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