@deprecated: add build system support

This commit is contained in:
Loris Cro 2025-02-13 20:58:11 +01:00 committed by Andrew Kelley
parent fff8eff2bd
commit ba7cd8121d
3 changed files with 17 additions and 0 deletions

View file

@ -260,6 +260,10 @@ pub fn main() !void {
graph.incremental = true;
} else if (mem.eql(u8, arg, "-fno-incremental")) {
graph.incremental = false;
} else if (mem.eql(u8, arg, "-fallow-deprecated")) {
graph.allow_deprecated = true;
} else if (mem.eql(u8, arg, "-fno-allow-deprecated")) {
graph.allow_deprecated = false;
} else if (mem.eql(u8, arg, "-fwine")) {
builder.enable_wine = true;
} else if (mem.eql(u8, arg, "-fno-wine")) {
@ -1283,6 +1287,8 @@ fn usage(b: *std.Build, out_stream: anytype) !void {
\\ new Omit cached steps
\\ failures (Default) Only print failed steps
\\ none Do not print the build summary
\\ -fallow-deprecated Allow usage of deprecated code for the entire build graph
\\ -fno-allow-deprecated Disallow usage of deprecated code for the entire build graph
\\ -j<N> Limit concurrent jobs (default is to use all CPU cores)
\\ --maxrss <bytes> Limit memory usage (default is to use available memory)
\\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss

View file

@ -94,6 +94,9 @@ available_deps: AvailableDeps,
release_mode: ReleaseMode,
// True only for the top-level builder.
is_root: bool = false,
pub const ReleaseMode = enum {
off,
any,
@ -118,6 +121,7 @@ pub const Graph = struct {
/// Information about the native target. Computed before build() is invoked.
host: ResolvedTarget,
incremental: ?bool = null,
allow_deprecated: ?bool = null,
random_seed: u32 = 0,
dependency_cache: InitializedDepMap = .empty,
allow_so_scripts: ?bool = null,
@ -304,6 +308,7 @@ pub fn create(
.pkg_hash = "",
.available_deps = available_deps,
.release_mode = .off,
.is_root = true,
};
try b.top_level_steps.put(arena, b.install_tls.step.name, &b.install_tls);
try b.top_level_steps.put(arena, b.uninstall_tls.step.name, &b.uninstall_tls);

View file

@ -25,6 +25,7 @@ stack_check: ?bool,
sanitize_c: ?bool,
sanitize_thread: ?bool,
fuzz: ?bool,
allow_deprecated: ?bool,
code_model: std.builtin.CodeModel,
valgrind: ?bool,
pic: ?bool,
@ -284,6 +285,7 @@ pub fn init(
.owner = owner,
.root_source_file = if (options.root_source_file) |lp| lp.dupe(owner) else null,
.import_table = .{},
.allow_deprecated = owner.graph.allow_deprecated orelse !owner.is_root,
.resolved_target = options.target,
.optimize = options.optimize,
.link_libc = options.link_libc,
@ -557,6 +559,10 @@ pub fn appendZigProcessFlags(
try addFlag(zig_args, m.pic, "-fPIC", "-fno-PIC");
try addFlag(zig_args, m.red_zone, "-mred-zone", "-mno-red-zone");
if (m.root_source_file != null) {
try addFlag(zig_args, m.allow_deprecated, "-fallow-deprecated", "-fno-allow-deprecated");
}
if (m.dwarf_format) |dwarf_format| {
try zig_args.append(switch (dwarf_format) {
.@"32" => "-gdwarf32",