authorgravatar for bratishkaerik@landless-city.netEric Joldasov <bratishkaerik@landless-city.net> 2024-06-21 09:36:45+05:00
committergravatar for bratishkaerik@landless-city.netEric Joldasov <bratishkaerik@landless-city.net> 2024-12-18 01:47:50+05:00
log3d393dba6fc06cea3508aaa3db9d49042663367e
treed377f0aa22b7ed353a44e61a9fe7554ffa6c7707
parentdebba652a3f5af76840517321d389a2ec98a88f4
signaturelock-open Commit is signed but in an unrecognized format.

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`

9 files changed, 9 insertions(+), 56 deletions(-)

lib/std/Build.zig-5
...@@ -81,9 +81,6 @@ enable_wine: bool = false,...@@ -81,9 +81,6 @@ enable_wine: bool = false,
81/// that contains the path `aarch64-linux-gnu/lib/ld-linux-aarch64.so.1`.81/// that contains the path `aarch64-linux-gnu/lib/ld-linux-aarch64.so.1`.
82glibc_runtimes_dir: ?[]const u8 = null,82glibc_runtimes_dir: ?[]const u8 = null,
8383
84/// Deprecated. Use `b.graph.host`.
85host: ResolvedTarget,
86
87dep_prefix: []const u8 = "",84dep_prefix: []const u8 = "",
8885
89modules: std.StringArrayHashMap(*Module),86modules: std.StringArrayHashMap(*Module),
...@@ -301,7 +298,6 @@ pub fn create(...@@ -301,7 +298,6 @@ pub fn create(
301 },298 },
302 .install_path = undefined,299 .install_path = undefined,
303 .args = null,300 .args = null,
304 .host = graph.host,
305 .modules = .init(arena),301 .modules = .init(arena),
306 .named_writefiles = .init(arena),302 .named_writefiles = .init(arena),
307 .named_lazy_paths = .init(arena),303 .named_lazy_paths = .init(arena),
...@@ -393,7 +389,6 @@ fn createChildOnly(...@@ -393,7 +389,6 @@ fn createChildOnly(
393 .enable_wasmtime = parent.enable_wasmtime,389 .enable_wasmtime = parent.enable_wasmtime,
394 .enable_wine = parent.enable_wine,390 .enable_wine = parent.enable_wine,
395 .glibc_runtimes_dir = parent.glibc_runtimes_dir,391 .glibc_runtimes_dir = parent.glibc_runtimes_dir,
396 .host = parent.host,
397 .dep_prefix = parent.fmt("{s}{s}.", .{ parent.dep_prefix, dep_name }),392 .dep_prefix = parent.fmt("{s}{s}.", .{ parent.dep_prefix, dep_name }),
398 .modules = .init(allocator),393 .modules = .init(allocator),
399 .named_writefiles = .init(allocator),394 .named_writefiles = .init(allocator),
lib/std/Build/Step/Compile.zig-18
...@@ -583,9 +583,6 @@ pub fn checkObject(compile: *Compile) *Step.CheckObject {...@@ -583,9 +583,6 @@ pub fn checkObject(compile: *Compile) *Step.CheckObject {
583 return Step.CheckObject.create(compile.step.owner, compile.getEmittedBin(), compile.rootModuleTarget().ofmt);583 return Step.CheckObject.create(compile.step.owner, compile.getEmittedBin(), compile.rootModuleTarget().ofmt);
584}584}
585585
586/// deprecated: use `setLinkerScript`
587pub const setLinkerScriptPath = setLinkerScript;
588
589pub fn setLinkerScript(compile: *Compile, source: LazyPath) void {586pub fn setLinkerScript(compile: *Compile, source: LazyPath) void {
590 const b = compile.step.owner;587 const b = compile.step.owner;
591 compile.linker_script = source.dupe(b);588 compile.linker_script = source.dupe(b);
...@@ -675,11 +672,6 @@ pub fn linkLibCpp(compile: *Compile) void {...@@ -675,11 +672,6 @@ pub fn linkLibCpp(compile: *Compile) void {
675 compile.root_module.link_libcpp = true;672 compile.root_module.link_libcpp = true;
676}673}
677674
678/// Deprecated. Use `c.root_module.addCMacro`.
679pub fn defineCMacro(c: *Compile, name: []const u8, value: ?[]const u8) void {
680 c.root_module.addCMacro(name, value orelse "1");
681}
682
683const PkgConfigResult = struct {675const PkgConfigResult = struct {
684 cflags: []const []const u8,676 cflags: []const []const u8,
685 libs: []const []const u8,677 libs: []const []const u8,
...@@ -805,16 +797,6 @@ pub fn linkFramework(c: *Compile, name: []const u8) void {...@@ -805,16 +797,6 @@ pub fn linkFramework(c: *Compile, name: []const u8) void {
805 c.root_module.linkFramework(name, .{});797 c.root_module.linkFramework(name, .{});
806}798}
807799
808/// Deprecated. Use `c.root_module.linkFramework`.
809pub fn linkFrameworkNeeded(c: *Compile, name: []const u8) void {
810 c.root_module.linkFramework(name, .{ .needed = true });
811}
812
813/// Deprecated. Use `c.root_module.linkFramework`.
814pub fn linkFrameworkWeak(c: *Compile, name: []const u8) void {
815 c.root_module.linkFramework(name, .{ .weak = true });
816}
817
818/// Handy when you have many C/C++ source files and want them all to have the same flags.800/// Handy when you have many C/C++ source files and want them all to have the same flags.
819pub fn addCSourceFiles(compile: *Compile, options: Module.AddCSourceFilesOptions) void {801pub fn addCSourceFiles(compile: *Compile, options: Module.AddCSourceFilesOptions) void {
820 compile.root_module.addCSourceFiles(options);802 compile.root_module.addCSourceFiles(options);
lib/std/Build/Step/ObjCopy.zig-3
...@@ -135,9 +135,6 @@ pub fn create(...@@ -135,9 +135,6 @@ pub fn create(
135 return objcopy;135 return objcopy;
136}136}
137137
138/// deprecated: use getOutput
139pub const getOutputSource = getOutput;
140
141pub fn getOutput(objcopy: *const ObjCopy) std.Build.LazyPath {138pub fn getOutput(objcopy: *const ObjCopy) std.Build.LazyPath {
142 return .{ .generated = .{ .file = &objcopy.output_file } };139 return .{ .generated = .{ .file = &objcopy.output_file } };
143}140}
lib/std/Build/Step/Options.zig-8
...@@ -390,20 +390,12 @@ pub fn addOptionPath(...@@ -390,20 +390,12 @@ pub fn addOptionPath(
390 path.addStepDependencies(&options.step);390 path.addStepDependencies(&options.step);
391}391}
392392
393/// Deprecated: use `addOptionPath(options, name, artifact.getEmittedBin())` instead.
394pub fn addOptionArtifact(options: *Options, name: []const u8, artifact: *Step.Compile) void {
395 return addOptionPath(options, name, artifact.getEmittedBin());
396}
397
398pub fn createModule(options: *Options) *std.Build.Module {393pub fn createModule(options: *Options) *std.Build.Module {
399 return options.step.owner.createModule(.{394 return options.step.owner.createModule(.{
400 .root_source_file = options.getOutput(),395 .root_source_file = options.getOutput(),
401 });396 });
402}397}
403398
404/// deprecated: use `getOutput`
405pub const getSource = getOutput;
406
407/// Returns the main artifact of this Build Step which is a Zig source file399/// Returns the main artifact of this Build Step which is a Zig source file
408/// generated from the key-value pairs of the Options.400/// generated from the key-value pairs of the Options.
409pub fn getOutput(options: *Options) LazyPath {401pub fn getOutput(options: *Options) LazyPath {
lib/std/Build/Step/Run.zig-13
...@@ -43,9 +43,6 @@ stdio: StdIo,...@@ -43,9 +43,6 @@ stdio: StdIo,
43/// It should be only set using `setStdIn`.43/// It should be only set using `setStdIn`.
44stdin: StdIn,44stdin: StdIn,
4545
46/// Deprecated: use `addFileInput`
47extra_file_dependencies: []const []const u8,
48
49/// Additional input files that, when modified, indicate that the Run step46/// Additional input files that, when modified, indicate that the Run step
50/// should be re-executed.47/// should be re-executed.
51/// If the Run step is determined to have side-effects, the Run step is always48/// 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 {...@@ -178,7 +175,6 @@ pub fn create(owner: *std.Build, name: []const u8) *Run {
178 .disable_zig_progress = false,175 .disable_zig_progress = false,
179 .stdio = .infer_from_args,176 .stdio = .infer_from_args,
180 .stdin = .none,177 .stdin = .none,
181 .extra_file_dependencies = &.{},
182 .file_inputs = .{},178 .file_inputs = .{},
183 .rename_step_with_output_arg = true,179 .rename_step_with_output_arg = true,
184 .skip_foreign_checks = false,180 .skip_foreign_checks = false,
...@@ -364,16 +360,10 @@ pub fn addPrefixedOutputDirectoryArg(...@@ -364,16 +360,10 @@ pub fn addPrefixedOutputDirectoryArg(
364 return .{ .generated = .{ .file = &output.generated_file } };360 return .{ .generated = .{ .file = &output.generated_file } };
365}361}
366362
367/// deprecated: use `addDirectoryArg`
368pub const addDirectorySourceArg = addDirectoryArg;
369
370pub fn addDirectoryArg(run: *Run, directory_source: std.Build.LazyPath) void {363pub fn addDirectoryArg(run: *Run, directory_source: std.Build.LazyPath) void {
371 run.addPrefixedDirectoryArg("", directory_source);364 run.addPrefixedDirectoryArg("", directory_source);
372}365}
373366
374// deprecated: use `addPrefixedDirectoryArg`
375pub const addPrefixedDirectorySourceArg = addPrefixedDirectoryArg;
376
377pub fn addPrefixedDirectoryArg(run: *Run, prefix: []const u8, directory_source: std.Build.LazyPath) void {367pub fn addPrefixedDirectoryArg(run: *Run, prefix: []const u8, directory_source: std.Build.LazyPath) void {
378 const b = run.step.owner;368 const b = run.step.owner;
379369
...@@ -698,9 +688,6 @@ fn make(step: *Step, options: Step.MakeOptions) !void {...@@ -698,9 +688,6 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
698688
699 hashStdIo(&man.hash, run.stdio);689 hashStdIo(&man.hash, run.stdio);
700690
701 for (run.extra_file_dependencies) |file_path| {
702 _ = try man.addFile(b.pathFromRoot(file_path), null);
703 }
704 for (run.file_inputs.items) |lazy_path| {691 for (run.file_inputs.items) |lazy_path| {
705 _ = try man.addFile(lazy_path.getPath2(b, step), null);692 _ = try man.addFile(lazy_path.getPath2(b, step), null);
706 }693 }
test/standalone/extern/build.zig+1-1
...@@ -18,7 +18,7 @@ pub fn build(b: *std.Build) void {...@@ -18,7 +18,7 @@ pub fn build(b: *std.Build) void {
18 .optimize = optimize,18 .optimize = optimize,
19 .link_libc = true,19 .link_libc = true,
20 });20 });
21 if (b.graph.host.result.abi == .msvc) shared.defineCMacro("API", "__declspec(dllexport)");21 if (b.graph.host.result.abi == .msvc) shared.root_module.addCMacro("API", "__declspec(dllexport)");
22 shared.addCSourceFile(.{ .file = b.path("shared.c"), .flags = &.{} });22 shared.addCSourceFile(.{ .file = b.path("shared.c"), .flags = &.{} });
23 const test_exe = b.addTest(.{23 const test_exe = b.addTest(.{
24 .root_source_file = b.path("main.zig"),24 .root_source_file = b.path("main.zig"),
test/standalone/issue_11595/build.zig+6-6
...@@ -30,16 +30,16 @@ pub fn build(b: *std.Build) void {...@@ -30,16 +30,16 @@ pub fn build(b: *std.Build) void {
3030
31 var i: i32 = 0;31 var i: i32 = 0;
32 while (i < 1000) : (i += 1) {32 while (i < 1000) : (i += 1) {
33 exe.defineCMacro("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");33 exe.root_module.addCMacro("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
34 }34 }
3535
36 exe.defineCMacro("FOO", "42");36 exe.root_module.addCMacro("FOO", "42");
37 exe.defineCMacro("BAR", "\"BAR\"");37 exe.root_module.addCMacro("BAR", "\"BAR\"");
38 exe.defineCMacro("BAZ",38 exe.root_module.addCMacro("BAZ",
39 \\"\"BAZ\""39 \\"\"BAZ\""
40 );40 );
41 exe.defineCMacro("QUX", "\"Q\" \"UX\"");41 exe.root_module.addCMacro("QUX", "\"Q\" \"UX\"");
42 exe.defineCMacro("QUUX", "\"QU\\\"UX\"");42 exe.root_module.addCMacro("QUUX", "\"QU\\\"UX\"");
4343
44 b.default_step.dependOn(&exe.step);44 b.default_step.dependOn(&exe.step);
4545
test/standalone/stack_iterator/build.zig+1-1
...@@ -72,7 +72,7 @@ pub fn build(b: *std.Build) void {...@@ -72,7 +72,7 @@ pub fn build(b: *std.Build) void {
72 });72 });
7373
74 if (target.result.os.tag == .windows)74 if (target.result.os.tag == .windows)
75 c_shared_lib.defineCMacro("LIB_API", "__declspec(dllexport)");75 c_shared_lib.root_module.addCMacro("LIB_API", "__declspec(dllexport)");
7676
77 c_shared_lib.addCSourceFile(.{77 c_shared_lib.addCSourceFile(.{
78 .file = b.path("shared_lib.c"),78 .file = b.path("shared_lib.c"),
test/tests.zig+1-1
...@@ -1704,7 +1704,7 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {...@@ -1704,7 +1704,7 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
1704 .file = b.path("test/c_abi/cfuncs.c"),1704 .file = b.path("test/c_abi/cfuncs.c"),
1705 .flags = &.{"-std=c99"},1705 .flags = &.{"-std=c99"},
1706 });1706 });
1707 for (c_abi_target.c_defines) |define| test_step.defineCMacro(define, null);1707 for (c_abi_target.c_defines) |define| test_step.root_module.addCMacro(define, "1");
17081708
1709 // This test is intentionally trying to check if the external ABI is1709 // This test is intentionally trying to check if the external ABI is
1710 // done properly. LTO would be a hindrance to this.1710 // done properly. LTO would be a hindrance to this.