| author | |
| committer | |
| log | 6bd590ad37dcb7e46c8eb78c54e69ad07e5b565e |
| tree | 512a9e21385bff95e3357ebad25d67a7d4503076 |
| parent | 82659c4594d12e5b80d2684320e15ce93eedb966 |
| signature |
56 files changed, 589 insertions(+), 374 deletions(-)
test/standalone/build.zig+5-3| ... | ... | @@ -47,9 +47,11 @@ pub fn build(b: *std.Build) void { |
| 47 | 47 | }) |tool_src_path| { |
| 48 | 48 | const tool = b.addTest(.{ |
| 49 | 49 | .name = std.fs.path.stem(tool_src_path), |
| 50 | .root_source_file = b.path(tool_src_path), | |
| 51 | .optimize = .Debug, | |
| 52 | .target = tools_target, | |
| 50 | .root_module = b.createModule(.{ | |
| 51 | .root_source_file = b.path(tool_src_path), | |
| 52 | .optimize = .Debug, | |
| 53 | .target = tools_target, | |
| 54 | }), | |
| 53 | 55 | }); |
| 54 | 56 | const run = b.addRunArtifact(tool); |
| 55 | 57 | tools_tests_step.dependOn(&run.step); |
test/standalone/c_compiler/build.zig+11-8| ... | ... | @@ -20,22 +20,25 @@ fn add( |
| 20 | 20 | ) void { |
| 21 | 21 | const target = b.graph.host; |
| 22 | 22 | |
| 23 | const exe_c = b.addExecutable(.{ | |
| 24 | .name = c_name, | |
| 23 | const c_mod = b.createModule(.{ | |
| 25 | 24 | .optimize = optimize, |
| 26 | 25 | .target = target, |
| 27 | 26 | }); |
| 28 | exe_c.addCSourceFile(.{ .file = b.path("test.c"), .flags = &[0][]const u8{} }); | |
| 29 | exe_c.linkLibC(); | |
| 27 | c_mod.addCSourceFile(.{ .file = b.path("test.c"), .flags = &[0][]const u8{} }); | |
| 28 | c_mod.link_libc = true; | |
| 30 | 29 | |
| 31 | const exe_cpp = b.addExecutable(.{ | |
| 32 | .name = cpp_name, | |
| 30 | const exe_c = b.addExecutable(.{ .name = c_name, .root_module = c_mod }); | |
| 31 | ||
| 32 | const cpp_mod = b.createModule(.{ | |
| 33 | 33 | .optimize = optimize, |
| 34 | 34 | .target = target, |
| 35 | 35 | }); |
| 36 | cpp_mod.addCSourceFile(.{ .file = b.path("test.cpp"), .flags = &[0][]const u8{} }); | |
| 37 | cpp_mod.link_libcpp = true; | |
| 38 | ||
| 39 | const exe_cpp = b.addExecutable(.{ .name = cpp_name, .root_module = cpp_mod }); | |
| 40 | ||
| 36 | 41 | b.default_step.dependOn(&exe_cpp.step); |
| 37 | exe_cpp.addCSourceFile(.{ .file = b.path("test.cpp"), .flags = &[0][]const u8{} }); | |
| 38 | exe_cpp.linkLibCpp(); | |
| 39 | 42 | |
| 40 | 43 | switch (target.result.os.tag) { |
| 41 | 44 | .windows => { |
test/standalone/child_process/build.zig+10-6| ... | ... | @@ -12,16 +12,20 @@ pub fn build(b: *std.Build) void { |
| 12 | 12 | |
| 13 | 13 | const child = b.addExecutable(.{ |
| 14 | 14 | .name = "child", |
| 15 | .root_source_file = b.path("child.zig"), | |
| 16 | .optimize = optimize, | |
| 17 | .target = target, | |
| 15 | .root_module = b.createModule(.{ | |
| 16 | .root_source_file = b.path("child.zig"), | |
| 17 | .optimize = optimize, | |
| 18 | .target = target, | |
| 19 | }), | |
| 18 | 20 | }); |
| 19 | 21 | |
| 20 | 22 | const main = b.addExecutable(.{ |
| 21 | 23 | .name = "main", |
| 22 | .root_source_file = b.path("main.zig"), | |
| 23 | .optimize = optimize, | |
| 24 | .target = target, | |
| 24 | .root_module = b.createModule(.{ | |
| 25 | .root_source_file = b.path("main.zig"), | |
| 26 | .optimize = optimize, | |
| 27 | .target = target, | |
| 28 | }), | |
| 25 | 29 | }); |
| 26 | 30 | const run = b.addRunArtifact(main); |
| 27 | 31 | run.addArtifactArg(child); |
test/standalone/coff_dwarf/build.zig+13-8| ... | ... | @@ -14,19 +14,24 @@ pub fn build(b: *std.Build) void { |
| 14 | 14 | |
| 15 | 15 | const exe = b.addExecutable(.{ |
| 16 | 16 | .name = "main", |
| 17 | .root_source_file = b.path("main.zig"), | |
| 18 | .optimize = optimize, | |
| 19 | .target = target, | |
| 17 | .root_module = b.createModule(.{ | |
| 18 | .root_source_file = b.path("main.zig"), | |
| 19 | .optimize = optimize, | |
| 20 | .target = target, | |
| 21 | }), | |
| 20 | 22 | }); |
| 21 | 23 | |
| 22 | 24 | const lib = b.addSharedLibrary(.{ |
| 23 | 25 | .name = "shared_lib", |
| 24 | .optimize = optimize, | |
| 25 | .target = target, | |
| 26 | .root_module = b.createModule(.{ | |
| 27 | .root_source_file = null, | |
| 28 | .optimize = optimize, | |
| 29 | .target = target, | |
| 30 | .link_libc = true, | |
| 31 | }), | |
| 26 | 32 | }); |
| 27 | lib.addCSourceFile(.{ .file = b.path("shared_lib.c"), .flags = &.{"-gdwarf"} }); | |
| 28 | lib.linkLibC(); | |
| 29 | exe.linkLibrary(lib); | |
| 33 | lib.root_module.addCSourceFile(.{ .file = b.path("shared_lib.c"), .flags = &.{"-gdwarf"} }); | |
| 34 | exe.root_module.linkLibrary(lib); | |
| 30 | 35 | |
| 31 | 36 | const run = b.addRunArtifact(exe); |
| 32 | 37 | run.expectExitCode(0); |
test/standalone/compiler_rt_panic/build.zig+7-4| ... | ... | @@ -12,11 +12,14 @@ pub fn build(b: *std.Build) void { |
| 12 | 12 | |
| 13 | 13 | const exe = b.addExecutable(.{ |
| 14 | 14 | .name = "main", |
| 15 | .optimize = optimize, | |
| 16 | .target = target, | |
| 15 | .root_module = b.createModule(.{ | |
| 16 | .root_source_file = null, | |
| 17 | .optimize = optimize, | |
| 18 | .target = target, | |
| 19 | .link_libc = true, | |
| 20 | }), | |
| 17 | 21 | }); |
| 18 | exe.linkLibC(); | |
| 19 | exe.addCSourceFile(.{ | |
| 22 | exe.root_module.addCSourceFile(.{ | |
| 20 | 23 | .file = b.path("main.c"), |
| 21 | 24 | .flags = &.{}, |
| 22 | 25 | }); |
test/standalone/dep_diamond/build.zig+13-13| ... | ... | @@ -6,23 +6,23 @@ pub fn build(b: *std.Build) void { |
| 6 | 6 | |
| 7 | 7 | const optimize: std.builtin.OptimizeMode = .Debug; |
| 8 | 8 | |
| 9 | const shared = b.createModule(.{ | |
| 10 | .root_source_file = b.path("shared.zig"), | |
| 11 | }); | |
| 12 | ||
| 13 | const exe = b.addExecutable(.{ | |
| 14 | .name = "test", | |
| 9 | const main_mod = b.createModule(.{ | |
| 15 | 10 | .root_source_file = b.path("test.zig"), |
| 16 | 11 | .target = b.graph.host, |
| 17 | 12 | .optimize = optimize, |
| 18 | 13 | }); |
| 19 | exe.root_module.addAnonymousImport("foo", .{ | |
| 20 | .root_source_file = b.path("foo.zig"), | |
| 21 | .imports = &.{.{ .name = "shared", .module = shared }}, | |
| 22 | }); | |
| 23 | exe.root_module.addAnonymousImport("bar", .{ | |
| 24 | .root_source_file = b.path("bar.zig"), | |
| 25 | .imports = &.{.{ .name = "shared", .module = shared }}, | |
| 14 | const shared_mod = b.createModule(.{ .root_source_file = b.path("shared.zig") }); | |
| 15 | const foo_mod = b.createModule(.{ .root_source_file = b.path("foo.zig") }); | |
| 16 | const bar_mod = b.createModule(.{ .root_source_file = b.path("bar.zig") }); | |
| 17 | ||
| 18 | main_mod.addImport("foo", foo_mod); | |
| 19 | main_mod.addImport("bar", bar_mod); | |
| 20 | foo_mod.addImport("shared", shared_mod); | |
| 21 | bar_mod.addImport("shared", shared_mod); | |
| 22 | ||
| 23 | const exe = b.addExecutable(.{ | |
| 24 | .name = "test", | |
| 25 | .root_module = main_mod, | |
| 26 | 26 | }); |
| 27 | 27 | |
| 28 | 28 | const run = b.addRunArtifact(exe); |
test/standalone/dep_duplicate_module/build.zig+17-10| ... | ... | @@ -4,29 +4,36 @@ pub fn build(b: *std.Build) void { |
| 4 | 4 | const target = b.standardTargetOptions(.{}); |
| 5 | 5 | const optimize = b.standardOptimizeOption(.{}); |
| 6 | 6 | |
| 7 | const mod = b.addModule("mod", .{ | |
| 7 | const shared_mod = b.createModule(.{ | |
| 8 | 8 | .root_source_file = b.path("mod.zig"), |
| 9 | 9 | .target = target, |
| 10 | 10 | .optimize = optimize, |
| 11 | 11 | }); |
| 12 | ||
| 13 | const lib = b.addStaticLibrary(.{ | |
| 14 | .name = "lib", | |
| 12 | const lib_mod = b.createModule(.{ | |
| 15 | 13 | .root_source_file = b.path("lib.zig"), |
| 16 | 14 | .target = target, |
| 17 | 15 | .optimize = optimize, |
| 18 | 16 | }); |
| 19 | lib.root_module.addImport("mod", mod); | |
| 20 | ||
| 21 | const exe = b.addExecutable(.{ | |
| 22 | .name = "app", | |
| 17 | const exe_mod = b.createModule(.{ | |
| 23 | 18 | .root_source_file = b.path("main.zig"), |
| 24 | 19 | .target = target, |
| 25 | 20 | .optimize = optimize, |
| 26 | 21 | }); |
| 27 | 22 | |
| 28 | exe.root_module.addImport("mod", mod); | |
| 29 | exe.root_module.linkLibrary(lib); | |
| 23 | lib_mod.addImport("mod", shared_mod); | |
| 24 | exe_mod.addImport("mod", shared_mod); | |
| 25 | ||
| 26 | const lib = b.addStaticLibrary(.{ | |
| 27 | .name = "lib", | |
| 28 | .root_module = lib_mod, | |
| 29 | }); | |
| 30 | ||
| 31 | exe_mod.linkLibrary(lib); | |
| 32 | ||
| 33 | const exe = b.addExecutable(.{ | |
| 34 | .name = "app", | |
| 35 | .root_module = exe_mod, | |
| 36 | }); | |
| 30 | 37 | |
| 31 | 38 | b.installArtifact(exe); |
| 32 | 39 | } |
test/standalone/dep_lazypath/build.zig+12-7| ... | ... | @@ -11,10 +11,13 @@ pub fn build(b: *std.Build) void { |
| 11 | 11 | const generated_main_c = write_files.add("main.c", ""); |
| 12 | 12 | const exe = b.addExecutable(.{ |
| 13 | 13 | .name = "test", |
| 14 | .target = b.graph.host, | |
| 15 | .optimize = optimize, | |
| 14 | .root_module = b.createModule(.{ | |
| 15 | .root_source_file = null, | |
| 16 | .target = b.graph.host, | |
| 17 | .optimize = optimize, | |
| 18 | }), | |
| 16 | 19 | }); |
| 17 | exe.addCSourceFiles(.{ | |
| 20 | exe.root_module.addCSourceFiles(.{ | |
| 18 | 21 | .root = generated_main_c.dirname(), |
| 19 | 22 | .files = &.{"main.c"}, |
| 20 | 23 | }); |
| ... | ... | @@ -26,11 +29,13 @@ pub fn build(b: *std.Build) void { |
| 26 | 29 | const dir = write_files.addCopyDirectory(b.path("inc"), "", .{}); |
| 27 | 30 | const exe = b.addExecutable(.{ |
| 28 | 31 | .name = "test", |
| 29 | .root_source_file = b.path("inctest.zig"), | |
| 30 | .target = b.graph.host, | |
| 31 | .optimize = optimize, | |
| 32 | .root_module = b.createModule(.{ | |
| 33 | .root_source_file = b.path("inctest.zig"), | |
| 34 | .target = b.graph.host, | |
| 35 | .optimize = optimize, | |
| 36 | }), | |
| 32 | 37 | }); |
| 33 | exe.addIncludePath(dir); | |
| 38 | exe.root_module.addIncludePath(dir); | |
| 34 | 39 | b.step("copydir", "").dependOn(&exe.step); |
| 35 | 40 | test_step.dependOn(&exe.step); |
| 36 | 41 | } |
test/standalone/dep_mutually_recursive/build.zig+12-8| ... | ... | @@ -6,22 +6,26 @@ pub fn build(b: *std.Build) void { |
| 6 | 6 | |
| 7 | 7 | const optimize: std.builtin.OptimizeMode = .Debug; |
| 8 | 8 | |
| 9 | const foo = b.createModule(.{ | |
| 9 | const main_mod = b.createModule(.{ | |
| 10 | .root_source_file = b.path("test.zig"), | |
| 11 | .target = b.graph.host, | |
| 12 | .optimize = optimize, | |
| 13 | }); | |
| 14 | const foo_mod = b.createModule(.{ | |
| 10 | 15 | .root_source_file = b.path("foo.zig"), |
| 11 | 16 | }); |
| 12 | const bar = b.createModule(.{ | |
| 17 | const bar_mod = b.createModule(.{ | |
| 13 | 18 | .root_source_file = b.path("bar.zig"), |
| 14 | 19 | }); |
| 15 | foo.addImport("bar", bar); | |
| 16 | bar.addImport("foo", foo); | |
| 20 | ||
| 21 | main_mod.addImport("foo", foo_mod); | |
| 22 | foo_mod.addImport("bar", bar_mod); | |
| 23 | bar_mod.addImport("foo", foo_mod); | |
| 17 | 24 | |
| 18 | 25 | const exe = b.addExecutable(.{ |
| 19 | 26 | .name = "test", |
| 20 | .root_source_file = b.path("test.zig"), | |
| 21 | .target = b.graph.host, | |
| 22 | .optimize = optimize, | |
| 27 | .root_module = main_mod, | |
| 23 | 28 | }); |
| 24 | exe.root_module.addImport("foo", foo); | |
| 25 | 29 | |
| 26 | 30 | const run = b.addRunArtifact(exe); |
| 27 | 31 | test_step.dependOn(&run.step); |
test/standalone/dep_recursive/build.zig+10-6| ... | ... | @@ -6,18 +6,22 @@ pub fn build(b: *std.Build) void { |
| 6 | 6 | |
| 7 | 7 | const optimize: std.builtin.OptimizeMode = .Debug; |
| 8 | 8 | |
| 9 | const foo = b.createModule(.{ | |
| 9 | const main_mod = b.createModule(.{ | |
| 10 | .root_source_file = b.path("test.zig"), | |
| 11 | .target = b.graph.host, | |
| 12 | .optimize = optimize, | |
| 13 | }); | |
| 14 | const foo_mod = b.createModule(.{ | |
| 10 | 15 | .root_source_file = b.path("foo.zig"), |
| 11 | 16 | }); |
| 12 | foo.addImport("foo", foo); | |
| 17 | ||
| 18 | main_mod.addImport("foo", foo_mod); | |
| 19 | foo_mod.addImport("foo", foo_mod); | |
| 13 | 20 | |
| 14 | 21 | const exe = b.addExecutable(.{ |
| 15 | 22 | .name = "test", |
| 16 | .root_source_file = b.path("test.zig"), | |
| 17 | .target = b.graph.host, | |
| 18 | .optimize = optimize, | |
| 23 | .root_module = main_mod, | |
| 19 | 24 | }); |
| 20 | exe.root_module.addImport("foo", foo); | |
| 21 | 25 | |
| 22 | 26 | const run = b.addRunArtifact(exe); |
| 23 | 27 | test_step.dependOn(&run.step); |
test/standalone/dep_shared_builtin/build.zig+9-3| ... | ... | @@ -6,16 +6,22 @@ pub fn build(b: *std.Build) void { |
| 6 | 6 | |
| 7 | 7 | const optimize: std.builtin.OptimizeMode = .Debug; |
| 8 | 8 | |
| 9 | const exe = b.addExecutable(.{ | |
| 10 | .name = "test", | |
| 9 | const main_mod = b.createModule(.{ | |
| 11 | 10 | .root_source_file = b.path("test.zig"), |
| 12 | 11 | .target = b.graph.host, |
| 13 | 12 | .optimize = optimize, |
| 14 | 13 | }); |
| 15 | exe.root_module.addAnonymousImport("foo", .{ | |
| 14 | const foo_mod = b.createModule(.{ | |
| 16 | 15 | .root_source_file = b.path("foo.zig"), |
| 17 | 16 | }); |
| 18 | 17 | |
| 18 | main_mod.addImport("foo", foo_mod); | |
| 19 | ||
| 20 | const exe = b.addExecutable(.{ | |
| 21 | .name = "test", | |
| 22 | .root_module = main_mod, | |
| 23 | }); | |
| 24 | ||
| 19 | 25 | const run = b.addRunArtifact(exe); |
| 20 | 26 | test_step.dependOn(&run.step); |
| 21 | 27 | } |
test/standalone/dep_triangle/build.zig+14-9| ... | ... | @@ -6,21 +6,26 @@ pub fn build(b: *std.Build) void { |
| 6 | 6 | |
| 7 | 7 | const optimize: std.builtin.OptimizeMode = .Debug; |
| 8 | 8 | |
| 9 | const shared = b.createModule(.{ | |
| 10 | .root_source_file = b.path("shared.zig"), | |
| 11 | }); | |
| 12 | ||
| 13 | const exe = b.addExecutable(.{ | |
| 14 | .name = "test", | |
| 9 | const main_mod = b.createModule(.{ | |
| 15 | 10 | .root_source_file = b.path("test.zig"), |
| 16 | 11 | .target = b.graph.host, |
| 17 | 12 | .optimize = optimize, |
| 18 | 13 | }); |
| 19 | exe.root_module.addAnonymousImport("foo", .{ | |
| 14 | const foo_mod = b.createModule(.{ | |
| 20 | 15 | .root_source_file = b.path("foo.zig"), |
| 21 | .imports = &.{.{ .name = "shared", .module = shared }}, | |
| 22 | 16 | }); |
| 23 | exe.root_module.addImport("shared", shared); | |
| 17 | const shared_mod = b.createModule(.{ | |
| 18 | .root_source_file = b.path("shared.zig"), | |
| 19 | }); | |
| 20 | ||
| 21 | main_mod.addImport("foo", foo_mod); | |
| 22 | main_mod.addImport("shared", shared_mod); | |
| 23 | foo_mod.addImport("shared", shared_mod); | |
| 24 | ||
| 25 | const exe = b.addExecutable(.{ | |
| 26 | .name = "test", | |
| 27 | .root_module = main_mod, | |
| 28 | }); | |
| 24 | 29 | |
| 25 | 30 | const run = b.addRunArtifact(exe); |
| 26 | 31 | test_step.dependOn(&run.step); |
test/standalone/depend_on_main_mod/build.zig+9-6| ... | ... | @@ -7,19 +7,22 @@ pub fn build(b: *std.Build) void { |
| 7 | 7 | const target = b.standardTargetOptions(.{}); |
| 8 | 8 | const optimize = b.standardOptimizeOption(.{}); |
| 9 | 9 | |
| 10 | const exe = b.addExecutable(.{ | |
| 11 | .name = "depend_on_main_mod", | |
| 10 | const main_mod = b.createModule(.{ | |
| 12 | 11 | .root_source_file = b.path("src/main.zig"), |
| 13 | 12 | .target = target, |
| 14 | 13 | .optimize = optimize, |
| 15 | 14 | }); |
| 16 | ||
| 17 | const foo_module = b.addModule("foo", .{ | |
| 15 | const foo_mod = b.createModule(.{ | |
| 18 | 16 | .root_source_file = b.path("src/foo.zig"), |
| 19 | 17 | }); |
| 20 | 18 | |
| 21 | foo_module.addImport("root2", exe.root_module); | |
| 22 | exe.root_module.addImport("foo", foo_module); | |
| 19 | foo_mod.addImport("root2", main_mod); | |
| 20 | main_mod.addImport("foo", foo_mod); | |
| 21 | ||
| 22 | const exe = b.addExecutable(.{ | |
| 23 | .name = "depend_on_main_mod", | |
| 24 | .root_module = main_mod, | |
| 25 | }); | |
| 23 | 26 | |
| 24 | 27 | const run_cmd = b.addRunArtifact(exe); |
| 25 | 28 | run_cmd.expectExitCode(0); |
test/standalone/dirname/build.zig+15-9| ... | ... | @@ -10,24 +10,30 @@ pub fn build(b: *std.Build) void { |
| 10 | 10 | |
| 11 | 11 | const touch = b.addExecutable(.{ |
| 12 | 12 | .name = "touch", |
| 13 | .root_source_file = touch_src, | |
| 14 | .optimize = .Debug, | |
| 15 | .target = target, | |
| 13 | .root_module = b.createModule(.{ | |
| 14 | .root_source_file = touch_src, | |
| 15 | .optimize = .Debug, | |
| 16 | .target = target, | |
| 17 | }), | |
| 16 | 18 | }); |
| 17 | 19 | const generated = b.addRunArtifact(touch).addOutputFileArg("subdir" ++ std.fs.path.sep_str ++ "generated.txt"); |
| 18 | 20 | |
| 19 | 21 | const exists_in = b.addExecutable(.{ |
| 20 | 22 | .name = "exists_in", |
| 21 | .root_source_file = b.path("exists_in.zig"), | |
| 22 | .optimize = .Debug, | |
| 23 | .target = target, | |
| 23 | .root_module = b.createModule(.{ | |
| 24 | .root_source_file = b.path("exists_in.zig"), | |
| 25 | .optimize = .Debug, | |
| 26 | .target = target, | |
| 27 | }), | |
| 24 | 28 | }); |
| 25 | 29 | |
| 26 | 30 | const has_basename = b.addExecutable(.{ |
| 27 | 31 | .name = "has_basename", |
| 28 | .root_source_file = b.path("has_basename.zig"), | |
| 29 | .optimize = .Debug, | |
| 30 | .target = target, | |
| 32 | .root_module = b.createModule(.{ | |
| 33 | .root_source_file = b.path("has_basename.zig"), | |
| 34 | .optimize = .Debug, | |
| 35 | .target = target, | |
| 36 | }), | |
| 31 | 37 | }); |
| 32 | 38 | |
| 33 | 39 | // Known path: |
test/standalone/embed_generated_file/build.zig+10-7| ... | ... | @@ -6,18 +6,21 @@ pub fn build(b: *std.Build) void { |
| 6 | 6 | |
| 7 | 7 | const bootloader = b.addExecutable(.{ |
| 8 | 8 | .name = "bootloader", |
| 9 | .root_source_file = b.path("bootloader.zig"), | |
| 10 | .target = b.resolveTargetQuery(.{ | |
| 11 | .cpu_arch = .x86, | |
| 12 | .os_tag = .freestanding, | |
| 9 | .root_module = b.createModule(.{ | |
| 10 | .root_source_file = b.path("bootloader.zig"), | |
| 11 | .target = b.resolveTargetQuery(.{ | |
| 12 | .cpu_arch = .x86, | |
| 13 | .os_tag = .freestanding, | |
| 14 | }), | |
| 15 | .optimize = .ReleaseSmall, | |
| 13 | 16 | }), |
| 14 | .optimize = .ReleaseSmall, | |
| 15 | 17 | }); |
| 16 | 18 | |
| 17 | const exe = b.addTest(.{ | |
| 19 | const exe = b.addTest(.{ .root_module = b.createModule(.{ | |
| 18 | 20 | .root_source_file = b.path("main.zig"), |
| 21 | .target = b.graph.host, | |
| 19 | 22 | .optimize = .Debug, |
| 20 | }); | |
| 23 | }) }); | |
| 21 | 24 | exe.root_module.addAnonymousImport("bootloader.elf", .{ |
| 22 | 25 | .root_source_file = bootloader.getEmittedBin(), |
| 23 | 26 | }); |
test/standalone/emit_asm_and_bin/build.zig+3-2| ... | ... | @@ -4,10 +4,11 @@ pub fn build(b: *std.Build) void { |
| 4 | 4 | const test_step = b.step("test", "Test it"); |
| 5 | 5 | b.default_step = test_step; |
| 6 | 6 | |
| 7 | const main = b.addTest(.{ | |
| 7 | const main = b.addTest(.{ .root_module = b.createModule(.{ | |
| 8 | 8 | .root_source_file = b.path("main.zig"), |
| 9 | .target = b.graph.host, | |
| 9 | 10 | .optimize = b.standardOptimizeOption(.{}), |
| 10 | }); | |
| 11 | }) }); | |
| 11 | 12 | // TODO: actually check these two artifacts for correctness |
| 12 | 13 | _ = main.getEmittedBin(); |
| 13 | 14 | _ = main.getEmittedAsm(); |
test/standalone/emit_asm_no_bin/build.zig+5-3| ... | ... | @@ -8,9 +8,11 @@ pub fn build(b: *std.Build) void { |
| 8 | 8 | |
| 9 | 9 | const obj = b.addObject(.{ |
| 10 | 10 | .name = "main", |
| 11 | .root_source_file = b.path("main.zig"), | |
| 12 | .optimize = optimize, | |
| 13 | .target = b.graph.host, | |
| 11 | .root_module = b.createModule(.{ | |
| 12 | .root_source_file = b.path("main.zig"), | |
| 13 | .optimize = optimize, | |
| 14 | .target = b.graph.host, | |
| 15 | }), | |
| 14 | 16 | }); |
| 15 | 17 | _ = obj.getEmittedAsm(); |
| 16 | 18 | b.default_step.dependOn(&obj.step); |
test/standalone/emit_llvm_no_bin/build.zig+5-3| ... | ... | @@ -8,9 +8,11 @@ pub fn build(b: *std.Build) void { |
| 8 | 8 | |
| 9 | 9 | const obj = b.addObject(.{ |
| 10 | 10 | .name = "main", |
| 11 | .root_source_file = b.path("main.zig"), | |
| 12 | .optimize = optimize, | |
| 13 | .target = b.graph.host, | |
| 11 | .root_module = b.createModule(.{ | |
| 12 | .root_source_file = b.path("main.zig"), | |
| 13 | .optimize = optimize, | |
| 14 | .target = b.graph.host, | |
| 15 | }), | |
| 14 | 16 | }); |
| 15 | 17 | _ = obj.getEmittedLlvmIr(); |
| 16 | 18 | _ = obj.getEmittedLlvmBc(); |
test/standalone/empty_env/build.zig+5-3| ... | ... | @@ -21,9 +21,11 @@ pub fn build(b: *std.Build) void { |
| 21 | 21 | |
| 22 | 22 | const main = b.addExecutable(.{ |
| 23 | 23 | .name = "main", |
| 24 | .root_source_file = b.path("main.zig"), | |
| 25 | .target = b.graph.host, | |
| 26 | .optimize = optimize, | |
| 24 | .root_module = b.createModule(.{ | |
| 25 | .root_source_file = b.path("main.zig"), | |
| 26 | .target = b.graph.host, | |
| 27 | .optimize = optimize, | |
| 28 | }), | |
| 27 | 29 | }); |
| 28 | 30 | |
| 29 | 31 | const run = b.addRunArtifact(main); |
test/standalone/extern/build.zig+15-9| ... | ... | @@ -8,22 +8,28 @@ pub fn build(b: *std.Build) void { |
| 8 | 8 | |
| 9 | 9 | const obj = b.addObject(.{ |
| 10 | 10 | .name = "exports", |
| 11 | .root_source_file = b.path("exports.zig"), | |
| 12 | .target = b.graph.host, | |
| 13 | .optimize = optimize, | |
| 11 | .root_module = b.createModule(.{ | |
| 12 | .root_source_file = b.path("exports.zig"), | |
| 13 | .target = b.graph.host, | |
| 14 | .optimize = optimize, | |
| 15 | }), | |
| 14 | 16 | }); |
| 15 | 17 | const shared = b.addSharedLibrary(.{ |
| 16 | 18 | .name = "shared", |
| 17 | .target = b.graph.host, | |
| 18 | .optimize = optimize, | |
| 19 | .link_libc = true, | |
| 19 | .root_module = b.createModule(.{ | |
| 20 | .root_source_file = null, | |
| 21 | .target = b.graph.host, | |
| 22 | .optimize = optimize, | |
| 23 | .link_libc = true, | |
| 24 | }), | |
| 20 | 25 | }); |
| 21 | 26 | if (b.graph.host.result.abi == .msvc) shared.root_module.addCMacro("API", "__declspec(dllexport)"); |
| 22 | shared.addCSourceFile(.{ .file = b.path("shared.c"), .flags = &.{} }); | |
| 23 | const test_exe = b.addTest(.{ | |
| 27 | shared.root_module.addCSourceFile(.{ .file = b.path("shared.c"), .flags = &.{} }); | |
| 28 | const test_exe = b.addTest(.{ .root_module = b.createModule(.{ | |
| 24 | 29 | .root_source_file = b.path("main.zig"), |
| 30 | .target = b.graph.host, | |
| 25 | 31 | .optimize = optimize, |
| 26 | }); | |
| 32 | }) }); | |
| 27 | 33 | test_exe.addObject(obj); |
| 28 | 34 | test_exe.linkLibrary(shared); |
| 29 | 35 |
test/standalone/global_linkage/build.zig+15-9| ... | ... | @@ -9,24 +9,30 @@ pub fn build(b: *std.Build) void { |
| 9 | 9 | |
| 10 | 10 | const obj1 = b.addStaticLibrary(.{ |
| 11 | 11 | .name = "obj1", |
| 12 | .root_source_file = b.path("obj1.zig"), | |
| 13 | .optimize = optimize, | |
| 14 | .target = target, | |
| 12 | .root_module = b.createModule(.{ | |
| 13 | .root_source_file = b.path("obj1.zig"), | |
| 14 | .optimize = optimize, | |
| 15 | .target = target, | |
| 16 | }), | |
| 15 | 17 | }); |
| 16 | 18 | |
| 17 | 19 | const obj2 = b.addStaticLibrary(.{ |
| 18 | 20 | .name = "obj2", |
| 19 | .root_source_file = b.path("obj2.zig"), | |
| 20 | .optimize = optimize, | |
| 21 | .target = target, | |
| 21 | .root_module = b.createModule(.{ | |
| 22 | .root_source_file = b.path("obj2.zig"), | |
| 23 | .optimize = optimize, | |
| 24 | .target = target, | |
| 25 | }), | |
| 22 | 26 | }); |
| 23 | 27 | |
| 24 | const main = b.addTest(.{ | |
| 28 | const main_mod = b.createModule(.{ | |
| 25 | 29 | .root_source_file = b.path("main.zig"), |
| 30 | .target = b.graph.host, | |
| 26 | 31 | .optimize = optimize, |
| 27 | 32 | }); |
| 28 | main.linkLibrary(obj1); | |
| 29 | main.linkLibrary(obj2); | |
| 33 | main_mod.linkLibrary(obj1); | |
| 34 | main_mod.linkLibrary(obj2); | |
| 30 | 35 | |
| 36 | const main = b.addTest(.{ .root_module = main_mod }); | |
| 31 | 37 | test_step.dependOn(&b.addRunArtifact(main).step); |
| 32 | 38 | } |
test/standalone/install_headers/build.zig+27-15| ... | ... | @@ -8,18 +8,24 @@ pub fn build(b: *std.Build) void { |
| 8 | 8 | |
| 9 | 9 | const libfoo = b.addStaticLibrary(.{ |
| 10 | 10 | .name = "foo", |
| 11 | .target = b.resolveTargetQuery(.{}), | |
| 12 | .optimize = .Debug, | |
| 11 | .root_module = b.createModule(.{ | |
| 12 | .root_source_file = null, | |
| 13 | .target = b.resolveTargetQuery(.{}), | |
| 14 | .optimize = .Debug, | |
| 15 | }), | |
| 13 | 16 | }); |
| 14 | libfoo.addCSourceFile(.{ .file = empty_c }); | |
| 17 | libfoo.root_module.addCSourceFile(.{ .file = empty_c }); | |
| 15 | 18 | |
| 16 | 19 | const exe = b.addExecutable(.{ |
| 17 | 20 | .name = "exe", |
| 18 | .target = b.resolveTargetQuery(.{}), | |
| 19 | .optimize = .Debug, | |
| 20 | .link_libc = true, | |
| 21 | .root_module = b.createModule(.{ | |
| 22 | .root_source_file = null, | |
| 23 | .target = b.resolveTargetQuery(.{}), | |
| 24 | .optimize = .Debug, | |
| 25 | .link_libc = true, | |
| 26 | }), | |
| 21 | 27 | }); |
| 22 | exe.addCSourceFile(.{ .file = b.addWriteFiles().add("main.c", | |
| 28 | exe.root_module.addCSourceFile(.{ .file = b.addWriteFiles().add("main.c", | |
| 23 | 29 | \\#include <stdio.h> |
| 24 | 30 | \\#include <foo/a.h> |
| 25 | 31 | \\#include <foo/sub_dir/b.h> |
| ... | ... | @@ -40,9 +46,10 @@ pub fn build(b: *std.Build) void { |
| 40 | 46 | |
| 41 | 47 | if (libfoo.installed_headers_include_tree != null) std.debug.panic("include tree step was created before linking", .{}); |
| 42 | 48 | |
| 43 | // Link before we have registered all headers for installation, | |
| 49 | // Link (and get the include tree) before we have registered all headers for installation, | |
| 44 | 50 | // to verify that the lazily created write files step is properly taken into account. |
| 45 | exe.linkLibrary(libfoo); | |
| 51 | exe.root_module.linkLibrary(libfoo); | |
| 52 | _ = libfoo.getEmittedIncludeTree(); | |
| 46 | 53 | |
| 47 | 54 | if (libfoo.installed_headers_include_tree == null) std.debug.panic("include tree step was not created after linking", .{}); |
| 48 | 55 | |
| ... | ... | @@ -56,10 +63,13 @@ pub fn build(b: *std.Build) void { |
| 56 | 63 | |
| 57 | 64 | const libbar = b.addStaticLibrary(.{ |
| 58 | 65 | .name = "bar", |
| 59 | .target = b.resolveTargetQuery(.{}), | |
| 60 | .optimize = .Debug, | |
| 66 | .root_module = b.createModule(.{ | |
| 67 | .root_source_file = null, | |
| 68 | .target = b.resolveTargetQuery(.{}), | |
| 69 | .optimize = .Debug, | |
| 70 | }), | |
| 61 | 71 | }); |
| 62 | libbar.addCSourceFile(.{ .file = empty_c }); | |
| 72 | libbar.root_module.addCSourceFile(.{ .file = empty_c }); | |
| 63 | 73 | libbar.installHeader(b.addWriteFiles().add("bar.h", |
| 64 | 74 | \\#define BAR_X "X" |
| 65 | 75 | \\ |
| ... | ... | @@ -78,9 +88,11 @@ pub fn build(b: *std.Build) void { |
| 78 | 88 | }); |
| 79 | 89 | const check_exists = b.addExecutable(.{ |
| 80 | 90 | .name = "check_exists", |
| 81 | .root_source_file = b.path("check_exists.zig"), | |
| 82 | .target = b.resolveTargetQuery(.{}), | |
| 83 | .optimize = .Debug, | |
| 91 | .root_module = b.createModule(.{ | |
| 92 | .root_source_file = b.path("check_exists.zig"), | |
| 93 | .target = b.resolveTargetQuery(.{}), | |
| 94 | .optimize = .Debug, | |
| 95 | }), | |
| 84 | 96 | }); |
| 85 | 97 | const run_check_exists = b.addRunArtifact(check_exists); |
| 86 | 98 | run_check_exists.addArgs(&.{ |
test/standalone/install_raw_hex/build.zig+5-3| ... | ... | @@ -16,9 +16,11 @@ pub fn build(b: *std.Build) void { |
| 16 | 16 | |
| 17 | 17 | const elf = b.addExecutable(.{ |
| 18 | 18 | .name = "zig-nrf52-blink.elf", |
| 19 | .root_source_file = b.path("main.zig"), | |
| 20 | .target = target, | |
| 21 | .optimize = optimize, | |
| 19 | .root_module = b.createModule(.{ | |
| 20 | .root_source_file = b.path("main.zig"), | |
| 21 | .target = target, | |
| 22 | .optimize = optimize, | |
| 23 | }), | |
| 22 | 24 | }); |
| 23 | 25 | |
| 24 | 26 | const hex_step = elf.addObjCopy(.{ |
test/standalone/ios/build.zig+12-9| ... | ... | @@ -18,16 +18,19 @@ pub fn build(b: *std.Build) void { |
| 18 | 18 | |
| 19 | 19 | const exe = b.addExecutable(.{ |
| 20 | 20 | .name = "main", |
| 21 | .optimize = optimize, | |
| 22 | .target = target, | |
| 21 | .root_module = b.createModule(.{ | |
| 22 | .root_source_file = null, | |
| 23 | .optimize = optimize, | |
| 24 | .target = target, | |
| 25 | .link_libc = true, | |
| 26 | }), | |
| 23 | 27 | }); |
| 24 | exe.addCSourceFile(.{ .file = b.path("main.m"), .flags = &.{} }); | |
| 25 | exe.addSystemIncludePath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/include" }) }); | |
| 26 | exe.addSystemFrameworkPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/System/Library/Frameworks" }) }); | |
| 27 | exe.addLibraryPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/lib" }) }); | |
| 28 | exe.linkFramework("Foundation"); | |
| 29 | exe.linkFramework("UIKit"); | |
| 30 | exe.linkLibC(); | |
| 28 | exe.root_module.addCSourceFile(.{ .file = b.path("main.m"), .flags = &.{} }); | |
| 29 | exe.root_module.addSystemIncludePath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/include" }) }); | |
| 30 | exe.root_module.addSystemFrameworkPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/System/Library/Frameworks" }) }); | |
| 31 | exe.root_module.addLibraryPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/lib" }) }); | |
| 32 | exe.root_module.linkFramework("Foundation", .{}); | |
| 33 | exe.root_module.linkFramework("UIKit", .{}); | |
| 31 | 34 | |
| 32 | 35 | const check = exe.checkObject(); |
| 33 | 36 | check.checkInHeaders(); |
test/standalone/issue_11595/build.zig+7-5| ... | ... | @@ -15,9 +15,11 @@ pub fn build(b: *std.Build) void { |
| 15 | 15 | |
| 16 | 16 | const exe = b.addExecutable(.{ |
| 17 | 17 | .name = "zigtest", |
| 18 | .root_source_file = b.path("main.zig"), | |
| 19 | .target = target, | |
| 20 | .optimize = optimize, | |
| 18 | .root_module = b.createModule(.{ | |
| 19 | .root_source_file = b.path("main.zig"), | |
| 20 | .target = target, | |
| 21 | .optimize = optimize, | |
| 22 | }), | |
| 21 | 23 | }); |
| 22 | 24 | b.installArtifact(exe); |
| 23 | 25 | |
| ... | ... | @@ -25,8 +27,8 @@ pub fn build(b: *std.Build) void { |
| 25 | 27 | "test.c", |
| 26 | 28 | }; |
| 27 | 29 | |
| 28 | exe.addCSourceFiles(.{ .files = &c_sources }); | |
| 29 | exe.linkLibC(); | |
| 30 | exe.root_module.addCSourceFiles(.{ .files = &c_sources }); | |
| 31 | exe.root_module.link_libc = true; | |
| 30 | 32 | |
| 31 | 33 | var i: i32 = 0; |
| 32 | 34 | while (i < 1000) : (i += 1) { |
test/standalone/issue_12706/build.zig+7-5| ... | ... | @@ -10,16 +10,18 @@ pub fn build(b: *std.Build) void { |
| 10 | 10 | |
| 11 | 11 | const exe = b.addExecutable(.{ |
| 12 | 12 | .name = "main", |
| 13 | .root_source_file = b.path("main.zig"), | |
| 14 | .optimize = optimize, | |
| 15 | .target = target, | |
| 13 | .root_module = b.createModule(.{ | |
| 14 | .root_source_file = b.path("main.zig"), | |
| 15 | .optimize = optimize, | |
| 16 | .target = target, | |
| 17 | }), | |
| 16 | 18 | }); |
| 17 | 19 | |
| 18 | 20 | const c_sources = [_][]const u8{ |
| 19 | 21 | "test.c", |
| 20 | 22 | }; |
| 21 | exe.addCSourceFiles(.{ .files = &c_sources }); | |
| 22 | exe.linkLibC(); | |
| 23 | exe.root_module.addCSourceFiles(.{ .files = &c_sources }); | |
| 24 | exe.root_module.link_libc = true; | |
| 23 | 25 | |
| 24 | 26 | const run_cmd = b.addRunArtifact(exe); |
| 25 | 27 | run_cmd.expectExitCode(0); |
test/standalone/issue_13970/build.zig+12-3| ... | ... | @@ -5,15 +5,24 @@ pub fn build(b: *std.Build) void { |
| 5 | 5 | b.default_step = test_step; |
| 6 | 6 | |
| 7 | 7 | const test1 = b.addTest(.{ |
| 8 | .root_source_file = b.path("test_root/empty.zig"), | |
| 8 | .root_module = b.createModule(.{ | |
| 9 | .root_source_file = b.path("test_root/empty.zig"), | |
| 10 | .target = b.graph.host, | |
| 11 | }), | |
| 9 | 12 | .test_runner = "src/main.zig", |
| 10 | 13 | }); |
| 11 | 14 | const test2 = b.addTest(.{ |
| 12 | .root_source_file = b.path("src/empty.zig"), | |
| 15 | .root_module = b.createModule(.{ | |
| 16 | .root_source_file = b.path("src/empty.zig"), | |
| 17 | .target = b.graph.host, | |
| 18 | }), | |
| 13 | 19 | .test_runner = "src/main.zig", |
| 14 | 20 | }); |
| 15 | 21 | const test3 = b.addTest(.{ |
| 16 | .root_source_file = b.path("empty.zig"), | |
| 22 | .root_module = b.createModule(.{ | |
| 23 | .root_source_file = b.path("empty.zig"), | |
| 24 | .target = b.graph.host, | |
| 25 | }), | |
| 17 | 26 | .test_runner = "src/main.zig", |
| 18 | 27 | }); |
| 19 | 28 |
test/standalone/issue_339/build.zig+5-3| ... | ... | @@ -9,9 +9,11 @@ pub fn build(b: *std.Build) void { |
| 9 | 9 | |
| 10 | 10 | const obj = b.addObject(.{ |
| 11 | 11 | .name = "test", |
| 12 | .root_source_file = b.path("test.zig"), | |
| 13 | .target = target, | |
| 14 | .optimize = optimize, | |
| 12 | .root_module = b.createModule(.{ | |
| 13 | .root_source_file = b.path("test.zig"), | |
| 14 | .target = target, | |
| 15 | .optimize = optimize, | |
| 16 | }), | |
| 15 | 17 | }); |
| 16 | 18 | |
| 17 | 19 | // TODO: actually check the output |
test/standalone/issue_5825/build.zig+13-8| ... | ... | @@ -16,20 +16,25 @@ pub fn build(b: *std.Build) void { |
| 16 | 16 | const optimize: std.builtin.OptimizeMode = .Debug; |
| 17 | 17 | const obj = b.addObject(.{ |
| 18 | 18 | .name = "issue_5825", |
| 19 | .root_source_file = b.path("main.zig"), | |
| 20 | .optimize = optimize, | |
| 21 | .target = target, | |
| 19 | .root_module = b.createModule(.{ | |
| 20 | .root_source_file = b.path("main.zig"), | |
| 21 | .optimize = optimize, | |
| 22 | .target = target, | |
| 23 | }), | |
| 22 | 24 | }); |
| 23 | 25 | |
| 24 | 26 | const exe = b.addExecutable(.{ |
| 25 | 27 | .name = "issue_5825", |
| 26 | .optimize = optimize, | |
| 27 | .target = target, | |
| 28 | .root_module = b.createModule(.{ | |
| 29 | .root_source_file = null, | |
| 30 | .optimize = optimize, | |
| 31 | .target = target, | |
| 32 | }), | |
| 28 | 33 | }); |
| 29 | 34 | exe.subsystem = .Console; |
| 30 | exe.linkSystemLibrary("kernel32"); | |
| 31 | exe.linkSystemLibrary("ntdll"); | |
| 32 | exe.addObject(obj); | |
| 35 | exe.root_module.linkSystemLibrary("kernel32", .{}); | |
| 36 | exe.root_module.linkSystemLibrary("ntdll", .{}); | |
| 37 | exe.root_module.addObject(obj); | |
| 33 | 38 | |
| 34 | 39 | // TODO: actually check the output |
| 35 | 40 | _ = exe.getEmittedBin(); |
test/standalone/issue_794/build.zig+3-2| ... | ... | @@ -4,9 +4,10 @@ pub fn build(b: *std.Build) void { |
| 4 | 4 | const test_step = b.step("test", "Test it"); |
| 5 | 5 | b.default_step = test_step; |
| 6 | 6 | |
| 7 | const test_artifact = b.addTest(.{ | |
| 7 | const test_artifact = b.addTest(.{ .root_module = b.createModule(.{ | |
| 8 | 8 | .root_source_file = b.path("main.zig"), |
| 9 | }); | |
| 9 | .target = b.graph.host, | |
| 10 | }) }); | |
| 10 | 11 | test_artifact.addIncludePath(b.path("a_directory")); |
| 11 | 12 | |
| 12 | 13 | // TODO: actually check the output |
test/standalone/issue_8550/build.zig+6-4| ... | ... | @@ -15,11 +15,13 @@ pub fn build(b: *std.Build) !void { |
| 15 | 15 | |
| 16 | 16 | const kernel = b.addExecutable(.{ |
| 17 | 17 | .name = "kernel", |
| 18 | .root_source_file = b.path("./main.zig"), | |
| 19 | .optimize = optimize, | |
| 20 | .target = target, | |
| 18 | .root_module = b.createModule(.{ | |
| 19 | .root_source_file = b.path("./main.zig"), | |
| 20 | .optimize = optimize, | |
| 21 | .target = target, | |
| 22 | }), | |
| 21 | 23 | }); |
| 22 | kernel.addObjectFile(b.path("./boot.S")); | |
| 24 | kernel.root_module.addObjectFile(b.path("./boot.S")); | |
| 23 | 25 | kernel.setLinkerScript(b.path("./linker.ld")); |
| 24 | 26 | b.installArtifact(kernel); |
| 25 | 27 |
test/standalone/libcxx/build.zig+15-11| ... | ... | @@ -11,12 +11,14 @@ pub fn build(b: *std.Build) void { |
| 11 | 11 | { |
| 12 | 12 | const exe = b.addExecutable(.{ |
| 13 | 13 | .name = "mt", |
| 14 | .root_source_file = b.path("mt.zig"), | |
| 15 | .target = target, | |
| 16 | .optimize = optimize, | |
| 14 | .root_module = b.createModule(.{ | |
| 15 | .root_source_file = b.path("mt.zig"), | |
| 16 | .target = target, | |
| 17 | .optimize = optimize, | |
| 18 | .link_libcpp = true, | |
| 19 | }), | |
| 17 | 20 | }); |
| 18 | exe.linkLibCpp(); | |
| 19 | exe.addCSourceFile(.{ .file = b.path("mt_doit.cpp") }); | |
| 21 | exe.root_module.addCSourceFile(.{ .file = b.path("mt_doit.cpp") }); | |
| 20 | 22 | link_step.dependOn(&exe.step); |
| 21 | 23 | b.installArtifact(exe); |
| 22 | 24 | run_step.dependOn(&b.addRunArtifact(exe).step); |
| ... | ... | @@ -24,13 +26,15 @@ pub fn build(b: *std.Build) void { |
| 24 | 26 | { |
| 25 | 27 | const exe = b.addExecutable(.{ |
| 26 | 28 | .name = "st", |
| 27 | .root_source_file = b.path("st.zig"), | |
| 28 | .target = target, | |
| 29 | .optimize = optimize, | |
| 30 | .single_threaded = true, | |
| 29 | .root_module = b.createModule(.{ | |
| 30 | .root_source_file = b.path("st.zig"), | |
| 31 | .target = target, | |
| 32 | .optimize = optimize, | |
| 33 | .link_libcpp = true, | |
| 34 | .single_threaded = true, | |
| 35 | }), | |
| 31 | 36 | }); |
| 32 | exe.linkLibCpp(); | |
| 33 | exe.addCSourceFile(.{ .file = b.path("st_doit.cpp") }); | |
| 37 | exe.root_module.addCSourceFile(.{ .file = b.path("st_doit.cpp") }); | |
| 34 | 38 | link_step.dependOn(&exe.step); |
| 35 | 39 | b.installArtifact(exe); |
| 36 | 40 | run_step.dependOn(&b.addRunArtifact(exe).step); |
test/standalone/load_dynamic_library/build.zig+10-6| ... | ... | @@ -12,17 +12,21 @@ pub fn build(b: *std.Build) void { |
| 12 | 12 | |
| 13 | 13 | const lib = b.addSharedLibrary(.{ |
| 14 | 14 | .name = "add", |
| 15 | .root_source_file = b.path("add.zig"), | |
| 16 | 15 | .version = .{ .major = 1, .minor = 0, .patch = 0 }, |
| 17 | .optimize = optimize, | |
| 18 | .target = target, | |
| 16 | .root_module = b.createModule(.{ | |
| 17 | .root_source_file = b.path("add.zig"), | |
| 18 | .optimize = optimize, | |
| 19 | .target = target, | |
| 20 | }), | |
| 19 | 21 | }); |
| 20 | 22 | |
| 21 | 23 | const main = b.addExecutable(.{ |
| 22 | 24 | .name = "main", |
| 23 | .root_source_file = b.path("main.zig"), | |
| 24 | .optimize = optimize, | |
| 25 | .target = target, | |
| 25 | .root_module = b.createModule(.{ | |
| 26 | .root_source_file = b.path("main.zig"), | |
| 27 | .optimize = optimize, | |
| 28 | .target = target, | |
| 29 | }), | |
| 26 | 30 | }); |
| 27 | 31 | |
| 28 | 32 | const run = b.addRunArtifact(main); |
test/standalone/mix_c_files/build.zig+7-5| ... | ... | @@ -18,12 +18,14 @@ pub fn build(b: *std.Build) void { |
| 18 | 18 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { |
| 19 | 19 | const exe = b.addExecutable(.{ |
| 20 | 20 | .name = "test", |
| 21 | .root_source_file = b.path("main.zig"), | |
| 22 | .target = b.graph.host, | |
| 23 | .optimize = optimize, | |
| 21 | .root_module = b.createModule(.{ | |
| 22 | .root_source_file = b.path("main.zig"), | |
| 23 | .target = b.graph.host, | |
| 24 | .optimize = optimize, | |
| 25 | .link_libc = true, | |
| 26 | }), | |
| 24 | 27 | }); |
| 25 | exe.addCSourceFile(.{ .file = b.path("test.c"), .flags = &[_][]const u8{"-std=c11"} }); | |
| 26 | exe.linkLibC(); | |
| 28 | exe.root_module.addCSourceFile(.{ .file = b.path("test.c"), .flags = &[_][]const u8{"-std=c11"} }); | |
| 27 | 29 | |
| 28 | 30 | const run_cmd = b.addRunArtifact(exe); |
| 29 | 31 | run_cmd.skip_foreign_checks = true; |
test/standalone/mix_o_files/build.zig+13-8| ... | ... | @@ -9,22 +9,27 @@ pub fn build(b: *std.Build) void { |
| 9 | 9 | |
| 10 | 10 | const obj = b.addObject(.{ |
| 11 | 11 | .name = "base64", |
| 12 | .root_source_file = b.path("base64.zig"), | |
| 13 | .optimize = optimize, | |
| 14 | .target = target, | |
| 12 | .root_module = b.createModule(.{ | |
| 13 | .root_source_file = b.path("base64.zig"), | |
| 14 | .optimize = optimize, | |
| 15 | .target = target, | |
| 16 | }), | |
| 15 | 17 | }); |
| 16 | 18 | |
| 17 | 19 | const exe = b.addExecutable(.{ |
| 18 | 20 | .name = "test", |
| 19 | .optimize = optimize, | |
| 20 | .target = target, | |
| 21 | .root_module = b.createModule(.{ | |
| 22 | .root_source_file = null, | |
| 23 | .optimize = optimize, | |
| 24 | .target = target, | |
| 25 | .link_libc = true, | |
| 26 | }), | |
| 21 | 27 | }); |
| 22 | exe.addCSourceFile(.{ | |
| 28 | exe.root_module.addCSourceFile(.{ | |
| 23 | 29 | .file = b.path("test.c"), |
| 24 | 30 | .flags = &[_][]const u8{"-std=c99"}, |
| 25 | 31 | }); |
| 26 | exe.addObject(obj); | |
| 27 | exe.linkSystemLibrary("c"); | |
| 32 | exe.root_module.addObject(obj); | |
| 28 | 33 | |
| 29 | 34 | b.default_step.dependOn(&exe.step); |
| 30 | 35 |
test/standalone/options/build.zig+2-2| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | |
| 3 | 3 | pub fn build(b: *std.Build) void { |
| 4 | const main = b.addTest(.{ | |
| 4 | const main = b.addTest(.{ .root_module = b.createModule(.{ | |
| 5 | 5 | .root_source_file = b.path("src/main.zig"), |
| 6 | 6 | .target = b.graph.host, |
| 7 | 7 | .optimize = .Debug, |
| 8 | }); | |
| 8 | }) }); | |
| 9 | 9 | |
| 10 | 10 | const options = b.addOptions(); |
| 11 | 11 | main.addOptions("build_options", options); |
test/standalone/pie/build.zig+5-3| ... | ... | @@ -11,9 +11,11 @@ pub fn build(b: *std.Build) void { |
| 11 | 11 | }); |
| 12 | 12 | |
| 13 | 13 | const main = b.addTest(.{ |
| 14 | .root_source_file = b.path("main.zig"), | |
| 15 | .optimize = optimize, | |
| 16 | .target = target, | |
| 14 | .root_module = b.createModule(.{ | |
| 15 | .root_source_file = b.path("main.zig"), | |
| 16 | .optimize = optimize, | |
| 17 | .target = target, | |
| 18 | }), | |
| 17 | 19 | }); |
| 18 | 20 | main.pie = true; |
| 19 | 21 |
test/standalone/pkg_import/build.zig+5-3| ... | ... | @@ -8,9 +8,11 @@ pub fn build(b: *std.Build) void { |
| 8 | 8 | |
| 9 | 9 | const exe = b.addExecutable(.{ |
| 10 | 10 | .name = "test", |
| 11 | .root_source_file = b.path("test.zig"), | |
| 12 | .optimize = optimize, | |
| 13 | .target = b.graph.host, | |
| 11 | .root_module = b.createModule(.{ | |
| 12 | .root_source_file = b.path("test.zig"), | |
| 13 | .optimize = optimize, | |
| 14 | .target = b.graph.host, | |
| 15 | }), | |
| 14 | 16 | }); |
| 15 | 17 | exe.root_module.addAnonymousImport("my_pkg", .{ .root_source_file = b.path("pkg.zig") }); |
| 16 | 18 |
test/standalone/run_output_caching/build.zig+5-3| ... | ... | @@ -9,9 +9,11 @@ pub fn build(b: *std.Build) void { |
| 9 | 9 | |
| 10 | 10 | const exe = b.addExecutable(.{ |
| 11 | 11 | .name = "create-file", |
| 12 | .root_source_file = b.path("main.zig"), | |
| 13 | .target = target, | |
| 14 | .optimize = optimize, | |
| 12 | .root_module = b.createModule(.{ | |
| 13 | .root_source_file = b.path("main.zig"), | |
| 14 | .target = target, | |
| 15 | .optimize = optimize, | |
| 16 | }), | |
| 15 | 17 | }); |
| 16 | 18 | |
| 17 | 19 | { |
test/standalone/run_output_paths/build.zig+5-3| ... | ... | @@ -9,9 +9,11 @@ pub fn build(b: *std.Build) void { |
| 9 | 9 | |
| 10 | 10 | const create_file_exe = b.addExecutable(.{ |
| 11 | 11 | .name = "create_file", |
| 12 | .root_source_file = b.path("create_file.zig"), | |
| 13 | .target = target, | |
| 14 | .optimize = optimize, | |
| 12 | .root_module = b.createModule(.{ | |
| 13 | .root_source_file = b.path("create_file.zig"), | |
| 14 | .target = target, | |
| 15 | .optimize = optimize, | |
| 16 | }), | |
| 15 | 17 | }); |
| 16 | 18 | |
| 17 | 19 | const create_first = b.addRunArtifact(create_file_exe); |
test/standalone/self_exe_symlink/build.zig+10-6| ... | ... | @@ -15,16 +15,20 @@ pub fn build(b: *std.Build) void { |
| 15 | 15 | |
| 16 | 16 | const main = b.addExecutable(.{ |
| 17 | 17 | .name = "main", |
| 18 | .root_source_file = b.path("main.zig"), | |
| 19 | .optimize = optimize, | |
| 20 | .target = target, | |
| 18 | .root_module = b.createModule(.{ | |
| 19 | .root_source_file = b.path("main.zig"), | |
| 20 | .optimize = optimize, | |
| 21 | .target = target, | |
| 22 | }), | |
| 21 | 23 | }); |
| 22 | 24 | |
| 23 | 25 | const create_symlink_exe = b.addExecutable(.{ |
| 24 | 26 | .name = "create-symlink", |
| 25 | .root_source_file = b.path("create-symlink.zig"), | |
| 26 | .optimize = optimize, | |
| 27 | .target = target, | |
| 27 | .root_module = b.createModule(.{ | |
| 28 | .root_source_file = b.path("create-symlink.zig"), | |
| 29 | .optimize = optimize, | |
| 30 | .target = target, | |
| 31 | }), | |
| 28 | 32 | }); |
| 29 | 33 | |
| 30 | 34 | var run_create_symlink = b.addRunArtifact(create_symlink_exe); |
test/standalone/shared_library/build.zig+13-8| ... | ... | @@ -8,23 +8,28 @@ pub fn build(b: *std.Build) void { |
| 8 | 8 | const target = b.graph.host; |
| 9 | 9 | const lib = b.addSharedLibrary(.{ |
| 10 | 10 | .name = "mathtest", |
| 11 | .root_source_file = b.path("mathtest.zig"), | |
| 12 | 11 | .version = .{ .major = 1, .minor = 0, .patch = 0 }, |
| 13 | .target = target, | |
| 14 | .optimize = optimize, | |
| 12 | .root_module = b.createModule(.{ | |
| 13 | .root_source_file = b.path("mathtest.zig"), | |
| 14 | .target = target, | |
| 15 | .optimize = optimize, | |
| 16 | }), | |
| 15 | 17 | }); |
| 16 | 18 | |
| 17 | 19 | const exe = b.addExecutable(.{ |
| 18 | 20 | .name = "test", |
| 19 | .target = target, | |
| 20 | .optimize = optimize, | |
| 21 | .root_module = b.createModule(.{ | |
| 22 | .root_source_file = null, | |
| 23 | .target = target, | |
| 24 | .optimize = optimize, | |
| 25 | .link_libc = true, | |
| 26 | }), | |
| 21 | 27 | }); |
| 22 | exe.addCSourceFile(.{ | |
| 28 | exe.root_module.addCSourceFile(.{ | |
| 23 | 29 | .file = b.path("test.c"), |
| 24 | 30 | .flags = &[_][]const u8{"-std=c99"}, |
| 25 | 31 | }); |
| 26 | exe.linkLibrary(lib); | |
| 27 | exe.linkSystemLibrary("c"); | |
| 32 | exe.root_module.linkLibrary(lib); | |
| 28 | 33 | |
| 29 | 34 | const run_cmd = b.addRunArtifact(exe); |
| 30 | 35 | test_step.dependOn(&run_cmd.step); |
test/standalone/simple/build.zig+12-8| ... | ... | @@ -42,11 +42,13 @@ pub fn build(b: *std.Build) void { |
| 42 | 42 | if (case.is_exe) { |
| 43 | 43 | const exe = b.addExecutable(.{ |
| 44 | 44 | .name = std.fs.path.stem(case.src_path), |
| 45 | .root_source_file = b.path(case.src_path), | |
| 46 | .optimize = optimize, | |
| 47 | .target = resolved_target, | |
| 45 | .root_module = b.createModule(.{ | |
| 46 | .root_source_file = b.path(case.src_path), | |
| 47 | .optimize = optimize, | |
| 48 | .target = resolved_target, | |
| 49 | }), | |
| 48 | 50 | }); |
| 49 | if (case.link_libc) exe.linkLibC(); | |
| 51 | if (case.link_libc) exe.root_module.link_libc = true; | |
| 50 | 52 | |
| 51 | 53 | _ = exe.getEmittedBin(); |
| 52 | 54 | |
| ... | ... | @@ -56,11 +58,13 @@ pub fn build(b: *std.Build) void { |
| 56 | 58 | if (case.is_test) { |
| 57 | 59 | const exe = b.addTest(.{ |
| 58 | 60 | .name = std.fs.path.stem(case.src_path), |
| 59 | .root_source_file = b.path(case.src_path), | |
| 60 | .optimize = optimize, | |
| 61 | .target = resolved_target, | |
| 61 | .root_module = b.createModule(.{ | |
| 62 | .root_source_file = b.path(case.src_path), | |
| 63 | .optimize = optimize, | |
| 64 | .target = resolved_target, | |
| 65 | }), | |
| 62 | 66 | }); |
| 63 | if (case.link_libc) exe.linkLibC(); | |
| 67 | if (case.link_libc) exe.root_module.link_libc = true; | |
| 64 | 68 | |
| 65 | 69 | const run = b.addRunArtifact(exe); |
| 66 | 70 | step.dependOn(&run.step); |
test/standalone/stack_iterator/build.zig+38-27| ... | ... | @@ -20,11 +20,13 @@ pub fn build(b: *std.Build) void { |
| 20 | 20 | { |
| 21 | 21 | const exe = b.addExecutable(.{ |
| 22 | 22 | .name = "unwind_fp", |
| 23 | .root_source_file = b.path("unwind.zig"), | |
| 24 | .target = target, | |
| 25 | .optimize = optimize, | |
| 26 | .unwind_tables = if (target.result.isDarwin()) .@"async" else null, | |
| 27 | .omit_frame_pointer = false, | |
| 23 | .root_module = b.createModule(.{ | |
| 24 | .root_source_file = b.path("unwind.zig"), | |
| 25 | .target = target, | |
| 26 | .optimize = optimize, | |
| 27 | .unwind_tables = if (target.result.isDarwin()) .@"async" else null, | |
| 28 | .omit_frame_pointer = false, | |
| 29 | }), | |
| 28 | 30 | }); |
| 29 | 31 | |
| 30 | 32 | const run_cmd = b.addRunArtifact(exe); |
| ... | ... | @@ -43,11 +45,13 @@ pub fn build(b: *std.Build) void { |
| 43 | 45 | { |
| 44 | 46 | const exe = b.addExecutable(.{ |
| 45 | 47 | .name = "unwind_nofp", |
| 46 | .root_source_file = b.path("unwind.zig"), | |
| 47 | .target = target, | |
| 48 | .optimize = optimize, | |
| 49 | .unwind_tables = .@"async", | |
| 50 | .omit_frame_pointer = true, | |
| 48 | .root_module = b.createModule(.{ | |
| 49 | .root_source_file = b.path("unwind.zig"), | |
| 50 | .target = target, | |
| 51 | .optimize = optimize, | |
| 52 | .unwind_tables = .@"async", | |
| 53 | .omit_frame_pointer = true, | |
| 54 | }), | |
| 51 | 55 | }); |
| 52 | 56 | |
| 53 | 57 | const run_cmd = b.addRunArtifact(exe); |
| ... | ... | @@ -66,27 +70,32 @@ pub fn build(b: *std.Build) void { |
| 66 | 70 | { |
| 67 | 71 | const c_shared_lib = b.addSharedLibrary(.{ |
| 68 | 72 | .name = "c_shared_lib", |
| 69 | .target = target, | |
| 70 | .optimize = optimize, | |
| 71 | .strip = false, | |
| 73 | .root_module = b.createModule(.{ | |
| 74 | .root_source_file = null, | |
| 75 | .target = target, | |
| 76 | .optimize = optimize, | |
| 77 | .link_libc = true, | |
| 78 | .strip = false, | |
| 79 | }), | |
| 72 | 80 | }); |
| 73 | 81 | |
| 74 | 82 | if (target.result.os.tag == .windows) |
| 75 | 83 | c_shared_lib.root_module.addCMacro("LIB_API", "__declspec(dllexport)"); |
| 76 | 84 | |
| 77 | c_shared_lib.addCSourceFile(.{ | |
| 85 | c_shared_lib.root_module.addCSourceFile(.{ | |
| 78 | 86 | .file = b.path("shared_lib.c"), |
| 79 | 87 | .flags = &.{"-fomit-frame-pointer"}, |
| 80 | 88 | }); |
| 81 | c_shared_lib.linkLibC(); | |
| 82 | 89 | |
| 83 | 90 | const exe = b.addExecutable(.{ |
| 84 | 91 | .name = "shared_lib_unwind", |
| 85 | .root_source_file = b.path("shared_lib_unwind.zig"), | |
| 86 | .target = target, | |
| 87 | .optimize = optimize, | |
| 88 | .unwind_tables = if (target.result.isDarwin()) .@"async" else null, | |
| 89 | .omit_frame_pointer = true, | |
| 92 | .root_module = b.createModule(.{ | |
| 93 | .root_source_file = b.path("shared_lib_unwind.zig"), | |
| 94 | .target = target, | |
| 95 | .optimize = optimize, | |
| 96 | .unwind_tables = if (target.result.isDarwin()) .@"async" else null, | |
| 97 | .omit_frame_pointer = true, | |
| 98 | }), | |
| 90 | 99 | }); |
| 91 | 100 | |
| 92 | 101 | exe.linkLibrary(c_shared_lib); |
| ... | ... | @@ -117,14 +126,16 @@ pub fn build(b: *std.Build) void { |
| 117 | 126 | inline for (no_os_targets) |os_tag| { |
| 118 | 127 | const exe = b.addExecutable(.{ |
| 119 | 128 | .name = "unwind_freestanding", |
| 120 | .root_source_file = b.path("unwind_freestanding.zig"), | |
| 121 | .target = b.resolveTargetQuery(.{ | |
| 122 | .cpu_arch = .x86_64, | |
| 123 | .os_tag = os_tag, | |
| 129 | .root_module = b.createModule(.{ | |
| 130 | .root_source_file = b.path("unwind_freestanding.zig"), | |
| 131 | .target = b.resolveTargetQuery(.{ | |
| 132 | .cpu_arch = .x86_64, | |
| 133 | .os_tag = os_tag, | |
| 134 | }), | |
| 135 | .optimize = optimize, | |
| 136 | .unwind_tables = null, | |
| 137 | .omit_frame_pointer = false, | |
| 124 | 138 | }), |
| 125 | .optimize = optimize, | |
| 126 | .unwind_tables = null, | |
| 127 | .omit_frame_pointer = false, | |
| 128 | 139 | }); |
| 129 | 140 | |
| 130 | 141 | // This "freestanding" binary is runnable because it invokes the |
test/standalone/static_c_lib/build.zig+12-8| ... | ... | @@ -8,18 +8,22 @@ pub fn build(b: *std.Build) void { |
| 8 | 8 | |
| 9 | 9 | const foo = b.addStaticLibrary(.{ |
| 10 | 10 | .name = "foo", |
| 11 | .optimize = optimize, | |
| 12 | .target = b.graph.host, | |
| 11 | .root_module = b.createModule(.{ | |
| 12 | .root_source_file = null, | |
| 13 | .optimize = optimize, | |
| 14 | .target = b.graph.host, | |
| 15 | }), | |
| 13 | 16 | }); |
| 14 | foo.addCSourceFile(.{ .file = b.path("foo.c"), .flags = &[_][]const u8{} }); | |
| 15 | foo.addIncludePath(b.path(".")); | |
| 17 | foo.root_module.addCSourceFile(.{ .file = b.path("foo.c"), .flags = &[_][]const u8{} }); | |
| 18 | foo.root_module.addIncludePath(b.path(".")); | |
| 16 | 19 | |
| 17 | const test_exe = b.addTest(.{ | |
| 20 | const test_exe = b.addTest(.{ .root_module = b.createModule(.{ | |
| 18 | 21 | .root_source_file = b.path("foo.zig"), |
| 22 | .target = b.graph.host, | |
| 19 | 23 | .optimize = optimize, |
| 20 | }); | |
| 21 | test_exe.linkLibrary(foo); | |
| 22 | test_exe.addIncludePath(b.path(".")); | |
| 24 | }) }); | |
| 25 | test_exe.root_module.linkLibrary(foo); | |
| 26 | test_exe.root_module.addIncludePath(b.path(".")); | |
| 23 | 27 | |
| 24 | 28 | test_step.dependOn(&b.addRunArtifact(test_exe).step); |
| 25 | 29 | } |
test/standalone/strip_empty_loop/build.zig+6-4| ... | ... | @@ -9,10 +9,12 @@ pub fn build(b: *std.Build) void { |
| 9 | 9 | |
| 10 | 10 | const main = b.addExecutable(.{ |
| 11 | 11 | .name = "main", |
| 12 | .root_source_file = b.path("main.zig"), | |
| 13 | .optimize = optimize, | |
| 14 | .target = target, | |
| 15 | .strip = true, | |
| 12 | .root_module = b.createModule(.{ | |
| 13 | .root_source_file = b.path("main.zig"), | |
| 14 | .optimize = optimize, | |
| 15 | .target = target, | |
| 16 | .strip = true, | |
| 17 | }), | |
| 16 | 18 | }); |
| 17 | 19 | |
| 18 | 20 | // TODO: actually check the output |
test/standalone/strip_struct_init/build.zig+6-3| ... | ... | @@ -7,9 +7,12 @@ pub fn build(b: *std.Build) void { |
| 7 | 7 | const optimize: std.builtin.OptimizeMode = .Debug; |
| 8 | 8 | |
| 9 | 9 | const main = b.addTest(.{ |
| 10 | .root_source_file = b.path("main.zig"), | |
| 11 | .optimize = optimize, | |
| 12 | .strip = true, | |
| 10 | .root_module = b.createModule(.{ | |
| 11 | .root_source_file = b.path("main.zig"), | |
| 12 | .target = b.graph.host, | |
| 13 | .optimize = optimize, | |
| 14 | .strip = true, | |
| 15 | }), | |
| 13 | 16 | }); |
| 14 | 17 | |
| 15 | 18 | test_step.dependOn(&b.addRunArtifact(main).step); |
test/standalone/test_runner_module_imports/build.zig+10-8| ... | ... | @@ -1,18 +1,20 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | |
| 3 | 3 | pub fn build(b: *std.Build) void { |
| 4 | const t = b.addTest(.{ | |
| 4 | const test_mod = b.createModule(.{ | |
| 5 | 5 | .root_source_file = b.path("src/main.zig"), |
| 6 | .test_runner = b.path("test_runner/main.zig"), | |
| 6 | .target = b.graph.host, | |
| 7 | 7 | }); |
| 8 | ||
| 9 | 8 | const module1 = b.createModule(.{ .root_source_file = b.path("module1/main.zig") }); |
| 10 | const module2 = b.createModule(.{ | |
| 11 | .root_source_file = b.path("module2/main.zig"), | |
| 12 | .imports = &.{.{ .name = "module1", .module = module1 }}, | |
| 13 | }); | |
| 9 | const module2 = b.createModule(.{ .root_source_file = b.path("module2/main.zig") }); | |
| 14 | 10 | |
| 15 | t.root_module.addImport("module2", module2); | |
| 11 | module2.addImport("module1", module1); | |
| 12 | test_mod.addImport("module2", module2); | |
| 13 | ||
| 14 | const t = b.addTest(.{ | |
| 15 | .root_module = test_mod, | |
| 16 | .test_runner = b.path("test_runner/main.zig"), | |
| 17 | }); | |
| 16 | 18 | |
| 17 | 19 | const test_step = b.step("test", "Run unit tests"); |
| 18 | 20 | test_step.dependOn(&b.addRunArtifact(t).step); |
test/standalone/test_runner_path/build.zig+3-2| ... | ... | @@ -6,9 +6,10 @@ pub fn build(b: *std.Build) void { |
| 6 | 6 | const test_step = b.step("test", "Test the program"); |
| 7 | 7 | b.default_step = test_step; |
| 8 | 8 | |
| 9 | const test_exe = b.addTest(.{ | |
| 9 | const test_exe = b.addTest(.{ .root_module = b.createModule(.{ | |
| 10 | .target = b.graph.host, | |
| 10 | 11 | .root_source_file = b.path("test.zig"), |
| 11 | }); | |
| 12 | }) }); | |
| 12 | 13 | test_exe.test_runner = b.path("test_runner.zig"); |
| 13 | 14 | |
| 14 | 15 | const test_run = b.addRunArtifact(test_exe); |
test/standalone/use_alias/build.zig+4-3| ... | ... | @@ -6,11 +6,12 @@ pub fn build(b: *std.Build) void { |
| 6 | 6 | |
| 7 | 7 | const optimize: std.builtin.OptimizeMode = .Debug; |
| 8 | 8 | |
| 9 | const main = b.addTest(.{ | |
| 9 | const main = b.addTest(.{ .root_module = b.createModule(.{ | |
| 10 | 10 | .root_source_file = b.path("main.zig"), |
| 11 | .target = b.graph.host, | |
| 11 | 12 | .optimize = optimize, |
| 12 | }); | |
| 13 | main.addIncludePath(b.path(".")); | |
| 13 | }) }); | |
| 14 | main.root_module.addIncludePath(b.path(".")); | |
| 14 | 15 | |
| 15 | 16 | test_step.dependOn(&b.addRunArtifact(main).step); |
| 16 | 17 | } |
test/standalone/windows_argv/build.zig+35-23| ... | ... | @@ -11,32 +11,39 @@ pub fn build(b: *std.Build) !void { |
| 11 | 11 | |
| 12 | 12 | const lib_gnu = b.addStaticLibrary(.{ |
| 13 | 13 | .name = "toargv-gnu", |
| 14 | .root_source_file = b.path("lib.zig"), | |
| 15 | .target = b.resolveTargetQuery(.{ | |
| 16 | .abi = .gnu, | |
| 14 | .root_module = b.createModule(.{ | |
| 15 | .root_source_file = b.path("lib.zig"), | |
| 16 | .target = b.resolveTargetQuery(.{ | |
| 17 | .abi = .gnu, | |
| 18 | }), | |
| 19 | .optimize = optimize, | |
| 17 | 20 | }), |
| 18 | .optimize = optimize, | |
| 19 | 21 | }); |
| 20 | 22 | const verify_gnu = b.addExecutable(.{ |
| 21 | 23 | .name = "verify-gnu", |
| 22 | .target = b.resolveTargetQuery(.{ | |
| 23 | .abi = .gnu, | |
| 24 | .root_module = b.createModule(.{ | |
| 25 | .root_source_file = null, | |
| 26 | .target = b.resolveTargetQuery(.{ | |
| 27 | .abi = .gnu, | |
| 28 | }), | |
| 29 | .optimize = optimize, | |
| 24 | 30 | }), |
| 25 | .optimize = optimize, | |
| 26 | 31 | }); |
| 27 | verify_gnu.addCSourceFile(.{ | |
| 32 | verify_gnu.root_module.addCSourceFile(.{ | |
| 28 | 33 | .file = b.path("verify.c"), |
| 29 | 34 | .flags = &.{ "-DUNICODE", "-D_UNICODE" }, |
| 30 | 35 | }); |
| 31 | 36 | verify_gnu.mingw_unicode_entry_point = true; |
| 32 | verify_gnu.linkLibrary(lib_gnu); | |
| 33 | verify_gnu.linkLibC(); | |
| 37 | verify_gnu.root_module.linkLibrary(lib_gnu); | |
| 38 | verify_gnu.root_module.link_libc = true; | |
| 34 | 39 | |
| 35 | 40 | const fuzz = b.addExecutable(.{ |
| 36 | 41 | .name = "fuzz", |
| 37 | .root_source_file = b.path("fuzz.zig"), | |
| 38 | .target = b.graph.host, | |
| 39 | .optimize = optimize, | |
| 42 | .root_module = b.createModule(.{ | |
| 43 | .root_source_file = b.path("fuzz.zig"), | |
| 44 | .target = b.graph.host, | |
| 45 | .optimize = optimize, | |
| 46 | }), | |
| 40 | 47 | }); |
| 41 | 48 | |
| 42 | 49 | const fuzz_max_iterations = b.option(u64, "iterations", "The max fuzz iterations (default: 100)") orelse 100; |
| ... | ... | @@ -69,25 +76,30 @@ pub fn build(b: *std.Build) !void { |
| 69 | 76 | if (has_msvc) { |
| 70 | 77 | const lib_msvc = b.addStaticLibrary(.{ |
| 71 | 78 | .name = "toargv-msvc", |
| 72 | .root_source_file = b.path("lib.zig"), | |
| 73 | .target = b.resolveTargetQuery(.{ | |
| 74 | .abi = .msvc, | |
| 79 | .root_module = b.createModule(.{ | |
| 80 | .root_source_file = b.path("lib.zig"), | |
| 81 | .target = b.resolveTargetQuery(.{ | |
| 82 | .abi = .msvc, | |
| 83 | }), | |
| 84 | .optimize = optimize, | |
| 75 | 85 | }), |
| 76 | .optimize = optimize, | |
| 77 | 86 | }); |
| 78 | 87 | const verify_msvc = b.addExecutable(.{ |
| 79 | 88 | .name = "verify-msvc", |
| 80 | .target = b.resolveTargetQuery(.{ | |
| 81 | .abi = .msvc, | |
| 89 | .root_module = b.createModule(.{ | |
| 90 | .root_source_file = null, | |
| 91 | .target = b.resolveTargetQuery(.{ | |
| 92 | .abi = .msvc, | |
| 93 | }), | |
| 94 | .optimize = optimize, | |
| 82 | 95 | }), |
| 83 | .optimize = optimize, | |
| 84 | 96 | }); |
| 85 | verify_msvc.addCSourceFile(.{ | |
| 97 | verify_msvc.root_module.addCSourceFile(.{ | |
| 86 | 98 | .file = b.path("verify.c"), |
| 87 | 99 | .flags = &.{ "-DUNICODE", "-D_UNICODE" }, |
| 88 | 100 | }); |
| 89 | verify_msvc.linkLibrary(lib_msvc); | |
| 90 | verify_msvc.linkLibC(); | |
| 101 | verify_msvc.root_module.linkLibrary(lib_msvc); | |
| 102 | verify_msvc.root_module.link_libc = true; | |
| 91 | 103 | |
| 92 | 104 | const run_msvc = b.addRunArtifact(fuzz); |
| 93 | 105 | run_msvc.setName("fuzz-msvc"); |
test/standalone/windows_bat_args/build.zig+15-9| ... | ... | @@ -12,16 +12,20 @@ pub fn build(b: *std.Build) !void { |
| 12 | 12 | |
| 13 | 13 | const echo_args = b.addExecutable(.{ |
| 14 | 14 | .name = "echo-args", |
| 15 | .root_source_file = b.path("echo-args.zig"), | |
| 16 | .optimize = optimize, | |
| 17 | .target = target, | |
| 15 | .root_module = b.createModule(.{ | |
| 16 | .root_source_file = b.path("echo-args.zig"), | |
| 17 | .optimize = optimize, | |
| 18 | .target = target, | |
| 19 | }), | |
| 18 | 20 | }); |
| 19 | 21 | |
| 20 | 22 | const test_exe = b.addExecutable(.{ |
| 21 | 23 | .name = "test", |
| 22 | .root_source_file = b.path("test.zig"), | |
| 23 | .optimize = optimize, | |
| 24 | .target = target, | |
| 24 | .root_module = b.createModule(.{ | |
| 25 | .root_source_file = b.path("test.zig"), | |
| 26 | .optimize = optimize, | |
| 27 | .target = target, | |
| 28 | }), | |
| 25 | 29 | }); |
| 26 | 30 | |
| 27 | 31 | const run = b.addRunArtifact(test_exe); |
| ... | ... | @@ -33,9 +37,11 @@ pub fn build(b: *std.Build) !void { |
| 33 | 37 | |
| 34 | 38 | const fuzz = b.addExecutable(.{ |
| 35 | 39 | .name = "fuzz", |
| 36 | .root_source_file = b.path("fuzz.zig"), | |
| 37 | .optimize = optimize, | |
| 38 | .target = target, | |
| 40 | .root_module = b.createModule(.{ | |
| 41 | .root_source_file = b.path("fuzz.zig"), | |
| 42 | .optimize = optimize, | |
| 43 | .target = target, | |
| 44 | }), | |
| 39 | 45 | }); |
| 40 | 46 | |
| 41 | 47 | const fuzz_max_iterations = b.option(u64, "iterations", "The max fuzz iterations (default: 100)") orelse 100; |
test/standalone/windows_entry_points/build.zig+28-16| ... | ... | @@ -13,11 +13,14 @@ pub fn build(b: *std.Build) void { |
| 13 | 13 | { |
| 14 | 14 | const exe = b.addExecutable(.{ |
| 15 | 15 | .name = "main", |
| 16 | .target = target, | |
| 17 | .optimize = .Debug, | |
| 18 | .link_libc = true, | |
| 16 | .root_module = b.createModule(.{ | |
| 17 | .root_source_file = null, | |
| 18 | .target = target, | |
| 19 | .optimize = .Debug, | |
| 20 | .link_libc = true, | |
| 21 | }), | |
| 19 | 22 | }); |
| 20 | exe.addCSourceFile(.{ .file = b.path("main.c") }); | |
| 23 | exe.root_module.addCSourceFile(.{ .file = b.path("main.c") }); | |
| 21 | 24 | |
| 22 | 25 | _ = exe.getEmittedBin(); |
| 23 | 26 | test_step.dependOn(&exe.step); |
| ... | ... | @@ -26,12 +29,15 @@ pub fn build(b: *std.Build) void { |
| 26 | 29 | { |
| 27 | 30 | const exe = b.addExecutable(.{ |
| 28 | 31 | .name = "wmain", |
| 29 | .target = target, | |
| 30 | .optimize = .Debug, | |
| 31 | .link_libc = true, | |
| 32 | .root_module = b.createModule(.{ | |
| 33 | .root_source_file = null, | |
| 34 | .target = target, | |
| 35 | .optimize = .Debug, | |
| 36 | .link_libc = true, | |
| 37 | }), | |
| 32 | 38 | }); |
| 33 | 39 | exe.mingw_unicode_entry_point = true; |
| 34 | exe.addCSourceFile(.{ .file = b.path("wmain.c") }); | |
| 40 | exe.root_module.addCSourceFile(.{ .file = b.path("wmain.c") }); | |
| 35 | 41 | |
| 36 | 42 | _ = exe.getEmittedBin(); |
| 37 | 43 | test_step.dependOn(&exe.step); |
| ... | ... | @@ -40,12 +46,15 @@ pub fn build(b: *std.Build) void { |
| 40 | 46 | { |
| 41 | 47 | const exe = b.addExecutable(.{ |
| 42 | 48 | .name = "winmain", |
| 43 | .target = target, | |
| 44 | .optimize = .Debug, | |
| 45 | .link_libc = true, | |
| 49 | .root_module = b.createModule(.{ | |
| 50 | .root_source_file = null, | |
| 51 | .target = target, | |
| 52 | .optimize = .Debug, | |
| 53 | .link_libc = true, | |
| 54 | }), | |
| 46 | 55 | }); |
| 47 | 56 | // Note: `exe.subsystem = .Windows;` is not necessary |
| 48 | exe.addCSourceFile(.{ .file = b.path("winmain.c") }); | |
| 57 | exe.root_module.addCSourceFile(.{ .file = b.path("winmain.c") }); | |
| 49 | 58 | |
| 50 | 59 | _ = exe.getEmittedBin(); |
| 51 | 60 | test_step.dependOn(&exe.step); |
| ... | ... | @@ -54,13 +63,16 @@ pub fn build(b: *std.Build) void { |
| 54 | 63 | { |
| 55 | 64 | const exe = b.addExecutable(.{ |
| 56 | 65 | .name = "wwinmain", |
| 57 | .target = target, | |
| 58 | .optimize = .Debug, | |
| 59 | .link_libc = true, | |
| 66 | .root_module = b.createModule(.{ | |
| 67 | .root_source_file = null, | |
| 68 | .target = target, | |
| 69 | .optimize = .Debug, | |
| 70 | .link_libc = true, | |
| 71 | }), | |
| 60 | 72 | }); |
| 61 | 73 | exe.mingw_unicode_entry_point = true; |
| 62 | 74 | // Note: `exe.subsystem = .Windows;` is not necessary |
| 63 | exe.addCSourceFile(.{ .file = b.path("wwinmain.c") }); | |
| 75 | exe.root_module.addCSourceFile(.{ .file = b.path("wwinmain.c") }); | |
| 64 | 76 | |
| 65 | 77 | _ = exe.getEmittedBin(); |
| 66 | 78 | test_step.dependOn(&exe.step); |
test/standalone/windows_resources/build.zig+6-4| ... | ... | @@ -28,11 +28,13 @@ fn add( |
| 28 | 28 | ) void { |
| 29 | 29 | const exe = b.addExecutable(.{ |
| 30 | 30 | .name = "zig_resource_test", |
| 31 | .root_source_file = b.path("main.zig"), | |
| 32 | .target = target, | |
| 33 | .optimize = .Debug, | |
| 31 | .root_module = b.createModule(.{ | |
| 32 | .root_source_file = b.path("main.zig"), | |
| 33 | .target = target, | |
| 34 | .optimize = .Debug, | |
| 35 | }), | |
| 34 | 36 | }); |
| 35 | exe.addWin32ResourceFile(.{ | |
| 37 | exe.root_module.addWin32ResourceFile(.{ | |
| 36 | 38 | .file = b.path("res/zig.rc"), |
| 37 | 39 | .flags = &.{"/c65001"}, // UTF-8 code page |
| 38 | 40 | .include_paths = &.{ |
test/standalone/windows_spawn/build.zig+10-6| ... | ... | @@ -12,16 +12,20 @@ pub fn build(b: *std.Build) void { |
| 12 | 12 | |
| 13 | 13 | const hello = b.addExecutable(.{ |
| 14 | 14 | .name = "hello", |
| 15 | .root_source_file = b.path("hello.zig"), | |
| 16 | .optimize = optimize, | |
| 17 | .target = target, | |
| 15 | .root_module = b.createModule(.{ | |
| 16 | .root_source_file = b.path("hello.zig"), | |
| 17 | .optimize = optimize, | |
| 18 | .target = target, | |
| 19 | }), | |
| 18 | 20 | }); |
| 19 | 21 | |
| 20 | 22 | const main = b.addExecutable(.{ |
| 21 | 23 | .name = "main", |
| 22 | .root_source_file = b.path("main.zig"), | |
| 23 | .optimize = optimize, | |
| 24 | .target = target, | |
| 24 | .root_module = b.createModule(.{ | |
| 25 | .root_source_file = b.path("main.zig"), | |
| 26 | .optimize = optimize, | |
| 27 | .target = target, | |
| 28 | }), | |
| 25 | 29 | }); |
| 26 | 30 | |
| 27 | 31 | const run = b.addRunArtifact(main); |
test/standalone/zerolength_check/build.zig+2-2| ... | ... | @@ -11,7 +11,7 @@ pub fn build(b: *std.Build) void { |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { |
| 14 | const unit_tests = b.addTest(.{ | |
| 14 | const unit_tests = b.addTest(.{ .root_module = b.createModule(.{ | |
| 15 | 15 | .root_source_file = b.path("src/main.zig"), |
| 16 | 16 | .target = b.resolveTargetQuery(.{ |
| 17 | 17 | .os_tag = .wasi, |
| ... | ... | @@ -19,7 +19,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize |
| 19 | 19 | .cpu_features_add = std.Target.wasm.featureSet(&.{.bulk_memory}), |
| 20 | 20 | }), |
| 21 | 21 | .optimize = optimize, |
| 22 | }); | |
| 22 | }) }); | |
| 23 | 23 | |
| 24 | 24 | const run_unit_tests = b.addRunArtifact(unit_tests); |
| 25 | 25 | run_unit_tests.skip_foreign_checks = true; |