@@ -167,22 +167,8 @@ function build_langkit_raw() {
167167 sed -i.bak -e ' s/GPR_BUILD/GPR_LIBRARY_TYPE/' ./langkit/libmanage.py
168168 pip install .
169169
170- # On macOS, the full path of gnat.adc is stored in ALI files with case
171- # normalization. Upon re-runs, gprbuild is unable to match the
172- # normalized path with a non-case-normalized real path. This causes
173- # unnecessary recompilations at every run.
174- #
175- # To avoid that, we use the -gnateb flag which tells GNAT to not use
176- # an absolute path for gnat.adc
177170 python manage.py make --no-mypy --generate-auto-dll-dirs \
178- --library-types=relocatable --gargs " -m -v -cargs:ada -gnateb"
179-
180- if [[ $NODE_ARCH_PLATFORM = * darwin* ]]; then
181- find . -name ' *.dylib' -print0 |
182- while IFS= read -r -d ' ' lib; do
183- fix_dylib_rpaths " $lib "
184- done
185- fi
171+ --library-types=relocatable --gargs=" -m -j0 -vh"
186172
187173 # Export the environment needed to use langkit into a file for later
188174 # usage
@@ -230,9 +216,16 @@ function fix_dylib_rpaths() {
230216
231217# Run build_langkit_raw in Alire environment
232218function build_langkit() {
233- # We use 'alr exec' to benefit from Alire setting up GPR_PROJECT_PATH with
234- # all the dependencies.
235- alr exec bash -- -x " $0 " build_langkit_raw
219+ (
220+ # The langkit build will try to import liblktlang at the end. For that
221+ # to work, all dependency libraries must be visible on
222+ # [[DY]LD_LIBRARY_]PATH. This function takes care of that.
223+ add_unpinned_deps_dlls_to_runtime_path
224+
225+ # We use 'alr exec' to benefit from Alire setting up GPR_PROJECT_PATH with
226+ # all the dependencies.
227+ alr exec bash -- -x " $0 " build_langkit_raw
228+ )
236229}
237230
238231# This function adds the paths of DLLs from GCC installation and the Alire deps
@@ -272,22 +265,39 @@ function add_unpinned_deps_dlls_to_runtime_path() {
272265 export PATH=$NEW_PATH " :$PATH "
273266}
274267
268+ # This is a utility function to run a command line within an environment where
269+ # the Langkit 'lkt' library is available.
270+ #
271+ # e.g. lkt_run python -c 'import liblktlang'
272+ #
273+ # Currently it is unused because on macOS spawning processes through a chain of
274+ # lkt_run --> alr --> bash does not allow inheriting DYLD_LIBRARY_PATH and
275+ # doesn't allow the libraries to be found.
276+ function lkt_run() {
277+ python -m langkit.scripts.lkm run --config " $ROOT /subprojects/langkit_support/lkt/langkit.yaml" -- " ${@ } "
278+ }
279+
275280# Build ALS with alire
276281function build_als() {
277282 add_unpinned_deps_dlls_to_runtime_path
278283
279284 # Check that we can use langkit successfully
280285 (
281286 source " $LANGKIT_SETENV "
287+
288+ # Log environments for debugging
289+ python -c ' import os; print("\n".join(f"{k}={v}" for k, v in os.environ.items()))'
290+ alr exec python -- -c ' import os; print("\n".join(f"{k}={v}" for k, v in os.environ.items()))'
291+
282292 # On Windows it is not enough to source the langkit env and unpinned
283293 # deps. The libraries of pinned Alire dependencies (not under
284- # alire/cache/dependencies) must also be made visible.
294+ # alire/cache/dependencies) must also be made visible by calling 'alr exec'
285295 alr exec python -- -c ' import liblktlang; print("Imported liblktlang successfully")'
286296 )
287297
288298 # We use 'alr exec' to benefit from Alire setting up GPR_PROJECT_PATH with
289299 # all the dependencies.
290- LIBRARY_TYPE=static STANDALONE=no alr exec make -- " VERSION=$TAG " all
300+ LIBRARY_TYPE=static STANDALONE=no alr exec make -- " VERSION=$TAG " " GPRBUILD_CARGS=-m -vh " all
291301}
292302
293303function test_als() {
@@ -427,6 +437,10 @@ strip_debug)
427437 strip_debug
428438 ;;
429439
440+ fix_dylib_rpaths)
441+ fix_dylib_rpaths " $2 "
442+ ;;
443+
430444* )
431445 echo " Unrecognized step: $STEP "
432446 exit 1
0 commit comments