2727# --output-<type> : One of: exe | lib | sysimage | o | bc. Controls entrypoint setup.
2828# --compile-ccallable : Export ccallable entrypoints (for shared libraries).
2929# --use-loaded-libs : Enable Libdl.dlopen override to reuse existing loads.
30- source_path, output_type, add_ccallables, use_loaded_libs = let
30+ # --scripts-dir <path> : Directory containing build helper scripts.
31+ source_path, output_type, add_ccallables, use_loaded_libs, scripts_dir = let
3132 source_path = " "
3233 output_type = " "
3334 add_ccallables = false
3435 use_loaded_libs = false
36+ scripts_dir = abspath (dirname (PROGRAM_FILE ))
3537 it = Iterators. Stateful (ARGS )
3638 for arg in it
3739 if startswith (arg, " --source=" )
@@ -40,6 +42,12 @@ source_path, output_type, add_ccallables, use_loaded_libs = let
4042 nextarg = popfirst! (it)
4143 nextarg === nothing && error (" Missing value for --source" )
4244 source_path = nextarg
45+ elseif startswith (arg, " --scripts-dir=" )
46+ scripts_dir = split (arg, " =" , limit= 2 )[2 ]
47+ elseif arg == " --scripts-dir"
48+ nextarg = popfirst! (it)
49+ nextarg === nothing && error (" Missing value for --scripts-dir" )
50+ scripts_dir = nextarg
4351 elseif arg == " --output-exe" || arg == " --output-lib" || arg == " --output-sysimage" || arg == " --output-o" || arg == " --output-bc"
4452 output_type = arg
4553 elseif arg == " --compile-ccallable" || arg == " --add-ccallables"
@@ -49,7 +57,7 @@ source_path, output_type, add_ccallables, use_loaded_libs = let
4957 end
5058 end
5159 source_path == " " && error (" Missing required --source <path>" )
52- (source_path, output_type, add_ccallables, use_loaded_libs)
60+ (source_path, output_type, add_ccallables, use_loaded_libs, scripts_dir )
5361end
5462
5563# Load user code
@@ -135,13 +143,13 @@ end
135143Core. Compiler. _verify_trim_world_age[] = Base. get_world_counter ()
136144
137145if Base. JLOptions (). trim != 0
138- include (joinpath (@__DIR__ , " juliac-trim-base.jl" ))
139- include (joinpath (@__DIR__ , " juliac-trim-stdlib.jl" ))
146+ include (joinpath (scripts_dir , " juliac-trim-base.jl" ))
147+ include (joinpath (scripts_dir , " juliac-trim-stdlib.jl" ))
140148end
141149
142150# Optionally install Libdl overrides to reuse existing loaded libs on absolute dlopen
143151if use_loaded_libs
144- include (joinpath (@__DIR__ , " juliac-libdl-overrides.jl" ))
152+ include (joinpath (scripts_dir , " juliac-libdl-overrides.jl" ))
145153end
146154
147155empty! (Core. ARGS )
0 commit comments