Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@ jobs:

- uses: mlugg/setup-zig@v2
with:
version: 0.16.0
version: 0.17.0

- name: Run zig fmt
if: matrix.os == 'Linux'
run: zig fmt --check .

- name: Run module tests
run: zig build test --summary all

- name: Run library tests
run: zig build -Dlibrary=static test --summary all
15 changes: 0 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
# drivercom

> PMF Smart Driver Communications Library.

## Building

### Library

To build `drivercom` as a static or dynamic C library, the `library` option
must be specified.

```console
zig build -Dlibrary=static
```

```console
zig build -Dlibrary=dynamic
```
38 changes: 0 additions & 38 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,22 @@ pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

const library = b.option(
std.builtin.LinkMode,
"library",
"Build an exportable C library.",
);

const build_zig_zon = b.createModule(.{
.root_source_file = b.path("build.zig.zon"),
.target = target,
.optimize = optimize,
});

const mmc_api = b.dependency("mmc_api", .{
.target = target,
.optimize = optimize,
});

const mod = b.addModule("drivercom", .{
.root_source_file = b.path("src/drivercom.zig"),
.target = target,
.optimize = optimize,
});
mod.addImport("build.zig.zon", build_zig_zon);
mod.addImport("mmc_api", mmc_api.module("mmc-api"));

const mod_unit_tests = b.addTest(.{ .root_module = mod });
const run_mod_unit_tests = b.addRunArtifact(mod_unit_tests);

const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_mod_unit_tests.step);

if (library) |l| {
const lib_mod = b.createModule(.{
.root_source_file = b.path("src/library.zig"),
.target = target,
.optimize = optimize,
});
lib_mod.addImport("drivercom", mod);

// Library Artifact
{
const lib = b.addLibrary(.{
.name = "drivercom",
.root_module = lib_mod,
.linkage = l,
});
b.installArtifact(lib);
}

// Library Tests
{
const lib_unit_tests = b.addTest(.{ .root_module = lib_mod });
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
test_step.dependOn(&run_lib_unit_tests.step);
}
}
}
9 changes: 2 additions & 7 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@
.name = .drivercom,
.version = "0.6.1",
.fingerprint = 0xc1b53adfd36fc2f0,
.minimum_zig_version = "0.16.0",
.dependencies = .{
.mmc_api = .{
.url = "https://github.com/pmotionf/mmc-api/archive/0a212c9.tar.gz",
.hash = "mmc_api-0.0.0-P5raR6pjMgCpq795vTCW5EnQ4eIrbLpCvA8SRw_8GS9Z",
},
},
.minimum_zig_version = "0.17.0",
.dependencies = .{},
.paths = .{
"build.zig",
"build.zig.zon",
Expand Down
Loading
Loading