aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-09-26 22:37:19 -0700
committerAndrew Kelley <andrew@ziglang.org>2020-09-26 22:37:19 -0700
commita9082b4ec51debdbffc20b56e9b37cb82dd04750 (patch)
tree251eaeee7562ee64757b3a171cd327c4d23a116c /src/main.zig
parent4b403c7eaca50815cae8f2ddde19b4fb476ae8ca (diff)
downloadzig-a9082b4ec51debdbffc20b56e9b37cb82dd04750.tar.gz
zig-a9082b4ec51debdbffc20b56e9b37cb82dd04750.zip
stage2: add CLI support for --subsystem
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
index 31eaf5d8ae..d96cfaf526 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -273,6 +273,7 @@ const usage_build_generic =
\\ --eh-frame-hdr Enable C++ exception handling by passing --eh-frame-hdr to linker
\\ -dynamic Force output to be dynamically linked
\\ -static Force output to be statically linked
+ \\ --subsystem [subsystem] (windows) /SUBSYSTEM:<subsystem> to the linker\n"
\\
\\Test Options:
\\ --test-filter [text] Skip tests that do not match filter
@@ -439,6 +440,7 @@ fn buildOutputType(
var override_lib_dir: ?[]const u8 = null;
var main_pkg_path: ?[]const u8 = null;
var clang_preprocessor_mode: Compilation.ClangPreprocessorMode = .no;
+ var subsystem: ?std.Target.SubSystem = null;
var system_libs = std.ArrayList([]const u8).init(gpa);
defer system_libs.deinit();
@@ -575,6 +577,39 @@ fn buildOutputType(
} else {
fatal("expected [auto|on|off] after --color, found '{}'", .{next_arg});
}
+ } else if (mem.eql(u8, arg, "--subsystem")) {
+ if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
+ i += 1;
+ if (mem.eql(u8, args[i], "console")) {
+ subsystem = .Console;
+ } else if (mem.eql(u8, args[i], "windows")) {
+ subsystem = .Windows;
+ } else if (mem.eql(u8, args[i], "posix")) {
+ subsystem = .Posix;
+ } else if (mem.eql(u8, args[i], "native")) {
+ subsystem = .Native;
+ } else if (mem.eql(u8, args[i], "efi_application")) {
+ subsystem = .EfiApplication;
+ } else if (mem.eql(u8, args[i], "efi_boot_service_driver")) {
+ subsystem = .EfiBootServiceDriver;
+ } else if (mem.eql(u8, args[i], "efi_rom")) {
+ subsystem = .EfiRom;
+ } else if (mem.eql(u8, args[i], "efi_runtime_driver")) {
+ subsystem = .EfiRuntimeDriver;
+ } else {
+ fatal("invalid: --subsystem: '{s}'. Options are:\n{s}", .{
+ args[i],
+ \\ console
+ \\ windows
+ \\ posix
+ \\ native
+ \\ efi_application
+ \\ efi_boot_service_driver
+ \\ efi_rom
+ \\ efi_runtime_driver
+ \\
+ });
+ }
} else if (mem.eql(u8, arg, "-O")) {
if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
i += 1;
@@ -1539,6 +1574,7 @@ fn buildOutputType(
.test_filter = test_filter,
.test_name_prefix = test_name_prefix,
.disable_lld_caching = !have_enable_cache,
+ .subsystem = subsystem,
}) catch |err| {
fatal("unable to create compilation: {}", .{@errorName(err)});
};