Skip to content

Commit b58fd8b

Browse files
authored
allow passing --project to juliac.jl (#59160)
My main motivation here is that it allows me to `alias juliac=julia /path/to/contrib/juliac.jl` and then specify `juliac --proj`.
1 parent 1a1270d commit b58fd8b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

contrib/juliac/juliac.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ end
8686
# arguments to forward to julia compilation process
8787
julia_args = []
8888
enable_trim::Bool = false
89+
project::String = "--project=$(Base.active_project())"
8990

9091
let i = 1
9192
while i <= length(ARGS)
@@ -107,6 +108,8 @@ let i = 1
107108
push!(julia_args, arg) # forwarded arg
108109
elseif arg == "--experimental"
109110
push!(julia_args, arg) # forwarded arg
111+
elseif startswith(arg, "--proj")
112+
global project = arg
110113
else
111114
if arg[1] == '-' || !isnothing(file)
112115
println("Unexpected argument `$arg`")
@@ -150,7 +153,7 @@ bc_path = joinpath(tmpdir, "img-bc.a")
150153
function precompile_env()
151154
# Pre-compile the environment
152155
# (otherwise obscure error messages will occur)
153-
cmd = addenv(`$julia_cmd --project=$(Base.active_project()) -e "using Pkg; Pkg.precompile()"`)
156+
cmd = addenv(`$julia_cmd $project -e "using Pkg; Pkg.precompile()"`)
154157
verbose && println("Running: $cmd")
155158
if !success(pipeline(cmd; stdout, stderr))
156159
println(stderr, "\nError encountered during pre-compilation of environment.")
@@ -168,7 +171,7 @@ function compile_products(enable_trim::Bool)
168171
end
169172

170173
# Compile the Julia code
171-
cmd = addenv(`$julia_cmd_target --project=$(Base.active_project()) --output-o $img_path --output-incremental=no $strip_args $julia_args $(joinpath(@__DIR__,"juliac-buildscript.jl")) $absfile $output_type $add_ccallables`, "OPENBLAS_NUM_THREADS" => 1, "JULIA_NUM_THREADS" => 1)
174+
cmd = addenv(`$julia_cmd_target $project --output-o $img_path --output-incremental=no $strip_args $julia_args $(joinpath(@__DIR__,"juliac-buildscript.jl")) $absfile $output_type $add_ccallables`, "OPENBLAS_NUM_THREADS" => 1, "JULIA_NUM_THREADS" => 1)
172175
verbose && println("Running: $cmd")
173176
if !success(pipeline(cmd; stdout, stderr))
174177
println(stderr, "\nFailed to compile $file")

0 commit comments

Comments
 (0)