arena is used for temporary -D argument strings.
The arena should be kept alive at least as long as argv.
pub fn appendAroArgs(arena: Allocator, argv: *std.ArrayList([]const u8), options: cli.Options, system_include_paths: []const []const u8, include_env_value: ?[]const u8) !void
pub fn appendAroArgs(arena: Allocator, argv: *std.ArrayList([]const u8), options: cli.Options, system_include_paths: []const []const u8, include_env_value: ?[]const u8) !void {
try argv.appendSlice(arena, &.{
"-E",
"--comments",
"-fuse-line-directives",
"-fgnuc-version=4.2.1",
"--target=x86_64-windows-msvc",
"--emulate=msvc",
"-nostdinc",
"-DRC_INVOKED",
"-D_WIN32", // undocumented, but defined by default
});
for (options.extra_include_paths.items) |extra_include_path| {
try argv.append(arena, "-I");
try argv.append(arena, extra_include_path);
}
for (system_include_paths) |include_path| {
try argv.append(arena, "-isystem");
try argv.append(arena, include_path);
}
if (!options.ignore_include_env_var) {
const INCLUDE = include_env_value orelse "";
// The only precedence here is llvm-rc which also uses the platform-specific
// delimiter. There's no precedence set by `rc.exe` since it's Windows-only.
const delimiter = switch (builtin.os.tag) {
.windows => ';',
else => ':',
};
var it = std.mem.tokenizeScalar(u8, INCLUDE, delimiter);
while (it.next()) |include_path| {
try argv.append(arena, "-isystem");
try argv.append(arena, include_path);
}
}
var symbol_it = options.symbols.iterator();
while (symbol_it.next()) |entry| {
switch (entry.value_ptr.*) {
.define => |value| {
try argv.append(arena, "-D");
const define_arg = try std.fmt.allocPrint(arena, "{s}={s}", .{ entry.key_ptr.*, value });
try argv.append(arena, define_arg);
},
.undefine => {
try argv.append(arena, "-U");
try argv.append(arena, entry.key_ptr.*);
},
}
}
}