@@ -64,6 +64,9 @@ branch_gnatformat=edge
6464branch_libgpr2=main
6565branch_prettier_ada=main
6666
67+ # Repository URLs can be overriden (e.g. to personal forks for experimentation)
68+ # url_langkit_support=https://github.com/<my-github-login>/langkit.git
69+
6770# Set `prod` build mode
6871# #######################
6972# for adasat,gnatformat,lal,langkit,lal_refactor,laltools,markdown,spawn
@@ -111,7 +114,10 @@ function pin_crates() {
111114 commit=$( grep " ^${repo:- $crate } =" deps.txt | sed -e ' s/.*=//' )
112115 fi
113116
114- URL=" https://github.com/AdaCore/${repo:- $crate } .git"
117+ url_var=url_$crate
118+ url_override=${! url_var}
119+ URL=${url_override:- " https://github.com/AdaCore/${repo:- $crate } .git" }
120+
115121 if [ ! -d " subprojects/$crate " ]; then
116122 # If the checkout doesn't exist, clone
117123 git clone " $URL " " subprojects/$crate "
@@ -161,22 +167,8 @@ function build_langkit_raw() {
161167 sed -i.bak -e ' s/GPR_BUILD/GPR_LIBRARY_TYPE/' ./langkit/libmanage.py
162168 pip install .
163169
164- # On macOS, the full path of gnat.adc is stored in ALI files with case
165- # normalization. Upon re-runs, gprbuild is unable to match the
166- # normalized path with a non-case-normalized real path. This causes
167- # unnecessary recompilations at every run.
168- #
169- # To avoid that, we use the -gnateb flag which tells GNAT to not use
170- # an absolute path for gnat.adc
171170 python manage.py make --no-mypy --generate-auto-dll-dirs \
172- --library-types=relocatable --gargs " -m -v -cargs:ada -gnateb"
173-
174- if [[ $NODE_ARCH_PLATFORM = * darwin* ]]; then
175- find . -name ' *.dylib' -print0 |
176- while IFS= read -r -d ' ' lib; do
177- fix_dylib_rpaths " $lib "
178- done
179- fi
171+ --library-types=relocatable --gargs=" -m -j0 -vh"
180172
181173 # Export the environment needed to use langkit into a file for later
182174 # usage
@@ -185,7 +177,14 @@ function build_langkit_raw() {
185177 if [[ $NODE_ARCH_PLATFORM == " x64/win32" ]]; then
186178 # Fix setenv.sh to be bash script for MSYS2 by replacing
187179 # 1) C:\ -> /C/ 2) '\' -> '/' and ';' -> ':' 3) ": export" -> "; export"
188- sed -i -e ' s#\([A-Z]\):\\#/\1/#g' -e ' y#\\;#/:#' -e ' s/: export /; export /' " $LANGKIT_SETENV "
180+ #
181+ # Only do this on the PATH environment variable which MSYS2/Cygwin
182+ # automatically converts to Windows paths. Other variables such as
183+ # PYTHONPATH must be left in Windows format to be usable by Python
184+ # subprocresses.
185+ #
186+ # See https://www.msys2.org/docs/filesystem-paths/
187+ sed -i -e ' /^PATH=/s#\([A-Z]\):\\#/\1/#g' -e ' /^PATH=/y#\\;#/:#' -e ' /^PATH=/s/: export /; export /' " $LANGKIT_SETENV "
189188 fi
190189
191190 cat " $LANGKIT_SETENV "
@@ -224,9 +223,16 @@ function fix_dylib_rpaths() {
224223
225224# Run build_langkit_raw in Alire environment
226225function build_langkit() {
227- # We use 'alr exec' to benefit from Alire setting up GPR_PROJECT_PATH with
228- # all the dependencies.
229- alr exec bash -- -x " $0 " build_langkit_raw
226+ (
227+ # The langkit build will try to import liblktlang at the end. For that
228+ # to work, all dependency libraries must be visible on
229+ # [[DY]LD_LIBRARY_]PATH. This function takes care of that.
230+ add_unpinned_deps_dlls_to_runtime_path
231+
232+ # We use 'alr exec' to benefit from Alire setting up GPR_PROJECT_PATH with
233+ # all the dependencies.
234+ alr exec bash -- -x " $0 " build_langkit_raw
235+ )
230236}
231237
232238# This function adds the paths of DLLs from GCC installation and the Alire deps
@@ -266,22 +272,39 @@ function add_unpinned_deps_dlls_to_runtime_path() {
266272 export PATH=$NEW_PATH " :$PATH "
267273}
268274
275+ # This is a utility function to run a command line within an environment where
276+ # the Langkit 'lkt' library is available.
277+ #
278+ # e.g. lkt_run python -c 'import liblktlang'
279+ #
280+ # Currently it is unused because on macOS spawning processes through a chain of
281+ # lkt_run --> alr --> bash does not allow inheriting DYLD_LIBRARY_PATH and
282+ # doesn't allow the libraries to be found.
283+ function lkt_run() {
284+ python -m langkit.scripts.lkm run --config " $ROOT /subprojects/langkit_support/lkt/langkit.yaml" -- " ${@ } "
285+ }
286+
269287# Build ALS with alire
270288function build_als() {
271289 add_unpinned_deps_dlls_to_runtime_path
272290
273291 # Check that we can use langkit successfully
274292 (
275293 source " $LANGKIT_SETENV "
294+
295+ # Log environments for debugging
296+ python -c ' import os; print("\n".join(f"{k}={v}" for k, v in os.environ.items()))'
297+ alr exec python -- -c ' import os; print("\n".join(f"{k}={v}" for k, v in os.environ.items()))'
298+
276299 # On Windows it is not enough to source the langkit env and unpinned
277300 # deps. The libraries of pinned Alire dependencies (not under
278- # alire/cache/dependencies) must also be made visible.
301+ # alire/cache/dependencies) must also be made visible by calling 'alr exec'
279302 alr exec python -- -c ' import liblktlang; print("Imported liblktlang successfully")'
280303 )
281304
282305 # We use 'alr exec' to benefit from Alire setting up GPR_PROJECT_PATH with
283306 # all the dependencies.
284- LIBRARY_TYPE=static STANDALONE=no alr exec make -- " VERSION=$TAG " all
307+ LIBRARY_TYPE=static STANDALONE=no alr exec make -- " VERSION=$TAG " " GPRBUILD_CARGS=-m -vh " all
285308}
286309
287310function test_als() {
@@ -421,6 +444,10 @@ strip_debug)
421444 strip_debug
422445 ;;
423446
447+ fix_dylib_rpaths)
448+ fix_dylib_rpaths " $2 "
449+ ;;
450+
424451* )
425452 echo " Unrecognized step: $STEP "
426453 exit 1
0 commit comments