mirror of
https://github.com/ziglang/zig.git
synced 2025-12-24 23:23:07 +00:00
@deprecated: remove per-module flag in Build
This implementation looks at the builder of each module in the build graph instead of storing a boolean for each module.
This commit is contained in:
parent
e3da2852f4
commit
25790e95f1
@ -94,7 +94,7 @@ available_deps: AvailableDeps,
|
|||||||
|
|
||||||
release_mode: ReleaseMode,
|
release_mode: ReleaseMode,
|
||||||
|
|
||||||
// True only for the top-level builder.
|
/// `true` only for the root `Build`; `false` for any `Build` belonging to a dependency.
|
||||||
is_root: bool = false,
|
is_root: bool = false,
|
||||||
|
|
||||||
pub const ReleaseMode = enum {
|
pub const ReleaseMode = enum {
|
||||||
|
|||||||
@ -25,7 +25,6 @@ stack_check: ?bool,
|
|||||||
sanitize_c: ?bool,
|
sanitize_c: ?bool,
|
||||||
sanitize_thread: ?bool,
|
sanitize_thread: ?bool,
|
||||||
fuzz: ?bool,
|
fuzz: ?bool,
|
||||||
allow_deprecated: ?bool,
|
|
||||||
code_model: std.builtin.CodeModel,
|
code_model: std.builtin.CodeModel,
|
||||||
valgrind: ?bool,
|
valgrind: ?bool,
|
||||||
pic: ?bool,
|
pic: ?bool,
|
||||||
@ -285,7 +284,6 @@ pub fn init(
|
|||||||
.owner = owner,
|
.owner = owner,
|
||||||
.root_source_file = if (options.root_source_file) |lp| lp.dupe(owner) else null,
|
.root_source_file = if (options.root_source_file) |lp| lp.dupe(owner) else null,
|
||||||
.import_table = .{},
|
.import_table = .{},
|
||||||
.allow_deprecated = owner.graph.allow_deprecated orelse !owner.is_root,
|
|
||||||
.resolved_target = options.target,
|
.resolved_target = options.target,
|
||||||
.optimize = options.optimize,
|
.optimize = options.optimize,
|
||||||
.link_libc = options.link_libc,
|
.link_libc = options.link_libc,
|
||||||
@ -560,7 +558,8 @@ pub fn appendZigProcessFlags(
|
|||||||
try addFlag(zig_args, m.red_zone, "-mred-zone", "-mno-red-zone");
|
try addFlag(zig_args, m.red_zone, "-mred-zone", "-mno-red-zone");
|
||||||
|
|
||||||
if (m.root_source_file != null) {
|
if (m.root_source_file != null) {
|
||||||
try addFlag(zig_args, m.allow_deprecated, "-fallow-deprecated", "-fno-allow-deprecated");
|
const allow_deprecated = m.owner.graph.allow_deprecated orelse !m.owner.is_root;
|
||||||
|
try addFlag(zig_args, allow_deprecated, "-fallow-deprecated", "-fno-allow-deprecated");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m.dwarf_format) |dwarf_format| {
|
if (m.dwarf_format) |dwarf_format| {
|
||||||
|
|||||||
@ -4313,7 +4313,6 @@ fn findTrackableInner(
|
|||||||
.value_placeholder => unreachable,
|
.value_placeholder => unreachable,
|
||||||
|
|
||||||
// Once again, we start with the boring tags.
|
// Once again, we start with the boring tags.
|
||||||
.deprecated,
|
|
||||||
.this,
|
.this,
|
||||||
.ret_addr,
|
.ret_addr,
|
||||||
.builtin_src,
|
.builtin_src,
|
||||||
@ -4367,6 +4366,7 @@ fn findTrackableInner(
|
|||||||
.tuple_decl,
|
.tuple_decl,
|
||||||
.dbg_empty_stmt,
|
.dbg_empty_stmt,
|
||||||
.astgen_error,
|
.astgen_error,
|
||||||
|
.deprecated,
|
||||||
=> return,
|
=> return,
|
||||||
|
|
||||||
// `@TypeOf` has a body.
|
// `@TypeOf` has a body.
|
||||||
|
|||||||
9
test/cases/compile_errors/deprecated.zig
Normal file
9
test/cases/compile_errors/deprecated.zig
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
const bad = @deprecated(42);
|
||||||
|
|
||||||
|
pub export fn foo() usize {
|
||||||
|
return bad;
|
||||||
|
}
|
||||||
|
|
||||||
|
// error
|
||||||
|
//
|
||||||
|
// :1:13: error: found deprecated code
|
||||||
@ -250,18 +250,4 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void {
|
|||||||
":1:5: error: expected expression, found 'invalid token'",
|
":1:5: error: expected expression, found 'invalid token'",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
const case = ctx.obj("usage of deprecated code", b.graph.host);
|
|
||||||
|
|
||||||
case.addError(
|
|
||||||
\\const bad = @deprecated(42);
|
|
||||||
\\
|
|
||||||
\\pub export fn foo() usize {
|
|
||||||
\\ return bad;
|
|
||||||
\\}
|
|
||||||
, &[_][]const u8{
|
|
||||||
":1:13: error: found deprecated code",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1199,13 +1199,13 @@ pub fn addCliTests(b: *std.Build) *Step {
|
|||||||
\\}
|
\\}
|
||||||
;
|
;
|
||||||
|
|
||||||
var src_dir = std.fs.cwd().makeOpenPath(b.pathJoin(&.{ tmp_path, "src" }), .{}) catch unreachable;
|
var src_dir = std.fs.cwd().makeOpenPath(b.pathJoin(&.{ tmp_path, "src" }), .{}) catch @panic("unable to create tmp path");
|
||||||
defer src_dir.close();
|
defer src_dir.close();
|
||||||
|
|
||||||
var main = src_dir.createFile("main.zig", .{}) catch unreachable;
|
var main = src_dir.createFile("main.zig", .{}) catch @panic("unable to create main.zig");
|
||||||
defer main.close();
|
defer main.close();
|
||||||
|
|
||||||
main.writeAll(new_main_src) catch unreachable;
|
main.writeAll(new_main_src) catch @panic("unable to write to main.zig");
|
||||||
}
|
}
|
||||||
|
|
||||||
const init_exe = b.addSystemCommand(&.{ b.graph.zig_exe, "init" });
|
const init_exe = b.addSystemCommand(&.{ b.graph.zig_exe, "init" });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user