Skip to content

Commit 42d2585

Browse files
committed
Prevent unnecessary recompilation on macOS
1 parent 8a59feb commit 42d2585

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

scripts/build_als.sh

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,18 @@ function build_langkit_raw() {
161161
*darwin*)
162162
# Install e3-binarydata which is needed for packaging langkit as a wheel
163163
pip install git+https://github.com/AdaCore/e3-binarydata.git#egg=e3-binarydata
164+
165+
# On macOS, the full path of gnat.adc is stored in ALI files with case
166+
# normalization. Upon re-runs, gprbuild is unable to match the
167+
# normalized path with a non-case-normalized real path. This causes
168+
# unnecessary recompilations at every run.
169+
#
170+
# To avoid that, we use the -gnateb flag which tells GNAT to not use
171+
# an absolute path for gnat.adc
172+
gprbuild_flag="--gargs=-cargs:ada -gnateb"
173+
;;
174+
*)
175+
gprbuild_flag="--gargs="
164176
;;
165177
esac
166178

@@ -183,17 +195,18 @@ function build_langkit_raw() {
183195

184196
# This builds langkit, as well as all the library projects of the dependencies
185197
python manage.py build-langkit-support \
186-
--library-types=relocatable
198+
--library-types=relocatable \
199+
"$gprbuild_flag"
187200
python manage.py install-langkit-support "$prefix_dir" \
188201
--library-types=relocatable
189202

190203
# Next build and install langkit
191-
(cd contrib/lkt && ./manage.py make --library-types=relocatable --disable-all-mains)
204+
(cd contrib/lkt && ./manage.py make --library-types=relocatable --disable-all-mains "$gprbuild_flag")
192205
(cd contrib/lkt && ./manage.py install "$prefix_dir" \
193206
--library-types=relocatable --disable-all-mains)
194207

195208
case "$NODE_ARCH_PLATFORM" in
196-
*win32*|*darwin*)
209+
*win32* | *darwin*)
197210
# on macOS, we want to copy all dependency libraries into the wheel to
198211
# avoid relying on DYLD_LIBRARY_PATH which has security restrictions.
199212

@@ -258,9 +271,22 @@ function set_langkit_usage_env() {
258271
function build_als() {
259272
set_langkit_usage_env
260273

274+
case "$NODE_ARCH_PLATFORM" in
275+
*darwin*)
276+
# On macOS, the full path of gnat.adc is stored in ALI files with case
277+
# normalization. Upon re-runs, gprbuild is unable to match the
278+
# normalized path with a non-case-normalized real path. This causes
279+
# unnecessary recompilations at every run.
280+
#
281+
# To avoid that, we use the -gnateb flag which tells GNAT to not use
282+
# an absolute path for gnat.adc
283+
gprbuild_flag="-cargs:ada -gnateb"
284+
;;
285+
esac
286+
261287
# We use 'alr exec' to benefit from Alire setting up GPR_PROJECT_PATH with
262288
# all the dependencies.
263-
LIBRARY_TYPE=static STANDALONE=no alr exec make -- "VERSION=$TAG" all
289+
LIBRARY_TYPE=static STANDALONE=no GPRBUILD_EXTRA="$gprbuild_flag" alr exec make -- "VERSION=$TAG" all
264290
}
265291

266292
function test_als() {

0 commit comments

Comments
 (0)