mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
std.Build: remove deprecated APIs
These APIs were all deprecated prior to the release of 0.13.0, so can be safety removed in the current release cycle. `std.Build`: * `host` -> `graph.host` `std.Build.Step.Compile`: * `setLinkerScriptPath` -> `setLinkerScript` * `defineCMacro` -> `root_module.addCMacro` * `linkFrameworkNeeded`-> `root_module.linkFramework` * `linkFrameworkWeak`-> `root_module.linkFramework` `std.Build.Step.ObjCopy`: * `getOutputSource` -> `getOutput` `std.Build.Step.Options`: * `addOptionArtifact` -> `addOptionPath` * `getSource` -> `getOutput` `std.Build.Step.Run`: * `extra_file_dependencies` -> `addFileInput` * `addDirectorySourceArg` -> `addDirectoryArg` * `addPrefixedDirectorySourceArg` -> `addPrefixedDirectoryArg`
This commit is contained in:
parent
debba652a3
commit
3d393dba6f
9 changed files with 9 additions and 56 deletions
|
|
@ -81,9 +81,6 @@ enable_wine: bool = false,
|
||||||
/// that contains the path `aarch64-linux-gnu/lib/ld-linux-aarch64.so.1`.
|
/// that contains the path `aarch64-linux-gnu/lib/ld-linux-aarch64.so.1`.
|
||||||
glibc_runtimes_dir: ?[]const u8 = null,
|
glibc_runtimes_dir: ?[]const u8 = null,
|
||||||
|
|
||||||
/// Deprecated. Use `b.graph.host`.
|
|
||||||
host: ResolvedTarget,
|
|
||||||
|
|
||||||
dep_prefix: []const u8 = "",
|
dep_prefix: []const u8 = "",
|
||||||
|
|
||||||
modules: std.StringArrayHashMap(*Module),
|
modules: std.StringArrayHashMap(*Module),
|
||||||
|
|
@ -301,7 +298,6 @@ pub fn create(
|
||||||
},
|
},
|
||||||
.install_path = undefined,
|
.install_path = undefined,
|
||||||
.args = null,
|
.args = null,
|
||||||
.host = graph.host,
|
|
||||||
.modules = .init(arena),
|
.modules = .init(arena),
|
||||||
.named_writefiles = .init(arena),
|
.named_writefiles = .init(arena),
|
||||||
.named_lazy_paths = .init(arena),
|
.named_lazy_paths = .init(arena),
|
||||||
|
|
@ -393,7 +389,6 @@ fn createChildOnly(
|
||||||
.enable_wasmtime = parent.enable_wasmtime,
|
.enable_wasmtime = parent.enable_wasmtime,
|
||||||
.enable_wine = parent.enable_wine,
|
.enable_wine = parent.enable_wine,
|
||||||
.glibc_runtimes_dir = parent.glibc_runtimes_dir,
|
.glibc_runtimes_dir = parent.glibc_runtimes_dir,
|
||||||
.host = parent.host,
|
|
||||||
.dep_prefix = parent.fmt("{s}{s}.", .{ parent.dep_prefix, dep_name }),
|
.dep_prefix = parent.fmt("{s}{s}.", .{ parent.dep_prefix, dep_name }),
|
||||||
.modules = .init(allocator),
|
.modules = .init(allocator),
|
||||||
.named_writefiles = .init(allocator),
|
.named_writefiles = .init(allocator),
|
||||||
|
|
|
||||||
|
|
@ -583,9 +583,6 @@ pub fn checkObject(compile: *Compile) *Step.CheckObject {
|
||||||
return Step.CheckObject.create(compile.step.owner, compile.getEmittedBin(), compile.rootModuleTarget().ofmt);
|
return Step.CheckObject.create(compile.step.owner, compile.getEmittedBin(), compile.rootModuleTarget().ofmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// deprecated: use `setLinkerScript`
|
|
||||||
pub const setLinkerScriptPath = setLinkerScript;
|
|
||||||
|
|
||||||
pub fn setLinkerScript(compile: *Compile, source: LazyPath) void {
|
pub fn setLinkerScript(compile: *Compile, source: LazyPath) void {
|
||||||
const b = compile.step.owner;
|
const b = compile.step.owner;
|
||||||
compile.linker_script = source.dupe(b);
|
compile.linker_script = source.dupe(b);
|
||||||
|
|
@ -675,11 +672,6 @@ pub fn linkLibCpp(compile: *Compile) void {
|
||||||
compile.root_module.link_libcpp = true;
|
compile.root_module.link_libcpp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deprecated. Use `c.root_module.addCMacro`.
|
|
||||||
pub fn defineCMacro(c: *Compile, name: []const u8, value: ?[]const u8) void {
|
|
||||||
c.root_module.addCMacro(name, value orelse "1");
|
|
||||||
}
|
|
||||||
|
|
||||||
const PkgConfigResult = struct {
|
const PkgConfigResult = struct {
|
||||||
cflags: []const []const u8,
|
cflags: []const []const u8,
|
||||||
libs: []const []const u8,
|
libs: []const []const u8,
|
||||||
|
|
@ -805,16 +797,6 @@ pub fn linkFramework(c: *Compile, name: []const u8) void {
|
||||||
c.root_module.linkFramework(name, .{});
|
c.root_module.linkFramework(name, .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deprecated. Use `c.root_module.linkFramework`.
|
|
||||||
pub fn linkFrameworkNeeded(c: *Compile, name: []const u8) void {
|
|
||||||
c.root_module.linkFramework(name, .{ .needed = true });
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Deprecated. Use `c.root_module.linkFramework`.
|
|
||||||
pub fn linkFrameworkWeak(c: *Compile, name: []const u8) void {
|
|
||||||
c.root_module.linkFramework(name, .{ .weak = true });
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 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(compile: *Compile, options: Module.AddCSourceFilesOptions) void {
|
pub fn addCSourceFiles(compile: *Compile, options: Module.AddCSourceFilesOptions) void {
|
||||||
compile.root_module.addCSourceFiles(options);
|
compile.root_module.addCSourceFiles(options);
|
||||||
|
|
|
||||||
|
|
@ -135,9 +135,6 @@ pub fn create(
|
||||||
return objcopy;
|
return objcopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// deprecated: use getOutput
|
|
||||||
pub const getOutputSource = getOutput;
|
|
||||||
|
|
||||||
pub fn getOutput(objcopy: *const ObjCopy) std.Build.LazyPath {
|
pub fn getOutput(objcopy: *const ObjCopy) std.Build.LazyPath {
|
||||||
return .{ .generated = .{ .file = &objcopy.output_file } };
|
return .{ .generated = .{ .file = &objcopy.output_file } };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -390,20 +390,12 @@ pub fn addOptionPath(
|
||||||
path.addStepDependencies(&options.step);
|
path.addStepDependencies(&options.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deprecated: use `addOptionPath(options, name, artifact.getEmittedBin())` instead.
|
|
||||||
pub fn addOptionArtifact(options: *Options, name: []const u8, artifact: *Step.Compile) void {
|
|
||||||
return addOptionPath(options, name, artifact.getEmittedBin());
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn createModule(options: *Options) *std.Build.Module {
|
pub fn createModule(options: *Options) *std.Build.Module {
|
||||||
return options.step.owner.createModule(.{
|
return options.step.owner.createModule(.{
|
||||||
.root_source_file = options.getOutput(),
|
.root_source_file = options.getOutput(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// deprecated: use `getOutput`
|
|
||||||
pub const getSource = getOutput;
|
|
||||||
|
|
||||||
/// Returns the main artifact of this Build Step which is a Zig source file
|
/// Returns the main artifact of this Build Step which is a Zig source file
|
||||||
/// generated from the key-value pairs of the Options.
|
/// generated from the key-value pairs of the Options.
|
||||||
pub fn getOutput(options: *Options) LazyPath {
|
pub fn getOutput(options: *Options) LazyPath {
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,6 @@ stdio: StdIo,
|
||||||
/// It should be only set using `setStdIn`.
|
/// It should be only set using `setStdIn`.
|
||||||
stdin: StdIn,
|
stdin: StdIn,
|
||||||
|
|
||||||
/// Deprecated: use `addFileInput`
|
|
||||||
extra_file_dependencies: []const []const u8,
|
|
||||||
|
|
||||||
/// Additional input files that, when modified, indicate that the Run step
|
/// Additional input files that, when modified, indicate that the Run step
|
||||||
/// should be re-executed.
|
/// should be re-executed.
|
||||||
/// If the Run step is determined to have side-effects, the Run step is always
|
/// If the Run step is determined to have side-effects, the Run step is always
|
||||||
|
|
@ -178,7 +175,6 @@ pub fn create(owner: *std.Build, name: []const u8) *Run {
|
||||||
.disable_zig_progress = false,
|
.disable_zig_progress = false,
|
||||||
.stdio = .infer_from_args,
|
.stdio = .infer_from_args,
|
||||||
.stdin = .none,
|
.stdin = .none,
|
||||||
.extra_file_dependencies = &.{},
|
|
||||||
.file_inputs = .{},
|
.file_inputs = .{},
|
||||||
.rename_step_with_output_arg = true,
|
.rename_step_with_output_arg = true,
|
||||||
.skip_foreign_checks = false,
|
.skip_foreign_checks = false,
|
||||||
|
|
@ -364,16 +360,10 @@ pub fn addPrefixedOutputDirectoryArg(
|
||||||
return .{ .generated = .{ .file = &output.generated_file } };
|
return .{ .generated = .{ .file = &output.generated_file } };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// deprecated: use `addDirectoryArg`
|
|
||||||
pub const addDirectorySourceArg = addDirectoryArg;
|
|
||||||
|
|
||||||
pub fn addDirectoryArg(run: *Run, directory_source: std.Build.LazyPath) void {
|
pub fn addDirectoryArg(run: *Run, directory_source: std.Build.LazyPath) void {
|
||||||
run.addPrefixedDirectoryArg("", directory_source);
|
run.addPrefixedDirectoryArg("", directory_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
// deprecated: use `addPrefixedDirectoryArg`
|
|
||||||
pub const addPrefixedDirectorySourceArg = addPrefixedDirectoryArg;
|
|
||||||
|
|
||||||
pub fn addPrefixedDirectoryArg(run: *Run, prefix: []const u8, directory_source: std.Build.LazyPath) void {
|
pub fn addPrefixedDirectoryArg(run: *Run, prefix: []const u8, directory_source: std.Build.LazyPath) void {
|
||||||
const b = run.step.owner;
|
const b = run.step.owner;
|
||||||
|
|
||||||
|
|
@ -698,9 +688,6 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
|
||||||
|
|
||||||
hashStdIo(&man.hash, run.stdio);
|
hashStdIo(&man.hash, run.stdio);
|
||||||
|
|
||||||
for (run.extra_file_dependencies) |file_path| {
|
|
||||||
_ = try man.addFile(b.pathFromRoot(file_path), null);
|
|
||||||
}
|
|
||||||
for (run.file_inputs.items) |lazy_path| {
|
for (run.file_inputs.items) |lazy_path| {
|
||||||
_ = try man.addFile(lazy_path.getPath2(b, step), null);
|
_ = try man.addFile(lazy_path.getPath2(b, step), null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
test/standalone/extern/build.zig
vendored
2
test/standalone/extern/build.zig
vendored
|
|
@ -18,7 +18,7 @@ pub fn build(b: *std.Build) void {
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.link_libc = true,
|
.link_libc = true,
|
||||||
});
|
});
|
||||||
if (b.graph.host.result.abi == .msvc) shared.defineCMacro("API", "__declspec(dllexport)");
|
if (b.graph.host.result.abi == .msvc) shared.root_module.addCMacro("API", "__declspec(dllexport)");
|
||||||
shared.addCSourceFile(.{ .file = b.path("shared.c"), .flags = &.{} });
|
shared.addCSourceFile(.{ .file = b.path("shared.c"), .flags = &.{} });
|
||||||
const test_exe = b.addTest(.{
|
const test_exe = b.addTest(.{
|
||||||
.root_source_file = b.path("main.zig"),
|
.root_source_file = b.path("main.zig"),
|
||||||
|
|
|
||||||
|
|
@ -30,16 +30,16 @@ pub fn build(b: *std.Build) void {
|
||||||
|
|
||||||
var i: i32 = 0;
|
var i: i32 = 0;
|
||||||
while (i < 1000) : (i += 1) {
|
while (i < 1000) : (i += 1) {
|
||||||
exe.defineCMacro("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
|
exe.root_module.addCMacro("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
|
||||||
}
|
}
|
||||||
|
|
||||||
exe.defineCMacro("FOO", "42");
|
exe.root_module.addCMacro("FOO", "42");
|
||||||
exe.defineCMacro("BAR", "\"BAR\"");
|
exe.root_module.addCMacro("BAR", "\"BAR\"");
|
||||||
exe.defineCMacro("BAZ",
|
exe.root_module.addCMacro("BAZ",
|
||||||
\\"\"BAZ\""
|
\\"\"BAZ\""
|
||||||
);
|
);
|
||||||
exe.defineCMacro("QUX", "\"Q\" \"UX\"");
|
exe.root_module.addCMacro("QUX", "\"Q\" \"UX\"");
|
||||||
exe.defineCMacro("QUUX", "\"QU\\\"UX\"");
|
exe.root_module.addCMacro("QUUX", "\"QU\\\"UX\"");
|
||||||
|
|
||||||
b.default_step.dependOn(&exe.step);
|
b.default_step.dependOn(&exe.step);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ pub fn build(b: *std.Build) void {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (target.result.os.tag == .windows)
|
if (target.result.os.tag == .windows)
|
||||||
c_shared_lib.defineCMacro("LIB_API", "__declspec(dllexport)");
|
c_shared_lib.root_module.addCMacro("LIB_API", "__declspec(dllexport)");
|
||||||
|
|
||||||
c_shared_lib.addCSourceFile(.{
|
c_shared_lib.addCSourceFile(.{
|
||||||
.file = b.path("shared_lib.c"),
|
.file = b.path("shared_lib.c"),
|
||||||
|
|
|
||||||
|
|
@ -1704,7 +1704,7 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
|
||||||
.file = b.path("test/c_abi/cfuncs.c"),
|
.file = b.path("test/c_abi/cfuncs.c"),
|
||||||
.flags = &.{"-std=c99"},
|
.flags = &.{"-std=c99"},
|
||||||
});
|
});
|
||||||
for (c_abi_target.c_defines) |define| test_step.defineCMacro(define, null);
|
for (c_abi_target.c_defines) |define| test_step.root_module.addCMacro(define, "1");
|
||||||
|
|
||||||
// This test is intentionally trying to check if the external ABI is
|
// This test is intentionally trying to check if the external ABI is
|
||||||
// done properly. LTO would be a hindrance to this.
|
// done properly. LTO would be a hindrance to this.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue