From f85eb4caf1b8b28dd6d7b2a99e2c090558303976 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Fri, 23 Aug 2024 13:50:30 -0700 Subject: [PATCH] add hack to allow import in build scripts --- .gitea/workflows/build.yaml | 7 +++++++ build.zig | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 1226fa4..aba40f5 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -24,6 +24,12 @@ jobs: version: 0.13.0 - name: Run tests run: zig build test --verbose + # Zig build scripts don't have the ability to import depenedencies directly + # (https://github.com/ziglang/zig/issues/18164). We can allow downstream + # build scripts to import aws with a few tweaks, but we can't @import("src/aws.zig") + # until we have our models built. So we have to have the build script + # basically modified, only during packaging, to allow this use case + # # Zig package manager expects everything to be inside a directory in the archive, # which it then strips out on download. So we need to shove everything inside a directory # the way GitHub/Gitea does for repo archives @@ -33,6 +39,7 @@ jobs: # should be using git archive, but we need our generated code to be part of it - name: Package source code with generated models run: | + sed -i 's#// UNCOMMENT AFTER MODEL GEN TO USE IN BUILD SCRIPTS //##' build.zig tar -czf ${{ runner.temp }}/${{ github.sha }}-with-models.tar.gz \ --format ustar \ --exclude 'zig-*' \ diff --git a/build.zig b/build.zig index fc28506..8683afc 100644 --- a/build.zig +++ b/build.zig @@ -4,7 +4,7 @@ const Builder = @import("std").Build; const models_subdir = "codegen/sdk-codegen/aws-models/"; // note will probably not work on windows -pub const aws = @import("src/aws.zig"); +// UNCOMMENT AFTER MODEL GEN TO USE IN BUILD SCRIPTS //pub const aws = @import("src/aws.zig"); const test_targets = [_]std.Target.Query{ .{}, // native