Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn build(b: *std.Build) !void {

const docgen_exe = b.addExecutable(.{
.name = "docgen",
.root_source_file = .{ .path = "tools/docgen.zig" },
.root_source_file = b.path("tools/docgen.zig"),
.target = b.host,
.optimize = .Debug,
.single_threaded = single_threaded,
Expand All @@ -46,7 +46,7 @@ pub fn build(b: *std.Build) !void {
docgen_cmd.addArg("--zig-lib-dir");
docgen_cmd.addDirectoryArg(p);
}
docgen_cmd.addFileArg(.{ .path = "doc/langref.html.in" });
docgen_cmd.addFileArg(b.path("doc/langref.html.in"));
const langref_file = docgen_cmd.addOutputFileArg("langref.html");
const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html");
if (!skip_install_langref) {
Expand All @@ -55,9 +55,9 @@ pub fn build(b: *std.Build) !void {

const autodoc_test = b.addObject(.{
.name = "std",
.root_source_file = .{ .path = "lib/std/std.zig" },
.root_source_file = b.path("lib/std/std.zig"),
.target = target,
.zig_lib_dir = .{ .path = "lib" },
.zig_lib_dir = b.path("lib"),
.optimize = .Debug,
});
const install_std_docs = b.addInstallDirectory(.{
Expand Down Expand Up @@ -86,7 +86,7 @@ pub fn build(b: *std.Build) !void {

const check_case_exe = b.addExecutable(.{
.name = "check-case",
.root_source_file = .{ .path = "test/src/Cases.zig" },
.root_source_file = b.path("test/src/Cases.zig"),
.target = b.host,
.optimize = optimize,
.single_threaded = single_threaded,
Expand Down Expand Up @@ -135,7 +135,7 @@ pub fn build(b: *std.Build) !void {

if (!skip_install_lib_files) {
b.installDirectory(.{
.source_dir = .{ .path = "lib" },
.source_dir = b.path("lib"),
.install_dir = if (flat) .prefix else .lib,
.install_subdir = if (flat) "lib" else "zig",
.exclude_extensions = &[_][]const u8{
Expand Down Expand Up @@ -377,8 +377,8 @@ pub fn build(b: *std.Build) !void {
else
&[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" };

exe.addIncludePath(.{ .cwd_relative = tracy_path });
exe.addCSourceFile(.{ .file = .{ .cwd_relative = client_cpp }, .flags = tracy_c_flags });
exe.addIncludePath(b.pathCwd(tracy_path));
exe.addCSourceFile(.{ .file = b.pathCwd(client_cpp), .flags = tracy_c_flags });
if (!enable_llvm) {
exe.root_module.linkSystemLibrary("c++", .{ .use_pkg_config = .no });
}
Expand Down Expand Up @@ -552,12 +552,12 @@ pub fn build(b: *std.Build) !void {
const update_mingw_exe = b.addExecutable(.{
.name = "update_mingw",
.target = b.host,
.root_source_file = .{ .path = "tools/update_mingw.zig" },
.root_source_file = b.path("tools/update_mingw.zig"),
});
const update_mingw_run = b.addRunArtifact(update_mingw_exe);
update_mingw_run.addDirectoryArg(.{ .path = "lib" });
update_mingw_run.addDirectoryArg(b.path("lib"));
if (opt_mingw_src_path) |mingw_src_path| {
update_mingw_run.addDirectoryArg(.{ .cwd_relative = mingw_src_path });
update_mingw_run.addDirectoryArg(b.pathCwd(mingw_src_path));
} else {
// Intentionally cause an error if this build step is requested.
update_mingw_run.addArg("--missing-mingw-source-directory");
Expand Down Expand Up @@ -606,10 +606,10 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
});
run_opt.addArtifactArg(exe);
run_opt.addArg("-o");
run_opt.addFileArg(.{ .path = "stage1/zig1.wasm" });
run_opt.addFileArg(b.path("stage1/zig1.wasm"));

const copy_zig_h = b.addWriteFiles();
copy_zig_h.addCopyFileToSource(.{ .path = "lib/zig.h" }, "stage1/zig.h");
copy_zig_h.addCopyFileToSource(b.path("lib/zig.h"), "stage1/zig.h");

const update_zig1_step = b.step("update-zig1", "Update stage1/zig1.wasm");
update_zig1_step.dependOn(&run_opt.step);
Expand All @@ -627,7 +627,7 @@ const AddCompilerStepOptions = struct {
fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.Step.Compile {
const exe = b.addExecutable(.{
.name = "zig",
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = options.target,
.optimize = options.optimize,
.max_rss = 7_000_000_000,
Expand All @@ -638,11 +638,11 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.St
exe.stack_size = stack_size;

const aro_module = b.createModule(.{
.root_source_file = .{ .path = "lib/compiler/aro/aro.zig" },
.root_source_file = b.path("lib/compiler/aro/aro.zig"),
});

const aro_translate_c_module = b.createModule(.{
.root_source_file = .{ .path = "lib/compiler/aro_translate_c.zig" },
.root_source_file = b.path("lib/compiler/aro_translate_c.zig"),
.imports = &.{
.{
.name = "aro",
Expand Down Expand Up @@ -680,19 +680,19 @@ fn addCmakeCfgOptionsToExe(
// useful for package maintainers
exe.headerpad_max_install_names = true;
}
exe.addObjectFile(.{ .cwd_relative = b.pathJoin(&[_][]const u8{
exe.addObjectFile(b.pathCwd(b.pathJoin(&[_][]const u8{
cfg.cmake_binary_dir,
"zigcpp",
b.fmt("{s}{s}{s}", .{
cfg.cmake_static_library_prefix,
"zigcpp",
cfg.cmake_static_library_suffix,
}),
}) });
})));
assert(cfg.lld_include_dir.len != 0);
exe.addIncludePath(.{ .cwd_relative = cfg.lld_include_dir });
exe.addIncludePath(.{ .cwd_relative = cfg.llvm_include_dir });
exe.addLibraryPath(.{ .cwd_relative = cfg.llvm_lib_dir });
exe.addIncludePath(b.pathCwd(cfg.lld_include_dir));
exe.addIncludePath(b.pathCwd(cfg.llvm_include_dir));
exe.addLibraryPath(b.pathCwd(cfg.llvm_lib_dir));
addCMakeLibraryList(exe, cfg.clang_libraries);
addCMakeLibraryList(exe, cfg.lld_libraries);
addCMakeLibraryList(exe, cfg.llvm_libraries);
Expand Down Expand Up @@ -755,7 +755,7 @@ fn addCmakeCfgOptionsToExe(
}

if (cfg.dia_guids_lib.len != 0) {
exe.addObjectFile(.{ .cwd_relative = cfg.dia_guids_lib });
exe.addObjectFile(b.pathCwd(cfg.dia_guids_lib));
}
}

Expand Down Expand Up @@ -827,7 +827,7 @@ fn addCxxKnownPath(
}
return error.RequiredLibraryNotFound;
}
exe.addObjectFile(.{ .cwd_relative = path_unpadded });
exe.addObjectFile(b.pathCwd(path_unpadded));

// TODO a way to integrate with system c++ include files here
// c++ -E -Wp,-v -xc++ /dev/null
Expand All @@ -849,7 +849,7 @@ fn addCMakeLibraryList(exe: *std.Build.Step.Compile, list: []const u8) void {
{
exe.linkSystemLibrary(lib[0 .. lib.len - ".lib".len]);
} else {
exe.addObjectFile(.{ .cwd_relative = lib });
exe.addObjectFile(exe.step.owner.pathCwd(lib));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/build_runner.zig
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ pub fn main() !void {
});
};
} else if (mem.eql(u8, arg, "--zig-lib-dir")) {
builder.zig_lib_dir = .{ .cwd_relative = nextArgOrFatal(args, &arg_idx) };
builder.zig_lib_dir = builder.pathCwd(nextArgOrFatal(args, &arg_idx));
} else if (mem.eql(u8, arg, "--seed")) {
const next_arg = nextArg(args, &arg_idx) orelse
fatalWithHint("expected u32 after '{s}'", .{arg});
Expand Down
8 changes: 4 additions & 4 deletions lib/init/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn build(b: *std.Build) void {
.name = "$",
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
.root_source_file = .{ .path = "src/root.zig" },
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
Expand All @@ -31,7 +31,7 @@ pub fn build(b: *std.Build) void {

const exe = b.addExecutable(.{
.name = "$",
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
Expand Down Expand Up @@ -67,15 +67,15 @@ pub fn build(b: *std.Build) void {
// Creates a step for unit testing. This only builds the test executable
// but does not run it.
const lib_unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/root.zig" },
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});

const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);

const exe_unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
Expand Down
Loading