aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-03-19 16:54:11 +0100
committerJakub Konka <kubkon@jakubkonka.com>2022-03-22 07:06:39 +0100
commit0376fd09bc9f29ceeb83760e32532923e4fe7f98 (patch)
tree2458f38c54fa77f642dc41658f3cf89c7af506ea /src/main.zig
parent91fd0f42c88f4bea424b5a5c58435a2a98b57a58 (diff)
downloadzig-0376fd09bc9f29ceeb83760e32532923e4fe7f98.tar.gz
zig-0376fd09bc9f29ceeb83760e32532923e4fe7f98.zip
macho: extend CodeSignature to accept entitlements
With this change, we can now bake in entitlements into the binary. Additionally, I see this as the first step towards full code signature support which includes baking in Apple issued certificates for redistribution, etc.
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
index a071ca9a60..115f3748b6 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -433,6 +433,7 @@ const usage_build_generic =
\\ -framework [name] (Darwin) link against framework
\\ -F[dir] (Darwin) add search path for frameworks
\\ -install_name=[value] (Darwin) add dylib's install name
+ \\ --entitlements [path] (Darwin) add path to entitlements file for embedding in code signature
\\ --import-memory (WebAssembly) import memory from the environment
\\ --import-table (WebAssembly) import function table from the host environment
\\ --export-table (WebAssembly) export function table to the host environment
@@ -680,6 +681,7 @@ fn buildOutputType(
var native_darwin_sdk: ?std.zig.system.darwin.DarwinSDK = null;
var install_name: ?[]const u8 = null;
var hash_style: link.HashStyle = .both;
+ var entitlements: ?[]const u8 = null;
// e.g. -m3dnow or -mno-outline-atomics. They correspond to std.Target llvm cpu feature names.
// This array is populated by zig cc frontend and then has to be converted to zig-style
@@ -1036,6 +1038,10 @@ fn buildOutputType(
} else {
enable_link_snapshots = true;
}
+ } else if (mem.eql(u8, arg, "--entitlements")) {
+ entitlements = args_iter.next() orelse {
+ fatal("expected parameter after {s}", .{arg});
+ };
} else if (mem.eql(u8, arg, "-fcompiler-rt")) {
want_compiler_rt = true;
} else if (mem.eql(u8, arg, "-fno-compiler-rt")) {
@@ -2729,6 +2735,7 @@ fn buildOutputType(
.enable_link_snapshots = enable_link_snapshots,
.native_darwin_sdk = native_darwin_sdk,
.install_name = install_name,
+ .entitlements = entitlements,
}) catch |err| switch (err) {
error.LibCUnavailable => {
const target = target_info.target;