mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
build.zig: use correct module graph for compiler unit tests
This commit is contained in:
parent
e26c326996
commit
6d7c89cb40
1 changed files with 11 additions and 6 deletions
17
build.zig
17
build.zig
|
|
@ -508,11 +508,9 @@ pub fn build(b: *std.Build) !void {
|
||||||
test_step.dependOn(unit_tests_step);
|
test_step.dependOn(unit_tests_step);
|
||||||
|
|
||||||
const unit_tests = b.addTest(.{
|
const unit_tests = b.addTest(.{
|
||||||
.root_module = b.createModule(.{
|
.root_module = addCompilerMod(b, .{
|
||||||
.root_source_file = b.path("src/main.zig"),
|
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.target = target,
|
.target = target,
|
||||||
.link_libc = link_libc,
|
|
||||||
.single_threaded = single_threaded,
|
.single_threaded = single_threaded,
|
||||||
}),
|
}),
|
||||||
.filters = test_filters,
|
.filters = test_filters,
|
||||||
|
|
@ -520,6 +518,9 @@ pub fn build(b: *std.Build) !void {
|
||||||
.use_lld = use_llvm,
|
.use_lld = use_llvm,
|
||||||
.zig_lib_dir = b.path("lib"),
|
.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.root_module.addOptions("build_options", exe_options);
|
||||||
unit_tests_step.dependOn(&b.addRunArtifact(unit_tests).step);
|
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);
|
update_zig1_step.dependOn(©_zig_h.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
const AddCompilerStepOptions = struct {
|
const AddCompilerModOptions = struct {
|
||||||
optimize: std.builtin.OptimizeMode,
|
optimize: std.builtin.OptimizeMode,
|
||||||
target: std.Build.ResolvedTarget,
|
target: std.Build.ResolvedTarget,
|
||||||
strip: ?bool = null,
|
strip: ?bool = null,
|
||||||
|
|
@ -659,7 +660,7 @@ const AddCompilerStepOptions = struct {
|
||||||
single_threaded: ?bool = null,
|
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(.{
|
const compiler_mod = b.createModule(.{
|
||||||
.root_source_file = b.path("src/main.zig"),
|
.root_source_file = b.path("src/main.zig"),
|
||||||
.target = options.target,
|
.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", aro_mod);
|
||||||
compiler_mod.addImport("aro_translate_c", aro_translate_c_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(.{
|
const exe = b.addExecutable(.{
|
||||||
.name = "zig",
|
.name = "zig",
|
||||||
.max_rss = 7_800_000_000,
|
.max_rss = 7_800_000_000,
|
||||||
.root_module = compiler_mod,
|
.root_module = addCompilerMod(b, options),
|
||||||
});
|
});
|
||||||
exe.stack_size = stack_size;
|
exe.stack_size = stack_size;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue