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