Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix up the ci #14

Merged
merged 3 commits into from
Jun 29, 2024
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
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- master

jobs:
behaviour-test:
test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
Expand All @@ -28,9 +28,12 @@ jobs:
path: |
~/.cache/zig
.zig-cache
key: osmium-${{hashFiles('build.zig.zon')}}
key: osmium-${{hashFiles('build.zig.zon')}}

- name: Run Tests
- name: Build Osmium
run: zig build

- name: Run Behaviour Tests
run: zig build test --summary all

- name: Save Cache
Expand Down
131 changes: 74 additions & 57 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16,66 +16,83 @@ pub fn build(b: *std.Build) !void {
.target = target,
.optimize = optimize,
});

const trace = b.option(bool, "trace",
\\Enables tracing of the compiler using the default backend (spall)
) orelse false;
const backend: TraceBackend = bend: {
if (trace) {
break :bend b.option(TraceBackend, "trace-backend",
\\Switch between what backend to use. None is default.
) orelse .None;
}
break :bend .None;
};

const use_llvm = b.option(bool, "use-llvm", "Uses llvm to compile Osmium. Default true.") orelse true;
exe.use_llvm = use_llvm;
exe.use_lld = use_llvm;

const enable_logging = b.option(bool, "log", "Enable debug logging.") orelse false;
const enable_debug_extensions = b.option(
bool,
"debug-extensions",
"Enable commands and options useful for debugging the compiler",
) orelse (optimize == .Debug);
b.installArtifact(exe);

const exe_options = b.addOptions();
exe_options.addOption(bool, "trace", trace);
exe_options.addOption(TraceBackend, "backend", backend);
exe_options.addOption(bool, "enable_logging", enable_logging);
exe_options.addOption(usize, "src_file_trimlen", std.fs.path.dirname(std.fs.path.dirname(@src().file).?).?.len);
exe_options.addOption(bool, "enable_debug_extensions", enable_debug_extensions);
exe.root_module.addOptions("options", exe_options);

const tracer_dep = b.dependency("tracer", .{ .optimize = optimize, .target = target });
const libgc_dep = b.dependency("libgc", .{ .optimize = optimize, .target = target });
exe.root_module.addImport("tracer", tracer_dep.module("tracer"));
exe.root_module.addImport("gc", libgc_dep.module("gc"));

const libpython, const lib_path = try generateLibPython(b, target, optimize);
exe.linkLibrary(libpython);
exe_options.addOption([]const u8, "lib_path", lib_path);

b.installArtifact(exe);
const libpython_install = b.addInstallArtifact(libpython, .{
.dest_dir = .{ .override = .{ .custom = "python" } },
});
b.getInstallStep().dependOn(&libpython_install.step);

const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());

if (b.args) |args| run_cmd.addArgs(args);

const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);

const opcode_step = b.step("opcode", "Generate opcodes");
generateOpCode(b, opcode_step);

const test_step = b.step("test", "Test Osmium");
try cases.addCases(b, exe, test_step);
// options
{
const trace = b.option(
bool,
"trace",
"Enables tracing of the compiler using the default backend (spall)",
) orelse false;
const backend: TraceBackend = bend: {
if (trace) {
break :bend b.option(
TraceBackend,
"trace-backend",
"Switch between what backend to use. None is default.",
) orelse .None;
}
break :bend .None;
};

const use_llvm = b.option(bool, "use-llvm", "Uses llvm to compile Osmium. Default true.") orelse true;
exe.use_llvm = use_llvm;
exe.use_lld = use_llvm;

const enable_logging = b.option(bool, "log", "Enable debug logging.") orelse false;
const enable_debug_extensions = b.option(
bool,
"debug-extensions",
"Enable commands and options useful for debugging the compiler",
) orelse (optimize == .Debug);

exe_options.addOption(bool, "trace", trace);
exe_options.addOption(TraceBackend, "backend", backend);
exe_options.addOption(bool, "enable_logging", enable_logging);
exe_options.addOption(usize, "src_file_trimlen", std.fs.path.dirname(std.fs.path.dirname(@src().file).?).?.len);
exe_options.addOption(bool, "enable_debug_extensions", enable_debug_extensions);
}

// dependencies
{
const tracer_dep = b.dependency("tracer", .{ .optimize = optimize, .target = target });
const libgc_dep = b.dependency("libgc", .{ .optimize = optimize, .target = target });
exe.root_module.addImport("tracer", tracer_dep.module("tracer"));
exe.root_module.addImport("gc", libgc_dep.module("gc"));
}

// libpython
{
const libpython, const lib_path = try generateLibPython(b, target, optimize);
exe.linkLibrary(libpython);
exe_options.addOption([]const u8, "lib_path", lib_path);
const libpython_install = b.addInstallArtifact(libpython, .{
.dest_dir = .{ .override = .{ .custom = "python" } },
});
b.getInstallStep().dependOn(&libpython_install.step);

const test_step = b.step("test", "Test Osmium");
try cases.addCases(b, exe, test_step);
test_step.dependOn(&libpython_install.step);
}

// other steps
{
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());

if (b.args) |args| run_cmd.addArgs(args);

const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);

const opcode_step = b.step("opcode", "Generate opcodes");
generateOpCode(b, opcode_step);
}
}

const TraceBackend = enum {
Expand Down Expand Up @@ -146,7 +163,7 @@ fn generateLibPython(
.HAVE_CLOCK_GETRES = 1,
.HAVE_CLOCK_GETTIME = 1,
.HAVE_CLOCK_SETTIME = 1,
.HAVE_CLOSE_RANGE = have(t.isGnuLibC()),
.HAVE_CLOSE_RANGE = null,
.HAVE_COMPUTED_GOTOS = 1,
.HAVE_CONFSTR = 1,
.HAVE_COPY_FILE_RANGE = 1,
Expand Down
Loading