Skip to content

Commit

Permalink
Fix ci.
Browse files Browse the repository at this point in the history
  • Loading branch information
fubark committed May 14, 2024
1 parent b4d32a1 commit a49bf64
Show file tree
Hide file tree
Showing 11 changed files with 250 additions and 123 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gen-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
deploy:
runs-on: ubuntu-22.04
env:
ZIG_VERSION: 0.11.0
ZIG_VERSION: 0.12.0
steps:
- name: Clone repo.
uses: actions/checkout@v3
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/latest-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,14 @@ jobs:
restore-keys:
build-${{ env.BUILD_TARGET }}-${{ env.BUILD_MODE }}-1

- name: Run tests. (cli, debug)
if: env.BUILD_TARGET != 'wasm32-wasi' && env.BUILD_CMD == 'cli'
- name: Run tests. (debug)
if: env.BUILD_TARGET != 'wasm32-wasi' && (env.BUILD_CMD == 'cli' || (env.BUILD_CMD == 'lib' && env.BUILD_TARGET != 'x86_64-windows-msvc'))
run: |
zig build test ${{ env.ZIG_TARGET_FLAG }}
# Optimize with ReleaseSafe since there are issues with Zig 0.11.0 and building tests for ReleaseFast.
- name: Run tests. (cli, release)
if: env.BUILD_TARGET != 'wasm32-wasi' && env.BUILD_CMD == 'cli'
- name: Run tests. (release)
if: env.BUILD_TARGET != 'wasm32-wasi' && (env.BUILD_CMD == 'cli' || (env.BUILD_CMD == 'lib' && env.BUILD_TARGET != 'x86_64-windows-msvc'))
run: |
zig build test ${{ env.ZIG_TARGET_FLAG }} -Doptimize=ReleaseSafe
Expand Down Expand Up @@ -286,7 +286,7 @@ jobs:
- name: Move. (wasm)
if: env.BUILD_TARGET == 'wasm32-freestanding'
run: |
mv zig-out/lib/cyber-web.wasm ${{ env.BIN_ZIP }}
mv zig-out/bin/cyber-web.wasm ${{ env.BIN_ZIP }}
- name: Move. (wasi)
if: env.BUILD_TARGET == 'wasm32-wasi'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ jobs:
restore-keys:
pr-build-${{ env.BUILD_TARGET }}-${{ env.BUILD_MODE }}-1

- name: Run tests. (cli, debug)
if: env.BUILD_TARGET != 'wasm32-wasi' && env.BUILD_CMD == 'cli'
- name: Run tests. (debug)
if: env.BUILD_TARGET != 'wasm32-wasi' && (env.BUILD_CMD == 'cli' || (env.BUILD_CMD == 'lib' && env.BUILD_TARGET != 'x86_64-windows-msvc'))
run: |
zig build test ${{ env.ZIG_TARGET_FLAG }}
# Optimize with ReleaseSafe since there are issues with Zig 0.11.0 and building tests for ReleaseFast.
- name: Run tests. (cli, release)
if: env.BUILD_TARGET != 'wasm32-wasi' && env.BUILD_CMD == 'cli'
- name: Run tests. (release)
if: env.BUILD_TARGET != 'wasm32-wasi' && (env.BUILD_CMD == 'cli' || (env.BUILD_CMD == 'lib' && env.BUILD_TARGET != 'x86_64-windows-msvc'))
run: |
zig build test ${{ env.ZIG_TARGET_FLAG }} -Doptimize=ReleaseSafe
Expand Down
26 changes: 9 additions & 17 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ var optStatic: ?bool = undefined;
var optJIT: ?bool = undefined;
var optRT: ?config.Runtime = undefined;

var tcc: *std.Build.Module = undefined;
var linenoise: *std.Build.Module = undefined;
var mimalloc: *std.Build.Module = undefined;

var rtarget: std.Build.ResolvedTarget = undefined;
var target: std.Target = undefined;
var optimize: std.builtin.OptimizeMode = undefined;
Expand All @@ -44,10 +40,6 @@ pub fn build(b: *std.Build) !void {
optRT = b.option(config.Runtime, "rt", "Runtime.");
link_test = b.option(bool, "link-test", "Build test by linking lib. Disable for better stack traces.") orelse true;

tcc = tcc_lib.createModule(b);
mimalloc = mimalloc_lib.createModule(b);
linenoise = createLinenoiseModule(b);

{
const step = b.step("cli", "Build main cli.");

Expand Down Expand Up @@ -228,6 +220,7 @@ pub fn build(b: *std.Build) !void {
fn createAllModule(b: *std.Build, build_options: *std.Build.Module, stdx: *std.Build.Module, opts: Options) !*std.Build.Module {
const mod = b.createModule(.{
.root_source_file = .{ .path = thisDir() ++ "/src/all.zig" },
.target = rtarget,
});
mod.addIncludePath(.{ .path = thisDir() ++ "/src" });
try buildAndLinkDeps(mod, build_options, stdx, opts);
Expand All @@ -244,6 +237,7 @@ pub fn buildAndLinkDeps(mod: *std.Build.Module, build_options: *std.Build.Module
mod.link_libc = true;

if (opts.malloc == .mimalloc) {
const mimalloc = mimalloc_lib.createModule(b);
mod.addImport("mimalloc", mimalloc);
mimalloc_lib.buildAndLink(b, mod, .{
.target = rtarget,
Expand All @@ -260,8 +254,8 @@ pub fn buildAndLinkDeps(mod: *std.Build.Module, build_options: *std.Build.Module
}

if (opts.ffi) {
const tcc_ = tcc_lib.createModule(b);
tcc_lib.addImport(mod, "tcc", tcc_);
const tcc = tcc_lib.createModule(b);
tcc_lib.addImport(mod, "tcc", tcc);
tcc_lib.buildAndLink(b, mod, .{
.selinux = selinux,
.target = rtarget,
Expand All @@ -276,8 +270,8 @@ pub fn buildAndLinkDeps(mod: *std.Build.Module, build_options: *std.Build.Module
}

if (opts.cli and target.os.tag != .windows and target.os.tag != .wasi) {
const linenoise_ = createLinenoiseModule(b);
mod.addImport("linenoise", linenoise_);
const linenoise = createLinenoiseModule(b);
mod.addImport("linenoise", linenoise);
buildAndLinkLinenoise(b, mod);
} else {
mod.addAnonymousImport("linenoise", .{
Expand Down Expand Up @@ -419,6 +413,9 @@ fn addBehaviorTest(b: *std.Build, opts: Options) !*std.Build.Step.Compile {
.filter = testFilter,
});

// For linux FFI test.
step.rdynamic = true;

const build_options = try createBuildOptions(b, opts);
step.root_module.addImport("build_options", build_options);

Expand Down Expand Up @@ -526,11 +523,6 @@ pub fn buildCVM(b: *std.Build, opts: Options) !*std.Build.Step.Compile {
} else {
try cflags.append("-DDEBUG=0");
}
if (optimize == .Debug) {
try cflags.append("-DDEBUG=1");
} else {
try cflags.append("-DDEBUG=0");
}
try cflags.append("-DCGOTO=1");
if (opts.trackGlobalRc) {
try cflags.append("-DTRACK_GLOBAL_RC=1");
Expand Down
Loading

0 comments on commit a49bf64

Please sign in to comment.