mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
build.zig: use correct module graph for compiler unit tests
This commit is contained in:
parent
e26c326996
commit
6d7c89cb40
17
build.zig
17
build.zig
@ -508,11 +508,9 @@ pub fn build(b: *std.Build) !void {
|
||||
test_step.dependOn(unit_tests_step);
|
||||
|
||||
const unit_tests = b.addTest(.{
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.root_module = addCompilerMod(b, .{
|
||||
.optimize = optimize,
|
||||
.target = target,
|
||||
.link_libc = link_libc,
|
||||
.single_threaded = single_threaded,
|
||||
}),
|
||||
.filters = test_filters,
|
||||
@ -520,6 +518,9 @@ pub fn build(b: *std.Build) !void {
|
||||
.use_lld = use_llvm,
|
||||
.zig_lib_dir = b.path("lib"),
|
||||
});
|
||||
if (link_libc) {
|
||||
unit_tests.root_module.link_libc = true;
|
||||
}
|
||||
unit_tests.root_module.addOptions("build_options", exe_options);
|
||||
unit_tests_step.dependOn(&b.addRunArtifact(unit_tests).step);
|
||||
|
||||
@ -650,7 +651,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
|
||||
update_zig1_step.dependOn(©_zig_h.step);
|
||||
}
|
||||
|
||||
const AddCompilerStepOptions = struct {
|
||||
const AddCompilerModOptions = struct {
|
||||
optimize: std.builtin.OptimizeMode,
|
||||
target: std.Build.ResolvedTarget,
|
||||
strip: ?bool = null,
|
||||
@ -659,7 +660,7 @@ const AddCompilerStepOptions = struct {
|
||||
single_threaded: ?bool = null,
|
||||
};
|
||||
|
||||
fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.Step.Compile {
|
||||
fn addCompilerMod(b: *std.Build, options: AddCompilerModOptions) *std.Build.Module {
|
||||
const compiler_mod = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = options.target,
|
||||
@ -682,10 +683,14 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.St
|
||||
compiler_mod.addImport("aro", aro_mod);
|
||||
compiler_mod.addImport("aro_translate_c", aro_translate_c_mod);
|
||||
|
||||
return compiler_mod;
|
||||
}
|
||||
|
||||
fn addCompilerStep(b: *std.Build, options: AddCompilerModOptions) *std.Build.Step.Compile {
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "zig",
|
||||
.max_rss = 7_800_000_000,
|
||||
.root_module = compiler_mod,
|
||||
.root_module = addCompilerMod(b, options),
|
||||
});
|
||||
exe.stack_size = stack_size;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user