@@ -142,6 +142,25 @@ if [[ "$agpl" == 1 ]]; then
142
142
# a flag to control AGPL vs. enterprise behavior.
143
143
ldflags+=(-X " 'github.com/coder/coder/v2/buildinfo.agpl=true'" )
144
144
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
145
164
build_args+=(-ldflags " ${ldflags[*]} " )
146
165
147
166
# Disable optimizations if building a binary for debuggers.
@@ -175,18 +194,8 @@ cmd_path="./enterprise/cmd/coder"
175
194
if [[ " $agpl " == 1 ]]; then
176
195
cmd_path=" ./cmd/coder"
177
196
fi
178
-
179
- cgo=0
180
197
if [[ " $dylib " == 1 ]]; then
181
- if [[ " $os " != " darwin" ]]; then
182
- error " dylib builds are not supported on $os "
183
- fi
184
- cgo=1
185
198
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"
190
199
fi
191
200
192
201
goexp=" "
0 commit comments