mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
rename std.Build.LibExeObjStep to std.Build.CompileStep
This matches the nomenclature internally: a Compilation is the main type that represents a single invokation of the compiler.
This commit is contained in:
parent
77544683dd
commit
16cdd1297e
12
build.zig
12
build.zig
@ -516,7 +516,7 @@ fn addCompilerStep(
|
|||||||
b: *std.Build,
|
b: *std.Build,
|
||||||
optimize: std.builtin.OptimizeMode,
|
optimize: std.builtin.OptimizeMode,
|
||||||
target: std.zig.CrossTarget,
|
target: std.zig.CrossTarget,
|
||||||
) *std.Build.LibExeObjStep {
|
) *std.Build.CompileStep {
|
||||||
const exe = b.addExecutable(.{
|
const exe = b.addExecutable(.{
|
||||||
.name = "zig",
|
.name = "zig",
|
||||||
.root_source_file = .{ .path = "src/main.zig" },
|
.root_source_file = .{ .path = "src/main.zig" },
|
||||||
@ -544,7 +544,7 @@ const exe_cflags = [_][]const u8{
|
|||||||
fn addCmakeCfgOptionsToExe(
|
fn addCmakeCfgOptionsToExe(
|
||||||
b: *std.Build,
|
b: *std.Build,
|
||||||
cfg: CMakeConfig,
|
cfg: CMakeConfig,
|
||||||
exe: *std.Build.LibExeObjStep,
|
exe: *std.Build.CompileStep,
|
||||||
use_zig_libcxx: bool,
|
use_zig_libcxx: bool,
|
||||||
) !void {
|
) !void {
|
||||||
if (exe.target.isDarwin()) {
|
if (exe.target.isDarwin()) {
|
||||||
@ -623,7 +623,7 @@ fn addCmakeCfgOptionsToExe(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn addStaticLlvmOptionsToExe(exe: *std.Build.LibExeObjStep) !void {
|
fn addStaticLlvmOptionsToExe(exe: *std.Build.CompileStep) !void {
|
||||||
// Adds the Zig C++ sources which both stage1 and stage2 need.
|
// Adds the Zig C++ sources which both stage1 and stage2 need.
|
||||||
//
|
//
|
||||||
// We need this because otherwise zig_clang_cc1_main.cpp ends up pulling
|
// We need this because otherwise zig_clang_cc1_main.cpp ends up pulling
|
||||||
@ -662,7 +662,7 @@ fn addStaticLlvmOptionsToExe(exe: *std.Build.LibExeObjStep) !void {
|
|||||||
fn addCxxKnownPath(
|
fn addCxxKnownPath(
|
||||||
b: *std.Build,
|
b: *std.Build,
|
||||||
ctx: CMakeConfig,
|
ctx: CMakeConfig,
|
||||||
exe: *std.Build.LibExeObjStep,
|
exe: *std.Build.CompileStep,
|
||||||
objname: []const u8,
|
objname: []const u8,
|
||||||
errtxt: ?[]const u8,
|
errtxt: ?[]const u8,
|
||||||
need_cpp_includes: bool,
|
need_cpp_includes: bool,
|
||||||
@ -695,7 +695,7 @@ fn addCxxKnownPath(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn addCMakeLibraryList(exe: *std.Build.LibExeObjStep, list: []const u8) void {
|
fn addCMakeLibraryList(exe: *std.Build.CompileStep, list: []const u8) void {
|
||||||
var it = mem.tokenize(u8, list, ";");
|
var it = mem.tokenize(u8, list, ";");
|
||||||
while (it.next()) |lib| {
|
while (it.next()) |lib| {
|
||||||
if (mem.startsWith(u8, lib, "-l")) {
|
if (mem.startsWith(u8, lib, "-l")) {
|
||||||
@ -709,7 +709,7 @@ fn addCMakeLibraryList(exe: *std.Build.LibExeObjStep, list: []const u8) void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CMakeConfig = struct {
|
const CMakeConfig = struct {
|
||||||
llvm_linkage: std.Build.LibExeObjStep.Linkage,
|
llvm_linkage: std.Build.CompileStep.Linkage,
|
||||||
cmake_binary_dir: []const u8,
|
cmake_binary_dir: []const u8,
|
||||||
cmake_prefix_path: []const u8,
|
cmake_prefix_path: []const u8,
|
||||||
cmake_static_library_prefix: []const u8,
|
cmake_static_library_prefix: []const u8,
|
||||||
|
|||||||
@ -19,6 +19,9 @@ const NativeTargetInfo = std.zig.system.NativeTargetInfo;
|
|||||||
const Sha256 = std.crypto.hash.sha2.Sha256;
|
const Sha256 = std.crypto.hash.sha2.Sha256;
|
||||||
const Build = @This();
|
const Build = @This();
|
||||||
|
|
||||||
|
///// deprecated: use `CompileStep` instead.
|
||||||
|
//pub const LibExeObjStep = CompileStep;
|
||||||
|
|
||||||
pub const Step = @import("Build/Step.zig");
|
pub const Step = @import("Build/Step.zig");
|
||||||
pub const CheckFileStep = @import("Build/CheckFileStep.zig");
|
pub const CheckFileStep = @import("Build/CheckFileStep.zig");
|
||||||
pub const CheckObjectStep = @import("Build/CheckObjectStep.zig");
|
pub const CheckObjectStep = @import("Build/CheckObjectStep.zig");
|
||||||
@ -29,7 +32,7 @@ pub const InstallArtifactStep = @import("Build/InstallArtifactStep.zig");
|
|||||||
pub const InstallDirStep = @import("Build/InstallDirStep.zig");
|
pub const InstallDirStep = @import("Build/InstallDirStep.zig");
|
||||||
pub const InstallFileStep = @import("Build/InstallFileStep.zig");
|
pub const InstallFileStep = @import("Build/InstallFileStep.zig");
|
||||||
pub const InstallRawStep = @import("Build/InstallRawStep.zig");
|
pub const InstallRawStep = @import("Build/InstallRawStep.zig");
|
||||||
pub const LibExeObjStep = @import("Build/LibExeObjStep.zig");
|
pub const CompileStep = @import("Build/CompileStep.zig");
|
||||||
pub const LogStep = @import("Build/LogStep.zig");
|
pub const LogStep = @import("Build/LogStep.zig");
|
||||||
pub const OptionsStep = @import("Build/OptionsStep.zig");
|
pub const OptionsStep = @import("Build/OptionsStep.zig");
|
||||||
pub const RemoveDirStep = @import("Build/RemoveDirStep.zig");
|
pub const RemoveDirStep = @import("Build/RemoveDirStep.zig");
|
||||||
@ -423,11 +426,11 @@ pub const ExecutableOptions = struct {
|
|||||||
version: ?std.builtin.Version = null,
|
version: ?std.builtin.Version = null,
|
||||||
target: CrossTarget = .{},
|
target: CrossTarget = .{},
|
||||||
optimize: std.builtin.Mode = .Debug,
|
optimize: std.builtin.Mode = .Debug,
|
||||||
linkage: ?LibExeObjStep.Linkage = null,
|
linkage: ?CompileStep.Linkage = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn addExecutable(b: *Build, options: ExecutableOptions) *LibExeObjStep {
|
pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep {
|
||||||
return LibExeObjStep.create(b, .{
|
return CompileStep.create(b, .{
|
||||||
.name = options.name,
|
.name = options.name,
|
||||||
.root_source_file = options.root_source_file,
|
.root_source_file = options.root_source_file,
|
||||||
.version = options.version,
|
.version = options.version,
|
||||||
@ -445,8 +448,8 @@ pub const ObjectOptions = struct {
|
|||||||
optimize: std.builtin.Mode,
|
optimize: std.builtin.Mode,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn addObject(b: *Build, options: ObjectOptions) *LibExeObjStep {
|
pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep {
|
||||||
return LibExeObjStep.create(b, .{
|
return CompileStep.create(b, .{
|
||||||
.name = options.name,
|
.name = options.name,
|
||||||
.root_source_file = options.root_source_file,
|
.root_source_file = options.root_source_file,
|
||||||
.target = options.target,
|
.target = options.target,
|
||||||
@ -463,8 +466,8 @@ pub const SharedLibraryOptions = struct {
|
|||||||
optimize: std.builtin.Mode,
|
optimize: std.builtin.Mode,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *LibExeObjStep {
|
pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep {
|
||||||
return LibExeObjStep.create(b, .{
|
return CompileStep.create(b, .{
|
||||||
.name = options.name,
|
.name = options.name,
|
||||||
.root_source_file = options.root_source_file,
|
.root_source_file = options.root_source_file,
|
||||||
.kind = .lib,
|
.kind = .lib,
|
||||||
@ -483,8 +486,8 @@ pub const StaticLibraryOptions = struct {
|
|||||||
version: ?std.builtin.Version = null,
|
version: ?std.builtin.Version = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *LibExeObjStep {
|
pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep {
|
||||||
return LibExeObjStep.create(b, .{
|
return CompileStep.create(b, .{
|
||||||
.name = options.name,
|
.name = options.name,
|
||||||
.root_source_file = options.root_source_file,
|
.root_source_file = options.root_source_file,
|
||||||
.kind = .lib,
|
.kind = .lib,
|
||||||
@ -497,15 +500,15 @@ pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *LibExeObjStep
|
|||||||
|
|
||||||
pub const TestOptions = struct {
|
pub const TestOptions = struct {
|
||||||
name: []const u8 = "test",
|
name: []const u8 = "test",
|
||||||
kind: LibExeObjStep.Kind = .@"test",
|
kind: CompileStep.Kind = .@"test",
|
||||||
root_source_file: FileSource,
|
root_source_file: FileSource,
|
||||||
target: CrossTarget = .{},
|
target: CrossTarget = .{},
|
||||||
optimize: std.builtin.Mode = .Debug,
|
optimize: std.builtin.Mode = .Debug,
|
||||||
version: ?std.builtin.Version = null,
|
version: ?std.builtin.Version = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn addTest(b: *Build, options: TestOptions) *LibExeObjStep {
|
pub fn addTest(b: *Build, options: TestOptions) *CompileStep {
|
||||||
return LibExeObjStep.create(b, .{
|
return CompileStep.create(b, .{
|
||||||
.name = options.name,
|
.name = options.name,
|
||||||
.kind = options.kind,
|
.kind = options.kind,
|
||||||
.root_source_file = options.root_source_file,
|
.root_source_file = options.root_source_file,
|
||||||
@ -521,8 +524,8 @@ pub const AssemblyOptions = struct {
|
|||||||
optimize: std.builtin.Mode,
|
optimize: std.builtin.Mode,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn addAssembly(b: *Build, options: AssemblyOptions) *LibExeObjStep {
|
pub fn addAssembly(b: *Build, options: AssemblyOptions) *CompileStep {
|
||||||
const obj_step = LibExeObjStep.create(b, .{
|
const obj_step = CompileStep.create(b, .{
|
||||||
.name = options.name,
|
.name = options.name,
|
||||||
.root_source_file = null,
|
.root_source_file = null,
|
||||||
.target = options.target,
|
.target = options.target,
|
||||||
@ -536,7 +539,7 @@ pub fn addAssembly(b: *Build, options: AssemblyOptions) *LibExeObjStep {
|
|||||||
/// executable. More command line arguments can be added with `addArg`,
|
/// executable. More command line arguments can be added with `addArg`,
|
||||||
/// `addArgs`, and `addArtifactArg`.
|
/// `addArgs`, and `addArtifactArg`.
|
||||||
/// Be careful using this function, as it introduces a system dependency.
|
/// Be careful using this function, as it introduces a system dependency.
|
||||||
/// To run an executable built with zig build, see `LibExeObjStep.run`.
|
/// To run an executable built with zig build, see `CompileStep.run`.
|
||||||
pub fn addSystemCommand(self: *Build, argv: []const []const u8) *RunStep {
|
pub fn addSystemCommand(self: *Build, argv: []const []const u8) *RunStep {
|
||||||
assert(argv.len >= 1);
|
assert(argv.len >= 1);
|
||||||
const run_step = RunStep.create(self, self.fmt("run {s}", .{argv[0]}));
|
const run_step = RunStep.create(self, self.fmt("run {s}", .{argv[0]}));
|
||||||
@ -1167,11 +1170,11 @@ pub fn makePath(self: *Build, path: []const u8) !void {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn installArtifact(self: *Build, artifact: *LibExeObjStep) void {
|
pub fn installArtifact(self: *Build, artifact: *CompileStep) void {
|
||||||
self.getInstallStep().dependOn(&self.addInstallArtifact(artifact).step);
|
self.getInstallStep().dependOn(&self.addInstallArtifact(artifact).step);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addInstallArtifact(self: *Build, artifact: *LibExeObjStep) *InstallArtifactStep {
|
pub fn addInstallArtifact(self: *Build, artifact: *CompileStep) *InstallArtifactStep {
|
||||||
return InstallArtifactStep.create(self, artifact);
|
return InstallArtifactStep.create(self, artifact);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1195,7 +1198,7 @@ pub fn installLibFile(self: *Build, src_path: []const u8, dest_rel_path: []const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Output format (BIN vs Intel HEX) determined by filename
|
/// Output format (BIN vs Intel HEX) determined by filename
|
||||||
pub fn installRaw(self: *Build, artifact: *LibExeObjStep, dest_filename: []const u8, options: InstallRawStep.CreateOptions) *InstallRawStep {
|
pub fn installRaw(self: *Build, artifact: *CompileStep, dest_filename: []const u8, options: InstallRawStep.CreateOptions) *InstallRawStep {
|
||||||
const raw = self.addInstallRaw(artifact, dest_filename, options);
|
const raw = self.addInstallRaw(artifact, dest_filename, options);
|
||||||
self.getInstallStep().dependOn(&raw.step);
|
self.getInstallStep().dependOn(&raw.step);
|
||||||
return raw;
|
return raw;
|
||||||
@ -1220,7 +1223,7 @@ pub fn addInstallHeaderFile(b: *Build, src_path: []const u8, dest_rel_path: []co
|
|||||||
return b.addInstallFileWithDir(.{ .path = src_path }, .header, dest_rel_path);
|
return b.addInstallFileWithDir(.{ .path = src_path }, .header, dest_rel_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addInstallRaw(self: *Build, artifact: *LibExeObjStep, dest_filename: []const u8, options: InstallRawStep.CreateOptions) *InstallRawStep {
|
pub fn addInstallRaw(self: *Build, artifact: *CompileStep, dest_filename: []const u8, options: InstallRawStep.CreateOptions) *InstallRawStep {
|
||||||
return InstallRawStep.create(self, artifact, dest_filename, options);
|
return InstallRawStep.create(self, artifact, dest_filename, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1456,8 +1459,8 @@ pub fn getInstallPath(self: *Build, dir: InstallDir, dest_rel_path: []const u8)
|
|||||||
pub const Dependency = struct {
|
pub const Dependency = struct {
|
||||||
builder: *Build,
|
builder: *Build,
|
||||||
|
|
||||||
pub fn artifact(d: *Dependency, name: []const u8) *LibExeObjStep {
|
pub fn artifact(d: *Dependency, name: []const u8) *CompileStep {
|
||||||
var found: ?*LibExeObjStep = null;
|
var found: ?*CompileStep = null;
|
||||||
for (d.builder.install_tls.step.dependencies.items) |dep_step| {
|
for (d.builder.install_tls.step.dependencies.items) |dep_step| {
|
||||||
const inst = dep_step.cast(InstallArtifactStep) orelse continue;
|
const inst = dep_step.cast(InstallArtifactStep) orelse continue;
|
||||||
if (mem.eql(u8, inst.artifact.name, name)) {
|
if (mem.eql(u8, inst.artifact.name, name)) {
|
||||||
@ -1767,7 +1770,7 @@ test {
|
|||||||
_ = InstallDirStep;
|
_ = InstallDirStep;
|
||||||
_ = InstallFileStep;
|
_ = InstallFileStep;
|
||||||
_ = InstallRawStep;
|
_ = InstallRawStep;
|
||||||
_ = LibExeObjStep;
|
_ = CompileStep;
|
||||||
_ = LogStep;
|
_ = LogStep;
|
||||||
_ = OptionsStep;
|
_ = OptionsStep;
|
||||||
_ = RemoveDirStep;
|
_ = RemoveDirStep;
|
||||||
|
|||||||
@ -42,7 +42,7 @@ pub fn runAndCompare(self: *CheckObjectStep) *EmulatableRunStep {
|
|||||||
const dependencies_len = self.step.dependencies.items.len;
|
const dependencies_len = self.step.dependencies.items.len;
|
||||||
assert(dependencies_len > 0);
|
assert(dependencies_len > 0);
|
||||||
const exe_step = self.step.dependencies.items[dependencies_len - 1];
|
const exe_step = self.step.dependencies.items[dependencies_len - 1];
|
||||||
const exe = exe_step.cast(std.Build.LibExeObjStep).?;
|
const exe = exe_step.cast(std.Build.CompileStep).?;
|
||||||
const emulatable_step = EmulatableRunStep.create(self.builder, "EmulatableRun", exe);
|
const emulatable_step = EmulatableRunStep.create(self.builder, "EmulatableRun", exe);
|
||||||
emulatable_step.step.dependOn(&self.step);
|
emulatable_step.step.dependOn(&self.step);
|
||||||
return emulatable_step;
|
return emulatable_step;
|
||||||
|
|||||||
@ -27,9 +27,9 @@ const CheckObjectStep = std.Build.CheckObjectStep;
|
|||||||
const RunStep = std.Build.RunStep;
|
const RunStep = std.Build.RunStep;
|
||||||
const OptionsStep = std.Build.OptionsStep;
|
const OptionsStep = std.Build.OptionsStep;
|
||||||
const ConfigHeaderStep = std.Build.ConfigHeaderStep;
|
const ConfigHeaderStep = std.Build.ConfigHeaderStep;
|
||||||
const LibExeObjStep = @This();
|
const CompileStep = @This();
|
||||||
|
|
||||||
pub const base_id = .lib_exe_obj;
|
pub const base_id: Step.Id = .compile;
|
||||||
|
|
||||||
step: Step,
|
step: Step,
|
||||||
builder: *std.Build,
|
builder: *std.Build,
|
||||||
@ -234,7 +234,7 @@ pub const CSourceFile = struct {
|
|||||||
|
|
||||||
pub const LinkObject = union(enum) {
|
pub const LinkObject = union(enum) {
|
||||||
static_path: FileSource,
|
static_path: FileSource,
|
||||||
other_step: *LibExeObjStep,
|
other_step: *CompileStep,
|
||||||
system_lib: SystemLib,
|
system_lib: SystemLib,
|
||||||
assembly_file: FileSource,
|
assembly_file: FileSource,
|
||||||
c_source_file: *CSourceFile,
|
c_source_file: *CSourceFile,
|
||||||
@ -265,7 +265,7 @@ const FrameworkLinkInfo = struct {
|
|||||||
pub const IncludeDir = union(enum) {
|
pub const IncludeDir = union(enum) {
|
||||||
raw_path: []const u8,
|
raw_path: []const u8,
|
||||||
raw_path_system: []const u8,
|
raw_path_system: []const u8,
|
||||||
other_step: *LibExeObjStep,
|
other_step: *CompileStep,
|
||||||
config_header_step: *ConfigHeaderStep,
|
config_header_step: *ConfigHeaderStep,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -305,15 +305,15 @@ pub const EmitOption = union(enum) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn create(builder: *std.Build, options: Options) *LibExeObjStep {
|
pub fn create(builder: *std.Build, options: Options) *CompileStep {
|
||||||
const name = builder.dupe(options.name);
|
const name = builder.dupe(options.name);
|
||||||
const root_src: ?FileSource = if (options.root_source_file) |rsrc| rsrc.dupe(builder) else null;
|
const root_src: ?FileSource = if (options.root_source_file) |rsrc| rsrc.dupe(builder) else null;
|
||||||
if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) {
|
if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) {
|
||||||
panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name});
|
panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name});
|
||||||
}
|
}
|
||||||
|
|
||||||
const self = builder.allocator.create(LibExeObjStep) catch unreachable;
|
const self = builder.allocator.create(CompileStep) catch unreachable;
|
||||||
self.* = LibExeObjStep{
|
self.* = CompileStep{
|
||||||
.strip = null,
|
.strip = null,
|
||||||
.unwind_tables = null,
|
.unwind_tables = null,
|
||||||
.builder = builder,
|
.builder = builder,
|
||||||
@ -371,7 +371,7 @@ pub fn create(builder: *std.Build, options: Options) *LibExeObjStep {
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn computeOutFileNames(self: *LibExeObjStep) void {
|
fn computeOutFileNames(self: *CompileStep) void {
|
||||||
const target = self.target_info.target;
|
const target = self.target_info.target;
|
||||||
|
|
||||||
self.out_filename = std.zig.binNameAlloc(self.builder.allocator, .{
|
self.out_filename = std.zig.binNameAlloc(self.builder.allocator, .{
|
||||||
@ -424,26 +424,26 @@ fn computeOutFileNames(self: *LibExeObjStep) void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setOutputDir(self: *LibExeObjStep, dir: []const u8) void {
|
pub fn setOutputDir(self: *CompileStep, dir: []const u8) void {
|
||||||
self.output_dir = self.builder.dupePath(dir);
|
self.output_dir = self.builder.dupePath(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn install(self: *LibExeObjStep) void {
|
pub fn install(self: *CompileStep) void {
|
||||||
self.builder.installArtifact(self);
|
self.builder.installArtifact(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn installRaw(self: *LibExeObjStep, dest_filename: []const u8, options: InstallRawStep.CreateOptions) *InstallRawStep {
|
pub fn installRaw(self: *CompileStep, dest_filename: []const u8, options: InstallRawStep.CreateOptions) *InstallRawStep {
|
||||||
return self.builder.installRaw(self, dest_filename, options);
|
return self.builder.installRaw(self, dest_filename, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn installHeader(a: *LibExeObjStep, src_path: []const u8, dest_rel_path: []const u8) void {
|
pub fn installHeader(a: *CompileStep, src_path: []const u8, dest_rel_path: []const u8) void {
|
||||||
const install_file = a.builder.addInstallHeaderFile(src_path, dest_rel_path);
|
const install_file = a.builder.addInstallHeaderFile(src_path, dest_rel_path);
|
||||||
a.builder.getInstallStep().dependOn(&install_file.step);
|
a.builder.getInstallStep().dependOn(&install_file.step);
|
||||||
a.installed_headers.append(&install_file.step) catch unreachable;
|
a.installed_headers.append(&install_file.step) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn installHeadersDirectory(
|
pub fn installHeadersDirectory(
|
||||||
a: *LibExeObjStep,
|
a: *CompileStep,
|
||||||
src_dir_path: []const u8,
|
src_dir_path: []const u8,
|
||||||
dest_rel_path: []const u8,
|
dest_rel_path: []const u8,
|
||||||
) void {
|
) void {
|
||||||
@ -455,7 +455,7 @@ pub fn installHeadersDirectory(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn installHeadersDirectoryOptions(
|
pub fn installHeadersDirectoryOptions(
|
||||||
a: *LibExeObjStep,
|
a: *CompileStep,
|
||||||
options: std.Build.InstallDirStep.Options,
|
options: std.Build.InstallDirStep.Options,
|
||||||
) void {
|
) void {
|
||||||
const install_dir = a.builder.addInstallDirectory(options);
|
const install_dir = a.builder.addInstallDirectory(options);
|
||||||
@ -463,7 +463,7 @@ pub fn installHeadersDirectoryOptions(
|
|||||||
a.installed_headers.append(&install_dir.step) catch unreachable;
|
a.installed_headers.append(&install_dir.step) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn installLibraryHeaders(a: *LibExeObjStep, l: *LibExeObjStep) void {
|
pub fn installLibraryHeaders(a: *CompileStep, l: *CompileStep) void {
|
||||||
assert(l.kind == .lib);
|
assert(l.kind == .lib);
|
||||||
const install_step = a.builder.getInstallStep();
|
const install_step = a.builder.getInstallStep();
|
||||||
// Copy each element from installed_headers, modifying the builder
|
// Copy each element from installed_headers, modifying the builder
|
||||||
@ -488,7 +488,7 @@ pub fn installLibraryHeaders(a: *LibExeObjStep, l: *LibExeObjStep) void {
|
|||||||
|
|
||||||
/// Creates a `RunStep` with an executable built with `addExecutable`.
|
/// Creates a `RunStep` with an executable built with `addExecutable`.
|
||||||
/// Add command line arguments with `addArg`.
|
/// Add command line arguments with `addArg`.
|
||||||
pub fn run(exe: *LibExeObjStep) *RunStep {
|
pub fn run(exe: *CompileStep) *RunStep {
|
||||||
assert(exe.kind == .exe or exe.kind == .test_exe);
|
assert(exe.kind == .exe or exe.kind == .test_exe);
|
||||||
|
|
||||||
// It doesn't have to be native. We catch that if you actually try to run it.
|
// It doesn't have to be native. We catch that if you actually try to run it.
|
||||||
@ -512,7 +512,7 @@ pub fn run(exe: *LibExeObjStep) *RunStep {
|
|||||||
/// Allows running foreign binaries through emulation platforms such as Qemu or Rosetta.
|
/// Allows running foreign binaries through emulation platforms such as Qemu or Rosetta.
|
||||||
/// When a binary cannot be ran through emulation or the option is disabled, a warning
|
/// When a binary cannot be ran through emulation or the option is disabled, a warning
|
||||||
/// will be printed and the binary will *NOT* be ran.
|
/// will be printed and the binary will *NOT* be ran.
|
||||||
pub fn runEmulatable(exe: *LibExeObjStep) *EmulatableRunStep {
|
pub fn runEmulatable(exe: *CompileStep) *EmulatableRunStep {
|
||||||
assert(exe.kind == .exe or exe.kind == .test_exe);
|
assert(exe.kind == .exe or exe.kind == .test_exe);
|
||||||
|
|
||||||
const run_step = EmulatableRunStep.create(exe.builder, exe.builder.fmt("run {s}", .{exe.step.name}), exe);
|
const run_step = EmulatableRunStep.create(exe.builder, exe.builder.fmt("run {s}", .{exe.step.name}), exe);
|
||||||
@ -522,33 +522,33 @@ pub fn runEmulatable(exe: *LibExeObjStep) *EmulatableRunStep {
|
|||||||
return run_step;
|
return run_step;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn checkObject(self: *LibExeObjStep, obj_format: std.Target.ObjectFormat) *CheckObjectStep {
|
pub fn checkObject(self: *CompileStep, obj_format: std.Target.ObjectFormat) *CheckObjectStep {
|
||||||
return CheckObjectStep.create(self.builder, self.getOutputSource(), obj_format);
|
return CheckObjectStep.create(self.builder, self.getOutputSource(), obj_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setLinkerScriptPath(self: *LibExeObjStep, source: FileSource) void {
|
pub fn setLinkerScriptPath(self: *CompileStep, source: FileSource) void {
|
||||||
self.linker_script = source.dupe(self.builder);
|
self.linker_script = source.dupe(self.builder);
|
||||||
source.addStepDependencies(&self.step);
|
source.addStepDependencies(&self.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn linkFramework(self: *LibExeObjStep, framework_name: []const u8) void {
|
pub fn linkFramework(self: *CompileStep, framework_name: []const u8) void {
|
||||||
self.frameworks.put(self.builder.dupe(framework_name), .{}) catch unreachable;
|
self.frameworks.put(self.builder.dupe(framework_name), .{}) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn linkFrameworkNeeded(self: *LibExeObjStep, framework_name: []const u8) void {
|
pub fn linkFrameworkNeeded(self: *CompileStep, framework_name: []const u8) void {
|
||||||
self.frameworks.put(self.builder.dupe(framework_name), .{
|
self.frameworks.put(self.builder.dupe(framework_name), .{
|
||||||
.needed = true,
|
.needed = true,
|
||||||
}) catch unreachable;
|
}) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn linkFrameworkWeak(self: *LibExeObjStep, framework_name: []const u8) void {
|
pub fn linkFrameworkWeak(self: *CompileStep, framework_name: []const u8) void {
|
||||||
self.frameworks.put(self.builder.dupe(framework_name), .{
|
self.frameworks.put(self.builder.dupe(framework_name), .{
|
||||||
.weak = true,
|
.weak = true,
|
||||||
}) catch unreachable;
|
}) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether the library, executable, or object depends on a particular system library.
|
/// Returns whether the library, executable, or object depends on a particular system library.
|
||||||
pub fn dependsOnSystemLibrary(self: LibExeObjStep, name: []const u8) bool {
|
pub fn dependsOnSystemLibrary(self: CompileStep, name: []const u8) bool {
|
||||||
if (isLibCLibrary(name)) {
|
if (isLibCLibrary(name)) {
|
||||||
return self.is_linking_libc;
|
return self.is_linking_libc;
|
||||||
}
|
}
|
||||||
@ -564,49 +564,49 @@ pub fn dependsOnSystemLibrary(self: LibExeObjStep, name: []const u8) bool {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn linkLibrary(self: *LibExeObjStep, lib: *LibExeObjStep) void {
|
pub fn linkLibrary(self: *CompileStep, lib: *CompileStep) void {
|
||||||
assert(lib.kind == .lib);
|
assert(lib.kind == .lib);
|
||||||
self.linkLibraryOrObject(lib);
|
self.linkLibraryOrObject(lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn isDynamicLibrary(self: *LibExeObjStep) bool {
|
pub fn isDynamicLibrary(self: *CompileStep) bool {
|
||||||
return self.kind == .lib and self.linkage == Linkage.dynamic;
|
return self.kind == .lib and self.linkage == Linkage.dynamic;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn isStaticLibrary(self: *LibExeObjStep) bool {
|
pub fn isStaticLibrary(self: *CompileStep) bool {
|
||||||
return self.kind == .lib and self.linkage != Linkage.dynamic;
|
return self.kind == .lib and self.linkage != Linkage.dynamic;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn producesPdbFile(self: *LibExeObjStep) bool {
|
pub fn producesPdbFile(self: *CompileStep) bool {
|
||||||
if (!self.target.isWindows() and !self.target.isUefi()) return false;
|
if (!self.target.isWindows() and !self.target.isUefi()) return false;
|
||||||
if (self.target.getObjectFormat() == .c) return false;
|
if (self.target.getObjectFormat() == .c) return false;
|
||||||
if (self.strip == true) return false;
|
if (self.strip == true) return false;
|
||||||
return self.isDynamicLibrary() or self.kind == .exe or self.kind == .test_exe;
|
return self.isDynamicLibrary() or self.kind == .exe or self.kind == .test_exe;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn linkLibC(self: *LibExeObjStep) void {
|
pub fn linkLibC(self: *CompileStep) void {
|
||||||
self.is_linking_libc = true;
|
self.is_linking_libc = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn linkLibCpp(self: *LibExeObjStep) void {
|
pub fn linkLibCpp(self: *CompileStep) void {
|
||||||
self.is_linking_libcpp = true;
|
self.is_linking_libcpp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the value is omitted, it is set to 1.
|
/// If the value is omitted, it is set to 1.
|
||||||
/// `name` and `value` need not live longer than the function call.
|
/// `name` and `value` need not live longer than the function call.
|
||||||
pub fn defineCMacro(self: *LibExeObjStep, name: []const u8, value: ?[]const u8) void {
|
pub fn defineCMacro(self: *CompileStep, name: []const u8, value: ?[]const u8) void {
|
||||||
const macro = std.Build.constructCMacro(self.builder.allocator, name, value);
|
const macro = std.Build.constructCMacro(self.builder.allocator, name, value);
|
||||||
self.c_macros.append(macro) catch unreachable;
|
self.c_macros.append(macro) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// name_and_value looks like [name]=[value]. If the value is omitted, it is set to 1.
|
/// name_and_value looks like [name]=[value]. If the value is omitted, it is set to 1.
|
||||||
pub fn defineCMacroRaw(self: *LibExeObjStep, name_and_value: []const u8) void {
|
pub fn defineCMacroRaw(self: *CompileStep, name_and_value: []const u8) void {
|
||||||
self.c_macros.append(self.builder.dupe(name_and_value)) catch unreachable;
|
self.c_macros.append(self.builder.dupe(name_and_value)) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This one has no integration with anything, it just puts -lname on the command line.
|
/// This one has no integration with anything, it just puts -lname on the command line.
|
||||||
/// Prefer to use `linkSystemLibrary` instead.
|
/// Prefer to use `linkSystemLibrary` instead.
|
||||||
pub fn linkSystemLibraryName(self: *LibExeObjStep, name: []const u8) void {
|
pub fn linkSystemLibraryName(self: *CompileStep, name: []const u8) void {
|
||||||
self.link_objects.append(.{
|
self.link_objects.append(.{
|
||||||
.system_lib = .{
|
.system_lib = .{
|
||||||
.name = self.builder.dupe(name),
|
.name = self.builder.dupe(name),
|
||||||
@ -619,7 +619,7 @@ pub fn linkSystemLibraryName(self: *LibExeObjStep, name: []const u8) void {
|
|||||||
|
|
||||||
/// This one has no integration with anything, it just puts -needed-lname on the command line.
|
/// This one has no integration with anything, it just puts -needed-lname on the command line.
|
||||||
/// Prefer to use `linkSystemLibraryNeeded` instead.
|
/// Prefer to use `linkSystemLibraryNeeded` instead.
|
||||||
pub fn linkSystemLibraryNeededName(self: *LibExeObjStep, name: []const u8) void {
|
pub fn linkSystemLibraryNeededName(self: *CompileStep, name: []const u8) void {
|
||||||
self.link_objects.append(.{
|
self.link_objects.append(.{
|
||||||
.system_lib = .{
|
.system_lib = .{
|
||||||
.name = self.builder.dupe(name),
|
.name = self.builder.dupe(name),
|
||||||
@ -632,7 +632,7 @@ pub fn linkSystemLibraryNeededName(self: *LibExeObjStep, name: []const u8) void
|
|||||||
|
|
||||||
/// Darwin-only. This one has no integration with anything, it just puts -weak-lname on the
|
/// Darwin-only. This one has no integration with anything, it just puts -weak-lname on the
|
||||||
/// command line. Prefer to use `linkSystemLibraryWeak` instead.
|
/// command line. Prefer to use `linkSystemLibraryWeak` instead.
|
||||||
pub fn linkSystemLibraryWeakName(self: *LibExeObjStep, name: []const u8) void {
|
pub fn linkSystemLibraryWeakName(self: *CompileStep, name: []const u8) void {
|
||||||
self.link_objects.append(.{
|
self.link_objects.append(.{
|
||||||
.system_lib = .{
|
.system_lib = .{
|
||||||
.name = self.builder.dupe(name),
|
.name = self.builder.dupe(name),
|
||||||
@ -645,7 +645,7 @@ pub fn linkSystemLibraryWeakName(self: *LibExeObjStep, name: []const u8) void {
|
|||||||
|
|
||||||
/// This links against a system library, exclusively using pkg-config to find the library.
|
/// This links against a system library, exclusively using pkg-config to find the library.
|
||||||
/// Prefer to use `linkSystemLibrary` instead.
|
/// Prefer to use `linkSystemLibrary` instead.
|
||||||
pub fn linkSystemLibraryPkgConfigOnly(self: *LibExeObjStep, lib_name: []const u8) void {
|
pub fn linkSystemLibraryPkgConfigOnly(self: *CompileStep, lib_name: []const u8) void {
|
||||||
self.link_objects.append(.{
|
self.link_objects.append(.{
|
||||||
.system_lib = .{
|
.system_lib = .{
|
||||||
.name = self.builder.dupe(lib_name),
|
.name = self.builder.dupe(lib_name),
|
||||||
@ -658,7 +658,7 @@ pub fn linkSystemLibraryPkgConfigOnly(self: *LibExeObjStep, lib_name: []const u8
|
|||||||
|
|
||||||
/// This links against a system library, exclusively using pkg-config to find the library.
|
/// This links against a system library, exclusively using pkg-config to find the library.
|
||||||
/// Prefer to use `linkSystemLibraryNeeded` instead.
|
/// Prefer to use `linkSystemLibraryNeeded` instead.
|
||||||
pub fn linkSystemLibraryNeededPkgConfigOnly(self: *LibExeObjStep, lib_name: []const u8) void {
|
pub fn linkSystemLibraryNeededPkgConfigOnly(self: *CompileStep, lib_name: []const u8) void {
|
||||||
self.link_objects.append(.{
|
self.link_objects.append(.{
|
||||||
.system_lib = .{
|
.system_lib = .{
|
||||||
.name = self.builder.dupe(lib_name),
|
.name = self.builder.dupe(lib_name),
|
||||||
@ -671,7 +671,7 @@ pub fn linkSystemLibraryNeededPkgConfigOnly(self: *LibExeObjStep, lib_name: []co
|
|||||||
|
|
||||||
/// Run pkg-config for the given library name and parse the output, returning the arguments
|
/// Run pkg-config for the given library name and parse the output, returning the arguments
|
||||||
/// that should be passed to zig to link the given library.
|
/// that should be passed to zig to link the given library.
|
||||||
pub fn runPkgConfig(self: *LibExeObjStep, lib_name: []const u8) ![]const []const u8 {
|
pub fn runPkgConfig(self: *CompileStep, lib_name: []const u8) ![]const []const u8 {
|
||||||
const pkg_name = match: {
|
const pkg_name = match: {
|
||||||
// First we have to map the library name to pkg config name. Unfortunately,
|
// First we have to map the library name to pkg config name. Unfortunately,
|
||||||
// there are several examples where this is not straightforward:
|
// there are several examples where this is not straightforward:
|
||||||
@ -765,19 +765,19 @@ pub fn runPkgConfig(self: *LibExeObjStep, lib_name: []const u8) ![]const []const
|
|||||||
return zig_args.toOwnedSlice();
|
return zig_args.toOwnedSlice();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn linkSystemLibrary(self: *LibExeObjStep, name: []const u8) void {
|
pub fn linkSystemLibrary(self: *CompileStep, name: []const u8) void {
|
||||||
self.linkSystemLibraryInner(name, .{});
|
self.linkSystemLibraryInner(name, .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn linkSystemLibraryNeeded(self: *LibExeObjStep, name: []const u8) void {
|
pub fn linkSystemLibraryNeeded(self: *CompileStep, name: []const u8) void {
|
||||||
self.linkSystemLibraryInner(name, .{ .needed = true });
|
self.linkSystemLibraryInner(name, .{ .needed = true });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn linkSystemLibraryWeak(self: *LibExeObjStep, name: []const u8) void {
|
pub fn linkSystemLibraryWeak(self: *CompileStep, name: []const u8) void {
|
||||||
self.linkSystemLibraryInner(name, .{ .weak = true });
|
self.linkSystemLibraryInner(name, .{ .weak = true });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn linkSystemLibraryInner(self: *LibExeObjStep, name: []const u8, opts: struct {
|
fn linkSystemLibraryInner(self: *CompileStep, name: []const u8, opts: struct {
|
||||||
needed: bool = false,
|
needed: bool = false,
|
||||||
weak: bool = false,
|
weak: bool = false,
|
||||||
}) void {
|
}) void {
|
||||||
@ -800,23 +800,23 @@ fn linkSystemLibraryInner(self: *LibExeObjStep, name: []const u8, opts: struct {
|
|||||||
}) catch unreachable;
|
}) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setNamePrefix(self: *LibExeObjStep, text: []const u8) void {
|
pub fn setNamePrefix(self: *CompileStep, text: []const u8) void {
|
||||||
assert(self.kind == .@"test" or self.kind == .test_exe);
|
assert(self.kind == .@"test" or self.kind == .test_exe);
|
||||||
self.name_prefix = self.builder.dupe(text);
|
self.name_prefix = self.builder.dupe(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setFilter(self: *LibExeObjStep, text: ?[]const u8) void {
|
pub fn setFilter(self: *CompileStep, text: ?[]const u8) void {
|
||||||
assert(self.kind == .@"test" or self.kind == .test_exe);
|
assert(self.kind == .@"test" or self.kind == .test_exe);
|
||||||
self.filter = if (text) |t| self.builder.dupe(t) else null;
|
self.filter = if (text) |t| self.builder.dupe(t) else null;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setTestRunner(self: *LibExeObjStep, path: ?[]const u8) void {
|
pub fn setTestRunner(self: *CompileStep, path: ?[]const u8) void {
|
||||||
assert(self.kind == .@"test" or self.kind == .test_exe);
|
assert(self.kind == .@"test" or self.kind == .test_exe);
|
||||||
self.test_runner = if (path) |p| self.builder.dupePath(p) else null;
|
self.test_runner = if (path) |p| self.builder.dupePath(p) else null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handy when you have many C/C++ source files and want them all to have the same flags.
|
/// Handy when you have many C/C++ source files and want them all to have the same flags.
|
||||||
pub fn addCSourceFiles(self: *LibExeObjStep, files: []const []const u8, flags: []const []const u8) void {
|
pub fn addCSourceFiles(self: *CompileStep, files: []const []const u8, flags: []const []const u8) void {
|
||||||
const c_source_files = self.builder.allocator.create(CSourceFiles) catch unreachable;
|
const c_source_files = self.builder.allocator.create(CSourceFiles) catch unreachable;
|
||||||
|
|
||||||
const files_copy = self.builder.dupeStrings(files);
|
const files_copy = self.builder.dupeStrings(files);
|
||||||
@ -829,89 +829,89 @@ pub fn addCSourceFiles(self: *LibExeObjStep, files: []const []const u8, flags: [
|
|||||||
self.link_objects.append(.{ .c_source_files = c_source_files }) catch unreachable;
|
self.link_objects.append(.{ .c_source_files = c_source_files }) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addCSourceFile(self: *LibExeObjStep, file: []const u8, flags: []const []const u8) void {
|
pub fn addCSourceFile(self: *CompileStep, file: []const u8, flags: []const []const u8) void {
|
||||||
self.addCSourceFileSource(.{
|
self.addCSourceFileSource(.{
|
||||||
.args = flags,
|
.args = flags,
|
||||||
.source = .{ .path = file },
|
.source = .{ .path = file },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addCSourceFileSource(self: *LibExeObjStep, source: CSourceFile) void {
|
pub fn addCSourceFileSource(self: *CompileStep, source: CSourceFile) void {
|
||||||
const c_source_file = self.builder.allocator.create(CSourceFile) catch unreachable;
|
const c_source_file = self.builder.allocator.create(CSourceFile) catch unreachable;
|
||||||
c_source_file.* = source.dupe(self.builder);
|
c_source_file.* = source.dupe(self.builder);
|
||||||
self.link_objects.append(.{ .c_source_file = c_source_file }) catch unreachable;
|
self.link_objects.append(.{ .c_source_file = c_source_file }) catch unreachable;
|
||||||
source.source.addStepDependencies(&self.step);
|
source.source.addStepDependencies(&self.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setVerboseLink(self: *LibExeObjStep, value: bool) void {
|
pub fn setVerboseLink(self: *CompileStep, value: bool) void {
|
||||||
self.verbose_link = value;
|
self.verbose_link = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setVerboseCC(self: *LibExeObjStep, value: bool) void {
|
pub fn setVerboseCC(self: *CompileStep, value: bool) void {
|
||||||
self.verbose_cc = value;
|
self.verbose_cc = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn overrideZigLibDir(self: *LibExeObjStep, dir_path: []const u8) void {
|
pub fn overrideZigLibDir(self: *CompileStep, dir_path: []const u8) void {
|
||||||
self.override_lib_dir = self.builder.dupePath(dir_path);
|
self.override_lib_dir = self.builder.dupePath(dir_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setMainPkgPath(self: *LibExeObjStep, dir_path: []const u8) void {
|
pub fn setMainPkgPath(self: *CompileStep, dir_path: []const u8) void {
|
||||||
self.main_pkg_path = self.builder.dupePath(dir_path);
|
self.main_pkg_path = self.builder.dupePath(dir_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setLibCFile(self: *LibExeObjStep, libc_file: ?FileSource) void {
|
pub fn setLibCFile(self: *CompileStep, libc_file: ?FileSource) void {
|
||||||
self.libc_file = if (libc_file) |f| f.dupe(self.builder) else null;
|
self.libc_file = if (libc_file) |f| f.dupe(self.builder) else null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the generated executable, library or object file.
|
/// Returns the generated executable, library or object file.
|
||||||
/// To run an executable built with zig build, use `run`, or create an install step and invoke it.
|
/// To run an executable built with zig build, use `run`, or create an install step and invoke it.
|
||||||
pub fn getOutputSource(self: *LibExeObjStep) FileSource {
|
pub fn getOutputSource(self: *CompileStep) FileSource {
|
||||||
return FileSource{ .generated = &self.output_path_source };
|
return FileSource{ .generated = &self.output_path_source };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the generated import library. This function can only be called for libraries.
|
/// Returns the generated import library. This function can only be called for libraries.
|
||||||
pub fn getOutputLibSource(self: *LibExeObjStep) FileSource {
|
pub fn getOutputLibSource(self: *CompileStep) FileSource {
|
||||||
assert(self.kind == .lib);
|
assert(self.kind == .lib);
|
||||||
return FileSource{ .generated = &self.output_lib_path_source };
|
return FileSource{ .generated = &self.output_lib_path_source };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the generated header file.
|
/// Returns the generated header file.
|
||||||
/// This function can only be called for libraries or object files which have `emit_h` set.
|
/// This function can only be called for libraries or object files which have `emit_h` set.
|
||||||
pub fn getOutputHSource(self: *LibExeObjStep) FileSource {
|
pub fn getOutputHSource(self: *CompileStep) FileSource {
|
||||||
assert(self.kind != .exe and self.kind != .test_exe and self.kind != .@"test");
|
assert(self.kind != .exe and self.kind != .test_exe and self.kind != .@"test");
|
||||||
assert(self.emit_h);
|
assert(self.emit_h);
|
||||||
return FileSource{ .generated = &self.output_h_path_source };
|
return FileSource{ .generated = &self.output_h_path_source };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the generated PDB file. This function can only be called for Windows and UEFI.
|
/// Returns the generated PDB file. This function can only be called for Windows and UEFI.
|
||||||
pub fn getOutputPdbSource(self: *LibExeObjStep) FileSource {
|
pub fn getOutputPdbSource(self: *CompileStep) FileSource {
|
||||||
// TODO: Is this right? Isn't PDB for *any* PE/COFF file?
|
// TODO: Is this right? Isn't PDB for *any* PE/COFF file?
|
||||||
assert(self.target.isWindows() or self.target.isUefi());
|
assert(self.target.isWindows() or self.target.isUefi());
|
||||||
return FileSource{ .generated = &self.output_pdb_path_source };
|
return FileSource{ .generated = &self.output_pdb_path_source };
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addAssemblyFile(self: *LibExeObjStep, path: []const u8) void {
|
pub fn addAssemblyFile(self: *CompileStep, path: []const u8) void {
|
||||||
self.link_objects.append(.{
|
self.link_objects.append(.{
|
||||||
.assembly_file = .{ .path = self.builder.dupe(path) },
|
.assembly_file = .{ .path = self.builder.dupe(path) },
|
||||||
}) catch unreachable;
|
}) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addAssemblyFileSource(self: *LibExeObjStep, source: FileSource) void {
|
pub fn addAssemblyFileSource(self: *CompileStep, source: FileSource) void {
|
||||||
const source_duped = source.dupe(self.builder);
|
const source_duped = source.dupe(self.builder);
|
||||||
self.link_objects.append(.{ .assembly_file = source_duped }) catch unreachable;
|
self.link_objects.append(.{ .assembly_file = source_duped }) catch unreachable;
|
||||||
source_duped.addStepDependencies(&self.step);
|
source_duped.addStepDependencies(&self.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addObjectFile(self: *LibExeObjStep, source_file: []const u8) void {
|
pub fn addObjectFile(self: *CompileStep, source_file: []const u8) void {
|
||||||
self.addObjectFileSource(.{ .path = source_file });
|
self.addObjectFileSource(.{ .path = source_file });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addObjectFileSource(self: *LibExeObjStep, source: FileSource) void {
|
pub fn addObjectFileSource(self: *CompileStep, source: FileSource) void {
|
||||||
self.link_objects.append(.{ .static_path = source.dupe(self.builder) }) catch unreachable;
|
self.link_objects.append(.{ .static_path = source.dupe(self.builder) }) catch unreachable;
|
||||||
source.addStepDependencies(&self.step);
|
source.addStepDependencies(&self.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addObject(self: *LibExeObjStep, obj: *LibExeObjStep) void {
|
pub fn addObject(self: *CompileStep, obj: *CompileStep) void {
|
||||||
assert(obj.kind == .obj);
|
assert(obj.kind == .obj);
|
||||||
self.linkLibraryOrObject(obj);
|
self.linkLibraryOrObject(obj);
|
||||||
}
|
}
|
||||||
@ -921,41 +921,41 @@ pub const addIncludeDir = @compileError("deprecated; use addIncludePath");
|
|||||||
pub const addLibPath = @compileError("deprecated, use addLibraryPath");
|
pub const addLibPath = @compileError("deprecated, use addLibraryPath");
|
||||||
pub const addFrameworkDir = @compileError("deprecated, use addFrameworkPath");
|
pub const addFrameworkDir = @compileError("deprecated, use addFrameworkPath");
|
||||||
|
|
||||||
pub fn addSystemIncludePath(self: *LibExeObjStep, path: []const u8) void {
|
pub fn addSystemIncludePath(self: *CompileStep, path: []const u8) void {
|
||||||
self.include_dirs.append(IncludeDir{ .raw_path_system = self.builder.dupe(path) }) catch unreachable;
|
self.include_dirs.append(IncludeDir{ .raw_path_system = self.builder.dupe(path) }) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addIncludePath(self: *LibExeObjStep, path: []const u8) void {
|
pub fn addIncludePath(self: *CompileStep, path: []const u8) void {
|
||||||
self.include_dirs.append(IncludeDir{ .raw_path = self.builder.dupe(path) }) catch unreachable;
|
self.include_dirs.append(IncludeDir{ .raw_path = self.builder.dupe(path) }) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addConfigHeader(self: *LibExeObjStep, config_header: *ConfigHeaderStep) void {
|
pub fn addConfigHeader(self: *CompileStep, config_header: *ConfigHeaderStep) void {
|
||||||
self.step.dependOn(&config_header.step);
|
self.step.dependOn(&config_header.step);
|
||||||
self.include_dirs.append(.{ .config_header_step = config_header }) catch @panic("OOM");
|
self.include_dirs.append(.{ .config_header_step = config_header }) catch @panic("OOM");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addLibraryPath(self: *LibExeObjStep, path: []const u8) void {
|
pub fn addLibraryPath(self: *CompileStep, path: []const u8) void {
|
||||||
self.lib_paths.append(self.builder.dupe(path)) catch unreachable;
|
self.lib_paths.append(self.builder.dupe(path)) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addRPath(self: *LibExeObjStep, path: []const u8) void {
|
pub fn addRPath(self: *CompileStep, path: []const u8) void {
|
||||||
self.rpaths.append(self.builder.dupe(path)) catch unreachable;
|
self.rpaths.append(self.builder.dupe(path)) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addFrameworkPath(self: *LibExeObjStep, dir_path: []const u8) void {
|
pub fn addFrameworkPath(self: *CompileStep, dir_path: []const u8) void {
|
||||||
self.framework_dirs.append(self.builder.dupe(dir_path)) catch unreachable;
|
self.framework_dirs.append(self.builder.dupe(dir_path)) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addPackage(self: *LibExeObjStep, package: Pkg) void {
|
pub fn addPackage(self: *CompileStep, package: Pkg) void {
|
||||||
self.packages.append(self.builder.dupePkg(package)) catch unreachable;
|
self.packages.append(self.builder.dupePkg(package)) catch unreachable;
|
||||||
self.addRecursiveBuildDeps(package);
|
self.addRecursiveBuildDeps(package);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addOptions(self: *LibExeObjStep, package_name: []const u8, options: *OptionsStep) void {
|
pub fn addOptions(self: *CompileStep, package_name: []const u8, options: *OptionsStep) void {
|
||||||
self.addPackage(options.getPackage(package_name));
|
self.addPackage(options.getPackage(package_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn addRecursiveBuildDeps(self: *LibExeObjStep, package: Pkg) void {
|
fn addRecursiveBuildDeps(self: *CompileStep, package: Pkg) void {
|
||||||
package.source.addStepDependencies(&self.step);
|
package.source.addStepDependencies(&self.step);
|
||||||
if (package.dependencies) |deps| {
|
if (package.dependencies) |deps| {
|
||||||
for (deps) |dep| {
|
for (deps) |dep| {
|
||||||
@ -964,7 +964,7 @@ fn addRecursiveBuildDeps(self: *LibExeObjStep, package: Pkg) void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addPackagePath(self: *LibExeObjStep, name: []const u8, pkg_index_path: []const u8) void {
|
pub fn addPackagePath(self: *CompileStep, name: []const u8, pkg_index_path: []const u8) void {
|
||||||
self.addPackage(Pkg{
|
self.addPackage(Pkg{
|
||||||
.name = self.builder.dupe(name),
|
.name = self.builder.dupe(name),
|
||||||
.source = .{ .path = self.builder.dupe(pkg_index_path) },
|
.source = .{ .path = self.builder.dupe(pkg_index_path) },
|
||||||
@ -973,7 +973,7 @@ pub fn addPackagePath(self: *LibExeObjStep, name: []const u8, pkg_index_path: []
|
|||||||
|
|
||||||
/// If Vcpkg was found on the system, it will be added to include and lib
|
/// If Vcpkg was found on the system, it will be added to include and lib
|
||||||
/// paths for the specified target.
|
/// paths for the specified target.
|
||||||
pub fn addVcpkgPaths(self: *LibExeObjStep, linkage: LibExeObjStep.Linkage) !void {
|
pub fn addVcpkgPaths(self: *CompileStep, linkage: CompileStep.Linkage) !void {
|
||||||
// Ideally in the Unattempted case we would call the function recursively
|
// Ideally in the Unattempted case we would call the function recursively
|
||||||
// after findVcpkgRoot and have only one switch statement, but the compiler
|
// after findVcpkgRoot and have only one switch statement, but the compiler
|
||||||
// cannot resolve the error set.
|
// cannot resolve the error set.
|
||||||
@ -1008,7 +1008,7 @@ pub fn addVcpkgPaths(self: *LibExeObjStep, linkage: LibExeObjStep.Linkage) !void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setExecCmd(self: *LibExeObjStep, args: []const ?[]const u8) void {
|
pub fn setExecCmd(self: *CompileStep, args: []const ?[]const u8) void {
|
||||||
assert(self.kind == .@"test");
|
assert(self.kind == .@"test");
|
||||||
const duped_args = self.builder.allocator.alloc(?[]u8, args.len) catch unreachable;
|
const duped_args = self.builder.allocator.alloc(?[]u8, args.len) catch unreachable;
|
||||||
for (args) |arg, i| {
|
for (args) |arg, i| {
|
||||||
@ -1017,13 +1017,13 @@ pub fn setExecCmd(self: *LibExeObjStep, args: []const ?[]const u8) void {
|
|||||||
self.exec_cmd_args = duped_args;
|
self.exec_cmd_args = duped_args;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn linkLibraryOrObject(self: *LibExeObjStep, other: *LibExeObjStep) void {
|
fn linkLibraryOrObject(self: *CompileStep, other: *CompileStep) void {
|
||||||
self.step.dependOn(&other.step);
|
self.step.dependOn(&other.step);
|
||||||
self.link_objects.append(.{ .other_step = other }) catch unreachable;
|
self.link_objects.append(.{ .other_step = other }) catch unreachable;
|
||||||
self.include_dirs.append(.{ .other_step = other }) catch unreachable;
|
self.include_dirs.append(.{ .other_step = other }) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn makePackageCmd(self: *LibExeObjStep, pkg: Pkg, zig_args: *ArrayList([]const u8)) error{OutOfMemory}!void {
|
fn makePackageCmd(self: *CompileStep, pkg: Pkg, zig_args: *ArrayList([]const u8)) error{OutOfMemory}!void {
|
||||||
const builder = self.builder;
|
const builder = self.builder;
|
||||||
|
|
||||||
try zig_args.append("--pkg-begin");
|
try zig_args.append("--pkg-begin");
|
||||||
@ -1040,7 +1040,7 @@ fn makePackageCmd(self: *LibExeObjStep, pkg: Pkg, zig_args: *ArrayList([]const u
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn make(step: *Step) !void {
|
fn make(step: *Step) !void {
|
||||||
const self = @fieldParentPtr(LibExeObjStep, "step", step);
|
const self = @fieldParentPtr(CompileStep, "step", step);
|
||||||
const builder = self.builder;
|
const builder = self.builder;
|
||||||
|
|
||||||
if (self.root_src == null and self.link_objects.items.len == 0) {
|
if (self.root_src == null and self.link_objects.items.len == 0) {
|
||||||
@ -2004,7 +2004,7 @@ const TransitiveDeps = struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn addInner(td: *TransitiveDeps, other: *LibExeObjStep, dyn: bool) !void {
|
fn addInner(td: *TransitiveDeps, other: *CompileStep, dyn: bool) !void {
|
||||||
// Inherit dependency on libc and libc++
|
// Inherit dependency on libc and libc++
|
||||||
td.is_linking_libcpp = td.is_linking_libcpp or other.is_linking_libcpp;
|
td.is_linking_libcpp = td.is_linking_libcpp or other.is_linking_libcpp;
|
||||||
td.is_linking_libc = td.is_linking_libc or other.is_linking_libc;
|
td.is_linking_libc = td.is_linking_libc or other.is_linking_libc;
|
||||||
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
const std = @import("../std.zig");
|
const std = @import("../std.zig");
|
||||||
const Step = std.Build.Step;
|
const Step = std.Build.Step;
|
||||||
const LibExeObjStep = std.Build.LibExeObjStep;
|
const CompileStep = std.Build.CompileStep;
|
||||||
const RunStep = std.Build.RunStep;
|
const RunStep = std.Build.RunStep;
|
||||||
|
|
||||||
const fs = std.fs;
|
const fs = std.fs;
|
||||||
@ -23,7 +23,7 @@ step: Step,
|
|||||||
builder: *std.Build,
|
builder: *std.Build,
|
||||||
|
|
||||||
/// The artifact (executable) to be run by this step
|
/// The artifact (executable) to be run by this step
|
||||||
exe: *LibExeObjStep,
|
exe: *CompileStep,
|
||||||
|
|
||||||
/// Set this to `null` to ignore the exit code for the purpose of determining a successful execution
|
/// Set this to `null` to ignore the exit code for the purpose of determining a successful execution
|
||||||
expected_exit_code: ?u8 = 0,
|
expected_exit_code: ?u8 = 0,
|
||||||
@ -45,7 +45,7 @@ hide_foreign_binaries_warning: bool,
|
|||||||
/// binary through emulation when any of the emulation options such as `enable_rosetta` are set to true.
|
/// binary through emulation when any of the emulation options such as `enable_rosetta` are set to true.
|
||||||
/// When set to false, and the binary is foreign, running the executable is skipped.
|
/// When set to false, and the binary is foreign, running the executable is skipped.
|
||||||
/// Asserts given artifact is an executable.
|
/// Asserts given artifact is an executable.
|
||||||
pub fn create(builder: *std.Build, name: []const u8, artifact: *LibExeObjStep) *EmulatableRunStep {
|
pub fn create(builder: *std.Build, name: []const u8, artifact: *CompileStep) *EmulatableRunStep {
|
||||||
std.debug.assert(artifact.kind == .exe or artifact.kind == .test_exe);
|
std.debug.assert(artifact.kind == .exe or artifact.kind == .test_exe);
|
||||||
const self = builder.allocator.create(EmulatableRunStep) catch unreachable;
|
const self = builder.allocator.create(EmulatableRunStep) catch unreachable;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
const std = @import("../std.zig");
|
const std = @import("../std.zig");
|
||||||
const Step = std.Build.Step;
|
const Step = std.Build.Step;
|
||||||
const LibExeObjStep = std.Build.LibExeObjStep;
|
const CompileStep = std.Build.CompileStep;
|
||||||
const InstallDir = std.Build.InstallDir;
|
const InstallDir = std.Build.InstallDir;
|
||||||
const InstallArtifactStep = @This();
|
const InstallArtifactStep = @This();
|
||||||
|
|
||||||
@ -8,12 +8,12 @@ pub const base_id = .install_artifact;
|
|||||||
|
|
||||||
step: Step,
|
step: Step,
|
||||||
builder: *std.Build,
|
builder: *std.Build,
|
||||||
artifact: *LibExeObjStep,
|
artifact: *CompileStep,
|
||||||
dest_dir: InstallDir,
|
dest_dir: InstallDir,
|
||||||
pdb_dir: ?InstallDir,
|
pdb_dir: ?InstallDir,
|
||||||
h_dir: ?InstallDir,
|
h_dir: ?InstallDir,
|
||||||
|
|
||||||
pub fn create(builder: *std.Build, artifact: *LibExeObjStep) *InstallArtifactStep {
|
pub fn create(builder: *std.Build, artifact: *CompileStep) *InstallArtifactStep {
|
||||||
if (artifact.install_step) |s| return s;
|
if (artifact.install_step) |s| return s;
|
||||||
|
|
||||||
const self = builder.allocator.create(InstallArtifactStep) catch unreachable;
|
const self = builder.allocator.create(InstallArtifactStep) catch unreachable;
|
||||||
@ -67,7 +67,7 @@ fn make(step: *Step) !void {
|
|||||||
const full_dest_path = builder.getInstallPath(self.dest_dir, self.artifact.out_filename);
|
const full_dest_path = builder.getInstallPath(self.dest_dir, self.artifact.out_filename);
|
||||||
try builder.updateFile(self.artifact.getOutputSource().getPath(builder), full_dest_path);
|
try builder.updateFile(self.artifact.getOutputSource().getPath(builder), full_dest_path);
|
||||||
if (self.artifact.isDynamicLibrary() and self.artifact.version != null and self.artifact.target.wantSharedLibSymLinks()) {
|
if (self.artifact.isDynamicLibrary() and self.artifact.version != null and self.artifact.target.wantSharedLibSymLinks()) {
|
||||||
try LibExeObjStep.doAtomicSymLinks(builder.allocator, full_dest_path, self.artifact.major_only_filename.?, self.artifact.name_only_filename.?);
|
try CompileStep.doAtomicSymLinks(builder.allocator, full_dest_path, self.artifact.major_only_filename.?, self.artifact.name_only_filename.?);
|
||||||
}
|
}
|
||||||
if (self.artifact.isDynamicLibrary() and self.artifact.target.isWindows() and self.artifact.emit_implib != .no_emit) {
|
if (self.artifact.isDynamicLibrary() and self.artifact.target.isWindows() and self.artifact.emit_implib != .no_emit) {
|
||||||
const full_implib_path = builder.getInstallPath(self.dest_dir, self.artifact.out_lib_filename);
|
const full_implib_path = builder.getInstallPath(self.dest_dir, self.artifact.out_lib_filename);
|
||||||
|
|||||||
@ -9,7 +9,7 @@ const ArenaAllocator = std.heap.ArenaAllocator;
|
|||||||
const ArrayListUnmanaged = std.ArrayListUnmanaged;
|
const ArrayListUnmanaged = std.ArrayListUnmanaged;
|
||||||
const File = std.fs.File;
|
const File = std.fs.File;
|
||||||
const InstallDir = std.Build.InstallDir;
|
const InstallDir = std.Build.InstallDir;
|
||||||
const LibExeObjStep = std.Build.LibExeObjStep;
|
const CompileStep = std.Build.CompileStep;
|
||||||
const Step = std.Build.Step;
|
const Step = std.Build.Step;
|
||||||
const elf = std.elf;
|
const elf = std.elf;
|
||||||
const fs = std.fs;
|
const fs = std.fs;
|
||||||
@ -25,7 +25,7 @@ pub const RawFormat = enum {
|
|||||||
|
|
||||||
step: Step,
|
step: Step,
|
||||||
builder: *std.Build,
|
builder: *std.Build,
|
||||||
artifact: *LibExeObjStep,
|
artifact: *CompileStep,
|
||||||
dest_dir: InstallDir,
|
dest_dir: InstallDir,
|
||||||
dest_filename: []const u8,
|
dest_filename: []const u8,
|
||||||
options: CreateOptions,
|
options: CreateOptions,
|
||||||
@ -40,7 +40,7 @@ pub const CreateOptions = struct {
|
|||||||
|
|
||||||
pub fn create(
|
pub fn create(
|
||||||
builder: *std.Build,
|
builder: *std.Build,
|
||||||
artifact: *LibExeObjStep,
|
artifact: *CompileStep,
|
||||||
dest_filename: []const u8,
|
dest_filename: []const u8,
|
||||||
options: CreateOptions,
|
options: CreateOptions,
|
||||||
) *InstallRawStep {
|
) *InstallRawStep {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ const builtin = @import("builtin");
|
|||||||
const fs = std.fs;
|
const fs = std.fs;
|
||||||
const Step = std.Build.Step;
|
const Step = std.Build.Step;
|
||||||
const GeneratedFile = std.Build.GeneratedFile;
|
const GeneratedFile = std.Build.GeneratedFile;
|
||||||
const LibExeObjStep = std.Build.LibExeObjStep;
|
const CompileStep = std.Build.CompileStep;
|
||||||
const FileSource = std.Build.FileSource;
|
const FileSource = std.Build.FileSource;
|
||||||
|
|
||||||
const OptionsStep = @This();
|
const OptionsStep = @This();
|
||||||
@ -195,7 +195,7 @@ pub fn addOptionFileSource(
|
|||||||
|
|
||||||
/// The value is the path in the cache dir.
|
/// The value is the path in the cache dir.
|
||||||
/// Adds a dependency automatically.
|
/// Adds a dependency automatically.
|
||||||
pub fn addOptionArtifact(self: *OptionsStep, name: []const u8, artifact: *LibExeObjStep) void {
|
pub fn addOptionArtifact(self: *OptionsStep, name: []const u8, artifact: *CompileStep) void {
|
||||||
self.artifact_args.append(.{ .name = self.builder.dupe(name), .artifact = artifact }) catch unreachable;
|
self.artifact_args.append(.{ .name = self.builder.dupe(name), .artifact = artifact }) catch unreachable;
|
||||||
self.step.dependOn(&artifact.step);
|
self.step.dependOn(&artifact.step);
|
||||||
}
|
}
|
||||||
@ -266,7 +266,7 @@ fn hashContentsToFileName(self: *OptionsStep) [64]u8 {
|
|||||||
|
|
||||||
const OptionArtifactArg = struct {
|
const OptionArtifactArg = struct {
|
||||||
name: []const u8,
|
name: []const u8,
|
||||||
artifact: *LibExeObjStep,
|
artifact: *CompileStep,
|
||||||
};
|
};
|
||||||
|
|
||||||
const OptionFileSourceArg = struct {
|
const OptionFileSourceArg = struct {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
const std = @import("../std.zig");
|
const std = @import("../std.zig");
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const Step = std.Build.Step;
|
const Step = std.Build.Step;
|
||||||
const LibExeObjStep = std.Build.LibExeObjStep;
|
const CompileStep = std.Build.CompileStep;
|
||||||
const WriteFileStep = std.Build.WriteFileStep;
|
const WriteFileStep = std.Build.WriteFileStep;
|
||||||
const fs = std.fs;
|
const fs = std.fs;
|
||||||
const mem = std.mem;
|
const mem = std.mem;
|
||||||
@ -48,7 +48,7 @@ pub const StdIoAction = union(enum) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub const Arg = union(enum) {
|
pub const Arg = union(enum) {
|
||||||
artifact: *LibExeObjStep,
|
artifact: *CompileStep,
|
||||||
file_source: std.Build.FileSource,
|
file_source: std.Build.FileSource,
|
||||||
bytes: []u8,
|
bytes: []u8,
|
||||||
};
|
};
|
||||||
@ -66,7 +66,7 @@ pub fn create(builder: *std.Build, name: []const u8) *RunStep {
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addArtifactArg(self: *RunStep, artifact: *LibExeObjStep) void {
|
pub fn addArtifactArg(self: *RunStep, artifact: *CompileStep) void {
|
||||||
self.argv.append(Arg{ .artifact = artifact }) catch unreachable;
|
self.argv.append(Arg{ .artifact = artifact }) catch unreachable;
|
||||||
self.step.dependOn(&artifact.step);
|
self.step.dependOn(&artifact.step);
|
||||||
}
|
}
|
||||||
@ -355,13 +355,13 @@ fn printCmd(cwd: ?[]const u8, argv: []const []const u8) void {
|
|||||||
std.debug.print("\n", .{});
|
std.debug.print("\n", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn addPathForDynLibs(self: *RunStep, artifact: *LibExeObjStep) void {
|
fn addPathForDynLibs(self: *RunStep, artifact: *CompileStep) void {
|
||||||
addPathForDynLibsInternal(&self.step, self.builder, artifact);
|
addPathForDynLibsInternal(&self.step, self.builder, artifact);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This should only be used for internal usage, this is called automatically
|
/// This should only be used for internal usage, this is called automatically
|
||||||
/// for the user.
|
/// for the user.
|
||||||
pub fn addPathForDynLibsInternal(step: *Step, builder: *std.Build, artifact: *LibExeObjStep) void {
|
pub fn addPathForDynLibsInternal(step: *Step, builder: *std.Build, artifact: *CompileStep) void {
|
||||||
for (artifact.link_objects.items) |link_object| {
|
for (artifact.link_objects.items) |link_object| {
|
||||||
switch (link_object) {
|
switch (link_object) {
|
||||||
.other_step => |other| {
|
.other_step => |other| {
|
||||||
|
|||||||
@ -7,7 +7,7 @@ done_flag: bool,
|
|||||||
|
|
||||||
pub const Id = enum {
|
pub const Id = enum {
|
||||||
top_level,
|
top_level,
|
||||||
lib_exe_obj,
|
compile,
|
||||||
install_artifact,
|
install_artifact,
|
||||||
install_file,
|
install_file,
|
||||||
install_dir,
|
install_dir,
|
||||||
@ -28,7 +28,7 @@ pub const Id = enum {
|
|||||||
pub fn Type(comptime id: Id) type {
|
pub fn Type(comptime id: Id) type {
|
||||||
return switch (id) {
|
return switch (id) {
|
||||||
.top_level => Build.TopLevelStep,
|
.top_level => Build.TopLevelStep,
|
||||||
.lib_exe_obj => Build.LibExeObjStep,
|
.compile => Build.CompileStep,
|
||||||
.install_artifact => Build.InstallArtifactStep,
|
.install_artifact => Build.InstallArtifactStep,
|
||||||
.install_file => Build.InstallFileStep,
|
.install_file => Build.InstallFileStep,
|
||||||
.install_dir => Build.InstallDirStep,
|
.install_dir => Build.InstallDirStep,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
const std = @import("../std.zig");
|
const std = @import("../std.zig");
|
||||||
const Step = std.Build.Step;
|
const Step = std.Build.Step;
|
||||||
const LibExeObjStep = std.Build.LibExeObjStep;
|
const CompileStep = std.Build.CompileStep;
|
||||||
const CheckFileStep = std.Build.CheckFileStep;
|
const CheckFileStep = std.Build.CheckFileStep;
|
||||||
const fs = std.fs;
|
const fs = std.fs;
|
||||||
const mem = std.mem;
|
const mem = std.mem;
|
||||||
@ -51,11 +51,11 @@ pub const AddExecutableOptions = struct {
|
|||||||
version: ?std.builtin.Version = null,
|
version: ?std.builtin.Version = null,
|
||||||
target: ?CrossTarget = null,
|
target: ?CrossTarget = null,
|
||||||
optimize: ?std.builtin.Mode = null,
|
optimize: ?std.builtin.Mode = null,
|
||||||
linkage: ?LibExeObjStep.Linkage = null,
|
linkage: ?CompileStep.Linkage = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Creates a step to build an executable from the translated source.
|
/// Creates a step to build an executable from the translated source.
|
||||||
pub fn addExecutable(self: *TranslateCStep, options: AddExecutableOptions) *LibExeObjStep {
|
pub fn addExecutable(self: *TranslateCStep, options: AddExecutableOptions) *CompileStep {
|
||||||
return self.builder.addExecutable(.{
|
return self.builder.addExecutable(.{
|
||||||
.root_source_file = .{ .generated = &self.output_file },
|
.root_source_file = .{ .generated = &self.output_file },
|
||||||
.name = options.name orelse "translated_c",
|
.name = options.name orelse "translated_c",
|
||||||
|
|||||||
@ -97,8 +97,10 @@ pub const zig = @import("zig.zig");
|
|||||||
pub const start = @import("start.zig");
|
pub const start = @import("start.zig");
|
||||||
|
|
||||||
///// Deprecated. Use `std.Build` instead.
|
///// Deprecated. Use `std.Build` instead.
|
||||||
|
///// TODO: remove this after releasing 0.11.0
|
||||||
//pub const build = struct {
|
//pub const build = struct {
|
||||||
// /// Deprecated. Use `std.Build` instead.
|
// /// Deprecated. Use `std.Build` instead.
|
||||||
|
// /// TODO: remove this after releasing 0.11.0
|
||||||
// pub const Builder = Build;
|
// pub const Builder = Build;
|
||||||
//};
|
//};
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const LibExeObjectStep = std.Build.LibExeObjStep;
|
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const LibExeObjectStep = std.Build.LibExeObjStep;
|
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
@ -36,7 +35,11 @@ pub fn build(b: *std.Build) void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn createScenario(b: *std.Build, optimize: std.builtin.OptimizeMode, target: std.zig.CrossTarget) *LibExeObjectStep {
|
fn createScenario(
|
||||||
|
b: *std.Build,
|
||||||
|
optimize: std.builtin.OptimizeMode,
|
||||||
|
target: std.zig.CrossTarget,
|
||||||
|
) *std.Build.CompileStep {
|
||||||
const exe = b.addExecutable(.{
|
const exe = b.addExecutable(.{
|
||||||
.name = "test",
|
.name = "test",
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const LibExeObjectStep = std.Build.LibExeObjStep;
|
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
@ -35,7 +34,7 @@ pub fn build(b: *std.Build) void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn createScenario(b: *std.Build, optimize: std.builtin.OptimizeMode) *LibExeObjectStep {
|
fn createScenario(b: *std.Build, optimize: std.builtin.OptimizeMode) *std.Build.CompileStep {
|
||||||
const exe = b.addExecutable(.{
|
const exe = b.addExecutable(.{
|
||||||
.name = "test",
|
.name = "test",
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const LibExeObjectStep = std.Build.LibExeObjStep;
|
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
@ -93,7 +92,7 @@ pub fn build(b: *std.Build) void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn simpleExe(b: *std.Build, optimize: std.builtin.OptimizeMode) *LibExeObjectStep {
|
fn simpleExe(b: *std.Build, optimize: std.builtin.OptimizeMode) *std.Build.CompileStep {
|
||||||
const exe = b.addExecutable(.{
|
const exe = b.addExecutable(.{
|
||||||
.name = "main",
|
.name = "main",
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const LibExeObjectStep = std.Build.LibExeObjStep;
|
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const LibExeObjectStep = std.Build.LibExeObjStep;
|
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const LibExeObjectStep = std.Build.LibExeObjStep;
|
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
@ -35,7 +34,11 @@ pub fn build(b: *std.Build) void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn createScenario(b: *std.Build, optimize: std.builtin.OptimizeMode, target: std.zig.CrossTarget) *LibExeObjectStep {
|
fn createScenario(
|
||||||
|
b: *std.Build,
|
||||||
|
optimize: std.builtin.OptimizeMode,
|
||||||
|
target: std.zig.CrossTarget,
|
||||||
|
) *std.Build.CompileStep {
|
||||||
const static = b.addStaticLibrary(.{
|
const static = b.addStaticLibrary(.{
|
||||||
.name = "a",
|
.name = "a",
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const LibExeObjectStep = std.Build.LibExeObjStep;
|
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const LibExeObjectStep = std.Build.LibExeObjStep;
|
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
@ -51,7 +50,11 @@ fn testUnwindInfo(
|
|||||||
test_step.dependOn(&run_cmd.step);
|
test_step.dependOn(&run_cmd.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn createScenario(b: *std.Build, optimize: std.builtin.OptimizeMode, target: std.zig.CrossTarget) *LibExeObjectStep {
|
fn createScenario(
|
||||||
|
b: *std.Build,
|
||||||
|
optimize: std.builtin.OptimizeMode,
|
||||||
|
target: std.zig.CrossTarget,
|
||||||
|
) *std.Build.CompileStep {
|
||||||
const exe = b.addExecutable(.{
|
const exe = b.addExecutable(.{
|
||||||
.name = "test",
|
.name = "test",
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const LibExeObjectStep = std.Build.LibExeObjStep;
|
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const test_step = b.step("test", "Test");
|
const test_step = b.step("test", "Test");
|
||||||
@ -51,7 +50,11 @@ fn testUuid(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn simpleDylib(b: *std.Build, optimize: std.builtin.OptimizeMode, target: std.zig.CrossTarget) *LibExeObjectStep {
|
fn simpleDylib(
|
||||||
|
b: *std.Build,
|
||||||
|
optimize: std.builtin.OptimizeMode,
|
||||||
|
target: std.zig.CrossTarget,
|
||||||
|
) *std.Build.CompileStep {
|
||||||
const dylib = b.addSharedLibrary(.{
|
const dylib = b.addSharedLibrary(.{
|
||||||
.name = "test",
|
.name = "test",
|
||||||
.version = .{ .major = 1, .minor = 0 },
|
.version = .{ .major = 1, .minor = 0 },
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const LibExeObjectStep = std.Build.LibExeObjStep;
|
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const LibExeObjectStep = std.Build.LibExeObjStep;
|
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|||||||
@ -8,7 +8,7 @@ const mem = std.mem;
|
|||||||
const fmt = std.fmt;
|
const fmt = std.fmt;
|
||||||
const ArrayList = std.ArrayList;
|
const ArrayList = std.ArrayList;
|
||||||
const OptimizeMode = std.builtin.OptimizeMode;
|
const OptimizeMode = std.builtin.OptimizeMode;
|
||||||
const LibExeObjStep = std.Build.LibExeObjStep;
|
const CompileStep = std.Build.CompileStep;
|
||||||
const Allocator = mem.Allocator;
|
const Allocator = mem.Allocator;
|
||||||
const ExecError = std.Build.ExecError;
|
const ExecError = std.Build.ExecError;
|
||||||
const Step = std.Build.Step;
|
const Step = std.Build.Step;
|
||||||
@ -842,7 +842,7 @@ pub const StackTracesContext = struct {
|
|||||||
|
|
||||||
step: Step,
|
step: Step,
|
||||||
context: *StackTracesContext,
|
context: *StackTracesContext,
|
||||||
exe: *LibExeObjStep,
|
exe: *CompileStep,
|
||||||
name: []const u8,
|
name: []const u8,
|
||||||
optimize_mode: OptimizeMode,
|
optimize_mode: OptimizeMode,
|
||||||
expect_output: []const u8,
|
expect_output: []const u8,
|
||||||
@ -850,7 +850,7 @@ pub const StackTracesContext = struct {
|
|||||||
|
|
||||||
pub fn create(
|
pub fn create(
|
||||||
context: *StackTracesContext,
|
context: *StackTracesContext,
|
||||||
exe: *LibExeObjStep,
|
exe: *CompileStep,
|
||||||
name: []const u8,
|
name: []const u8,
|
||||||
optimize_mode: OptimizeMode,
|
optimize_mode: OptimizeMode,
|
||||||
expect_output: []const u8,
|
expect_output: []const u8,
|
||||||
@ -1180,14 +1180,14 @@ pub const GenHContext = struct {
|
|||||||
const GenHCmpOutputStep = struct {
|
const GenHCmpOutputStep = struct {
|
||||||
step: Step,
|
step: Step,
|
||||||
context: *GenHContext,
|
context: *GenHContext,
|
||||||
obj: *LibExeObjStep,
|
obj: *CompileStep,
|
||||||
name: []const u8,
|
name: []const u8,
|
||||||
test_index: usize,
|
test_index: usize,
|
||||||
case: *const TestCase,
|
case: *const TestCase,
|
||||||
|
|
||||||
pub fn create(
|
pub fn create(
|
||||||
context: *GenHContext,
|
context: *GenHContext,
|
||||||
obj: *LibExeObjStep,
|
obj: *CompileStep,
|
||||||
name: []const u8,
|
name: []const u8,
|
||||||
case: *const TestCase,
|
case: *const TestCase,
|
||||||
) *GenHCmpOutputStep {
|
) *GenHCmpOutputStep {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user