Skip to content

Commit 01f2ac0

Browse files
chore: embed Info.plist in dylib (#15907)
Relates to coder/coder-desktop-macos#2
1 parent 91875c2 commit 01f2ac0

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

scripts/build_go.sh

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,25 @@ if [[ "$agpl" == 1 ]]; then
142142
# a flag to control AGPL vs. enterprise behavior.
143143
ldflags+=(-X "'github.com/coder/coder/v2/buildinfo.agpl=true'")
144144
fi
145+
cgo=0
146+
if [[ "$dylib" == 1 ]]; then
147+
if [[ "$os" != "darwin" ]]; then
148+
error "dylib builds are not supported on $os"
149+
fi
150+
cgo=1
151+
build_args+=("-buildmode=c-shared")
152+
SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
153+
export SDKROOT
154+
bin_ident="com.coder.Coder-Desktop.VPN.dylib"
155+
156+
plist_file=$(mktemp)
157+
trap 'rm -f "$plist_file"' EXIT
158+
# CFBundleShortVersionString must be in the format /[0-9]+.[0-9]+.[0-9]+/
159+
# CFBundleVersion can be in any format
160+
BUNDLE_IDENTIFIER="$bin_ident" VERSION_STRING="$version" SHORT_VERSION_STRING=$(echo "$version" | grep -oE '^[0-9]+\.[0-9]+\.[0-9]+') \
161+
execrelative envsubst <"$(realpath ./vpn/dylib/info.plist.tmpl)" >"$plist_file"
162+
ldflags+=("-extldflags '-sectcreate __TEXT __info_plist $plist_file'")
163+
fi
145164
build_args+=(-ldflags "${ldflags[*]}")
146165

147166
# Disable optimizations if building a binary for debuggers.
@@ -175,18 +194,8 @@ cmd_path="./enterprise/cmd/coder"
175194
if [[ "$agpl" == 1 ]]; then
176195
cmd_path="./cmd/coder"
177196
fi
178-
179-
cgo=0
180197
if [[ "$dylib" == 1 ]]; then
181-
if [[ "$os" != "darwin" ]]; then
182-
error "dylib builds are not supported on $os"
183-
fi
184-
cgo=1
185198
cmd_path="./vpn/dylib/lib.go"
186-
build_args+=("-buildmode=c-shared")
187-
SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
188-
export SDKROOT
189-
bin_ident="com.coder.vpn"
190199
fi
191200

192201
goexp=""

scripts/sign_darwin.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# certificate.
1010
#
1111
# For the Coder CLI, the binary_identifier should be "com.coder.cli".
12-
# For the CoderVPN `.dylib`, the binary_identifier should be "com.coder.vpn".
12+
# For the CoderVPN `.dylib`, the binary_identifier should be "com.coder.Coder-Desktop.VPN.dylib".
1313
#
1414
# You can check if a binary is signed by running the following command on a Mac:
1515
# codesign -dvv path/to/binary

vpn/dylib/info.plist.tmpl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleName</key>
6+
<string>CoderVPN</string>
7+
<key>CFBundleIdentifier</key>
8+
<string>${BUNDLE_IDENTIFIER}</string>
9+
<key>CFBundleVersion</key>
10+
<string>${VERSION_STRING}</string>
11+
<key>CFBundleShortVersionString</key>
12+
<string>${SHORT_VERSION_STRING}</string>
13+
</dict>
14+
</plist>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy