Skip to content

Commit

Permalink
Update stm32 generated code and properly set up data dependency as la…
Browse files Browse the repository at this point in the history
…zy (#331)

* update stm32 generated code and properly set up data dependency as lazy
* ignore untracked files
  • Loading branch information
mattnite authored Dec 23, 2024
1 parent 18fecdc commit 7a8704d
Show file tree
Hide file tree
Showing 3 changed files with 131,916 additions and 143,075 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ jobs:

stm32-gen-check:
name: Check that stm32 generated code is up to date
continue-on-error: true
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -168,11 +167,11 @@ jobs:
with:
version: ${{ env.ZIG_VERSION }}
- name: Generate Code
run: zig build update
run: zig build -Dgenerate
working-directory: port/stmicro/stm32
- name: Check for code diffs
run: |
if [[ $(git status --porcelain) ]]; then
if [[ $(git status --porcelain | grep -v '^??') ]]; then
echo "Code differences detected:"
git diff
echo "Please commit or fix these changes to proceed."
Expand Down
42 changes: 22 additions & 20 deletions port/stmicro/stm32/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,30 @@ pub fn init(dep: *std.Build.Dependency) Self {
}

pub fn build(b: *std.Build) !void {
const update = b.step("update", "Update chip definitions from embassy-rs/stm32-data-generated");
const generate = b.option(bool, "generate", "Generate chip definitions from embassy-rs/stm32-data-generated") orelse false;

const stm32_data_generated = b.lazyDependency("stm32-data-generated", .{}) orelse return;
if (generate) {
const stm32_data_generated = b.lazyDependency("stm32-data-generated", .{}) orelse return;

const generate_optimize = .ReleaseSafe;
const regz_dep = b.dependency("microzig/tools/regz", .{
.optimize = generate_optimize,
});
const regz = regz_dep.module("regz");
const generate_optimize = .ReleaseSafe;
const regz_dep = b.dependency("microzig/tools/regz", .{
.optimize = generate_optimize,
});
const regz = regz_dep.module("regz");

const generate = b.addExecutable(.{
.name = "generate",
.root_source_file = b.path("src/generate.zig"),
.target = b.host,
.optimize = generate_optimize,
});
generate.root_module.addImport("regz", regz);
const generate_exe = b.addExecutable(.{
.name = "generate",
.root_source_file = b.path("src/generate.zig"),
.target = b.host,
.optimize = generate_optimize,
});
generate_exe.root_module.addImport("regz", regz);

const generate_run = b.addRunArtifact(generate);
generate_run.max_stdio_size = std.math.maxInt(usize);
generate_run.addFileArg(stm32_data_generated.path("."));
update.dependOn(&generate_run.step);

_ = b.step("test", "Run platform agnostic unit tests");
const generate_run = b.addRunArtifact(generate_exe);
generate_run.max_stdio_size = std.math.maxInt(usize);
generate_run.addFileArg(stm32_data_generated.path("."));
b.getInstallStep().dependOn(&generate_run.step);
} else {
_ = b.step("test", "Run platform agnostic unit tests");
}
}
Loading

0 comments on commit 7a8704d

Please sign in to comment.