mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
zig cc: fix ambiguity with -MT
In an MSVC context, `-MT` means "Use static run-time" and it is a flag with no parameter. On POSIX it means "Specify name of main file output in depfile" and it is "joined or separate". The former was interfering with the latter. Now, the MT flag is required to be specified with a `/` to disambiguate: `/MT`.
This commit is contained in:
parent
e7f555ca55
commit
f8cc6a1917
@ -95,6 +95,16 @@ pub fn flagpd1(name: []const u8) CliArg {
|
||||
};
|
||||
}
|
||||
|
||||
/// Shortcut function for initializing a `CliArg`
|
||||
pub fn flagpsl(name: []const u8) CliArg {
|
||||
return .{
|
||||
.name = name,
|
||||
.syntax = .flag,
|
||||
.zig_equivalent = .other,
|
||||
.psl = true,
|
||||
};
|
||||
}
|
||||
|
||||
/// Shortcut function for initializing a `CliArg`
|
||||
pub fn joinpd1(name: []const u8) CliArg {
|
||||
return .{
|
||||
|
||||
@ -34,10 +34,38 @@ flagpd1("M"),
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
},
|
||||
flagpd1("MG"),
|
||||
flagpd1("MM"),
|
||||
flagpd1("MMD"),
|
||||
flagpd1("MP"),
|
||||
.{
|
||||
.name = "MG",
|
||||
.syntax = .flag,
|
||||
.zig_equivalent = .dep_file,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
},
|
||||
.{
|
||||
.name = "MM",
|
||||
.syntax = .flag,
|
||||
.zig_equivalent = .dep_file,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
},
|
||||
.{
|
||||
.name = "MMD",
|
||||
.syntax = .flag,
|
||||
.zig_equivalent = .dep_file,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
},
|
||||
.{
|
||||
.name = "MP",
|
||||
.syntax = .flag,
|
||||
.zig_equivalent = .dep_file,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
},
|
||||
.{
|
||||
.name = "MV",
|
||||
.syntax = .flag,
|
||||
@ -517,14 +545,7 @@ sepd1("Zlinker-input"),
|
||||
.pd2 = false,
|
||||
.psl = true,
|
||||
},
|
||||
.{
|
||||
.name = "MT",
|
||||
.syntax = .flag,
|
||||
.zig_equivalent = .other,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = true,
|
||||
},
|
||||
flagpsl("MT"),
|
||||
.{
|
||||
.name = "MTd",
|
||||
.syntax = .flag,
|
||||
@ -5463,9 +5484,30 @@ joinpd1("G="),
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
},
|
||||
jspd1("MJ"),
|
||||
jspd1("MQ"),
|
||||
jspd1("MT"),
|
||||
.{
|
||||
.name = "MJ",
|
||||
.syntax = .joined_or_separate,
|
||||
.zig_equivalent = .dep_file,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
},
|
||||
.{
|
||||
.name = "MQ",
|
||||
.syntax = .joined_or_separate,
|
||||
.zig_equivalent = .dep_file,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
},
|
||||
.{
|
||||
.name = "MT",
|
||||
.syntax = .joined_or_separate,
|
||||
.zig_equivalent = .dep_file,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
},
|
||||
.{
|
||||
.name = "AI",
|
||||
.syntax = .joined_or_separate,
|
||||
@ -5589,7 +5631,7 @@ jspd1("MT"),
|
||||
.{
|
||||
.name = "MP",
|
||||
.syntax = .joined,
|
||||
.zig_equivalent = .other,
|
||||
.zig_equivalent = .dep_file,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = true,
|
||||
|
||||
@ -206,6 +206,34 @@ const known_options = [_]KnownOpt{
|
||||
.name = "MF",
|
||||
.ident = "dep_file",
|
||||
},
|
||||
.{
|
||||
.name = "MT",
|
||||
.ident = "dep_file",
|
||||
},
|
||||
.{
|
||||
.name = "MG",
|
||||
.ident = "dep_file",
|
||||
},
|
||||
.{
|
||||
.name = "MJ",
|
||||
.ident = "dep_file",
|
||||
},
|
||||
.{
|
||||
.name = "MM",
|
||||
.ident = "dep_file",
|
||||
},
|
||||
.{
|
||||
.name = "MMD",
|
||||
.ident = "dep_file",
|
||||
},
|
||||
.{
|
||||
.name = "MP",
|
||||
.ident = "dep_file",
|
||||
},
|
||||
.{
|
||||
.name = "MQ",
|
||||
.ident = "dep_file",
|
||||
},
|
||||
.{
|
||||
.name = "F",
|
||||
.ident = "framework_dir",
|
||||
@ -336,7 +364,12 @@ pub fn main() anyerror!void {
|
||||
}
|
||||
const syntax = objSyntax(obj);
|
||||
|
||||
if (knownOption(name)) |ident| {
|
||||
if (std.mem.eql(u8, name, "MT") and syntax == .flag) {
|
||||
// `-MT foo` is ambiguous because there is also an -MT flag
|
||||
// The canonical way to specify the flag is with `/MT` and so we make this
|
||||
// the only way.
|
||||
try stdout.print("flagpsl(\"{}\"),\n", .{name});
|
||||
} else if (knownOption(name)) |ident| {
|
||||
try stdout.print(
|
||||
\\.{{
|
||||
\\ .name = "{}",
|
||||
@ -350,6 +383,8 @@ pub fn main() anyerror!void {
|
||||
, .{ name, syntax, ident, pd1, pd2, pslash });
|
||||
} else if (pd1 and !pd2 and !pslash and syntax == .flag) {
|
||||
try stdout.print("flagpd1(\"{}\"),\n", .{name});
|
||||
} else if (!pd1 and !pd2 and pslash and syntax == .flag) {
|
||||
try stdout.print("flagpsl(\"{}\"),\n", .{name});
|
||||
} else if (pd1 and !pd2 and !pslash and syntax == .joined) {
|
||||
try stdout.print("joinpd1(\"{}\"),\n", .{name});
|
||||
} else if (pd1 and !pd2 and !pslash and syntax == .joined_or_separate) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user