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,
8181/// that contains the path `aarch64-linux-gnu/lib/ld-linux-aarch64.so.1`.
8282glibc_runtimes_dir: ?[]const u8 = null,
8383
84/// Deprecated. Use `b.graph.host`.
85host: ResolvedTarget,
86
8784dep_prefix: []const u8 = "",
8885
8986modules: std.StringArrayHashMap(*Module),
......@@ -301,7 +298,6 @@ pub fn create(
301298 },
302299 .install_path = undefined,
303300 .args = null,
304 .host = graph.host,
305301 .modules = .init(arena),
306302 .named_writefiles = .init(arena),
307303 .named_lazy_paths = .init(arena),
......@@ -393,7 +389,6 @@ fn createChildOnly(
393389 .enable_wasmtime = parent.enable_wasmtime,
394390 .enable_wine = parent.enable_wine,
395391 .glibc_runtimes_dir = parent.glibc_runtimes_dir,
396 .host = parent.host,
397392 .dep_prefix = parent.fmt("{s}{s}.", .{ parent.dep_prefix, dep_name }),
398393 .modules = .init(allocator),
399394 .named_writefiles = .init(allocator),
lib/std/Build/Step/Compile.zig-18
......@@ -583,9 +583,6 @@ pub fn checkObject(compile: *Compile) *Step.CheckObject {
583583 return Step.CheckObject.create(compile.step.owner, compile.getEmittedBin(), compile.rootModuleTarget().ofmt);
584584}
585585
586/// deprecated: use `setLinkerScript`
587pub const setLinkerScriptPath = setLinkerScript;
588
589586pub fn setLinkerScript(compile: *Compile, source: LazyPath) void {
590587 const b = compile.step.owner;
591588 compile.linker_script = source.dupe(b);
......@@ -675,11 +672,6 @@ pub fn linkLibCpp(compile: *Compile) void {
675672 compile.root_module.link_libcpp = true;
676673}
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
683675const PkgConfigResult = struct {
684676 cflags: []const []const u8,
685677 libs: []const []const u8,
......@@ -805,16 +797,6 @@ pub fn linkFramework(c: *Compile, name: []const u8) void {
805797 c.root_module.linkFramework(name, .{});
806798}
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
818800/// Handy when you have many C/C++ source files and want them all to have the same flags.
819801pub fn addCSourceFiles(compile: *Compile, options: Module.AddCSourceFilesOptions) void {
820802 compile.root_module.addCSourceFiles(options);
lib/std/Build/Step/ObjCopy.zig-3
......@@ -135,9 +135,6 @@ pub fn create(
135135 return objcopy;
136136}
137137
138/// deprecated: use getOutput
139pub const getOutputSource = getOutput;
140
141138pub fn getOutput(objcopy: *const ObjCopy) std.Build.LazyPath {
142139 return .{ .generated = .{ .file = &objcopy.output_file } };
143140}
lib/std/Build/Step/Options.zig-8
......@@ -390,20 +390,12 @@ pub fn addOptionPath(
390390 path.addStepDependencies(&options.step);
391391}
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
398393pub fn createModule(options: *Options) *std.Build.Module {
399394 return options.step.owner.createModule(.{
400395 .root_source_file = options.getOutput(),
401396 });
402397}
403398
404/// deprecated: use `getOutput`
405pub const getSource = getOutput;
406
407399/// Returns the main artifact of this Build Step which is a Zig source file
408400/// generated from the key-value pairs of the Options.
409401pub fn getOutput(options: *Options) LazyPath {
lib/std/Build/Step/Run.zig-13
......@@ -43,9 +43,6 @@ stdio: StdIo,
4343/// It should be only set using `setStdIn`.
4444stdin: StdIn,
4545
46/// Deprecated: use `addFileInput`
47extra_file_dependencies: []const []const u8,
48
4946/// Additional input files that, when modified, indicate that the Run step
5047/// should be re-executed.
5148/// 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 {
178175 .disable_zig_progress = false,
179176 .stdio = .infer_from_args,
180177 .stdin = .none,
181 .extra_file_dependencies = &.{},
182178 .file_inputs = .{},
183179 .rename_step_with_output_arg = true,
184180 .skip_foreign_checks = false,
......@@ -364,16 +360,10 @@ pub fn addPrefixedOutputDirectoryArg(
364360 return .{ .generated = .{ .file = &output.generated_file } };
365361}
366362
367/// deprecated: use `addDirectoryArg`
368pub const addDirectorySourceArg = addDirectoryArg;
369
370363pub fn addDirectoryArg(run: *Run, directory_source: std.Build.LazyPath) void {
371364 run.addPrefixedDirectoryArg("", directory_source);
372365}
373366
374// deprecated: use `addPrefixedDirectoryArg`
375pub const addPrefixedDirectorySourceArg = addPrefixedDirectoryArg;
376
377367pub fn addPrefixedDirectoryArg(run: *Run, prefix: []const u8, directory_source: std.Build.LazyPath) void {
378368 const b = run.step.owner;
379369
......@@ -698,9 +688,6 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
698688
699689 hashStdIo(&man.hash, run.stdio);
700690
701 for (run.extra_file_dependencies) |file_path| {
702 _ = try man.addFile(b.pathFromRoot(file_path), null);
703 }
704691 for (run.file_inputs.items) |lazy_path| {
705692 _ = try man.addFile(lazy_path.getPath2(b, step), null);
706693 }
test/standalone/extern/build.zig+1-1
......@@ -18,7 +18,7 @@ pub fn build(b: *std.Build) void {
1818 .optimize = optimize,
1919 .link_libc = true,
2020 });
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)");
2222 shared.addCSourceFile(.{ .file = b.path("shared.c"), .flags = &.{} });
2323 const test_exe = b.addTest(.{
2424 .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 {
3030
3131 var i: i32 = 0;
3232 while (i < 1000) : (i += 1) {
33 exe.defineCMacro("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
33 exe.root_module.addCMacro("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
3434 }
3535
36 exe.defineCMacro("FOO", "42");
37 exe.defineCMacro("BAR", "\"BAR\"");
38 exe.defineCMacro("BAZ",
36 exe.root_module.addCMacro("FOO", "42");
37 exe.root_module.addCMacro("BAR", "\"BAR\"");
38 exe.root_module.addCMacro("BAZ",
3939 \\"\"BAZ\""
4040 );
41 exe.defineCMacro("QUX", "\"Q\" \"UX\"");
42 exe.defineCMacro("QUUX", "\"QU\\\"UX\"");
41 exe.root_module.addCMacro("QUX", "\"Q\" \"UX\"");
42 exe.root_module.addCMacro("QUUX", "\"QU\\\"UX\"");
4343
4444 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 {
7272 });
7373
7474 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
7777 c_shared_lib.addCSourceFile(.{
7878 .file = b.path("shared_lib.c"),
test/tests.zig+1-1
......@@ -1704,7 +1704,7 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
17041704 .file = b.path("test/c_abi/cfuncs.c"),
17051705 .flags = &.{"-std=c99"},
17061706 });
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
17091709 // This test is intentionally trying to check if the external ABI is
17101710 // done properly. LTO would be a hindrance to this.