@@ -19,7 +19,7 @@ function main(args)
1919 " cprog"
2020 arg_type = String
2121 default = nothing
22- help = " C program to compile (if not provided, a minimal standard program is used)"
22+ help = " C program to compile (required only when building an executable; if not provided a minimal standard program is used)"
2323 " builddir"
2424 arg_type = String
2525 default = " builddir"
@@ -33,6 +33,11 @@ function main(args)
3333 " --clean" , " -c"
3434 action = :store_true
3535 help = " delete builddir"
36+ " --sysimage" , " -J"
37+ arg_type = String
38+ default = nothing
39+ metavar = " <file>"
40+ help = " start up with the given system image file"
3641 " --cpu-target" , " -C"
3742 arg_type = String
3843 default = nothing
@@ -111,6 +116,7 @@ function main(args)
111116 parsed_args[" verbose" ],
112117 parsed_args[" quiet" ],
113118 parsed_args[" clean" ],
119+ parsed_args[" sysimage" ],
114120 parsed_args[" cpu-target" ],
115121 parsed_args[" optimize" ],
116122 parsed_args[" debug" ],
@@ -125,8 +131,9 @@ function main(args)
125131 )
126132end
127133
128- function julia_compile (julia_program, c_program= nothing , build_dir= " builddir" , verbose= false , quiet= false , clean= false ,
129- cpu_target= nothing , optimize= nothing , debug= nothing , inline= nothing , check_bounds= nothing , math_mode= nothing , depwarn= nothing ,
134+ function julia_compile (julia_program, c_program= nothing , build_dir= " builddir" , verbose= false , quiet= false ,
135+ clean= false , sysimage = nothing , cpu_target= nothing , optimize= nothing , debug= nothing ,
136+ inline= nothing , check_bounds= nothing , math_mode= nothing , depwarn= nothing ,
130137 object= false , shared= false , executable= true , julialibs= true )
131138
132139 verbose && quiet && (verbose = false )
@@ -135,9 +142,11 @@ function julia_compile(julia_program, c_program=nothing, build_dir="builddir", v
135142 isfile (julia_program) || error (" Cannot find file:\n \" $julia_program \" " )
136143 quiet || println (" Julia program file:\n \" $julia_program \" " )
137144
138- c_program = c_program == nothing ? joinpath (@__DIR__ , " program.c" ) : abspath (c_program)
139- isfile (c_program) || error (" Cannot find file:\n \" $c_program \" " )
140- quiet || println (" C program file:\n \" $c_program \" " )
145+ if executable
146+ c_program = c_program == nothing ? joinpath (@__DIR__ , " program.c" ) : abspath (c_program)
147+ isfile (c_program) || error (" Cannot find file:\n \" $c_program \" " )
148+ quiet || println (" C program file:\n \" $c_program \" " )
149+ end
141150
142151 cd (dirname (julia_program))
143152
@@ -176,14 +185,19 @@ function julia_compile(julia_program, c_program=nothing, build_dir="builddir", v
176185
177186 delete_object = false
178187 if object || shared || executable
179- julia_cmd = ` $(Base. julia_cmd ()) --startup-file=no`
180- cpu_target == nothing || splice! (julia_cmd. exec, 2 , [" -C$cpu_target " ])
188+ julia_cmd = ` $(Base. julia_cmd ()) `
189+ if length (julia_cmd. exec) != 5 || ! all (startswith .(julia_cmd. exec[2 : 5 ], [" -C" , " -J" , " --compile" , " --depwarn" ]))
190+ error (" Unexpected format of \" Base.julia_cmd()\" , you may be using an incompatible version of Julia" )
191+ end
192+ sysimage == nothing || (julia_cmd. exec[3 ] = " -J$sysimage " )
193+ push! (julia_cmd. exec, " --startup-file=no" )
194+ cpu_target == nothing || (julia_cmd. exec[2 ] = " -C$cpu_target " )
181195 optimize == nothing || push! (julia_cmd. exec, " -O$optimize " )
182196 debug == nothing || push! (julia_cmd. exec, " -g$debug " )
183197 inline == nothing || push! (julia_cmd. exec, " --inline=$inline " )
184198 check_bounds == nothing || push! (julia_cmd. exec, " --check-bounds=$check_bounds " )
185199 math_mode == nothing || push! (julia_cmd. exec, " --math-mode=$math_mode " )
186- depwarn == nothing || splice! (julia_cmd. exec, 5 , [ " --depwarn=$depwarn " ] )
200+ depwarn == nothing || (julia_cmd. exec[ 5 ] = " --depwarn=$depwarn " )
187201 is_windows () && (julia_program = replace (julia_program, " \\ " , " \\\\ " ))
188202 expr = "
189203 VERSION >= v\" 0.7+\" && Base.init_load_path($(repr (JULIA_HOME)) ) # initialize location of site-packages
@@ -192,7 +206,7 @@ function julia_compile(julia_program, c_program=nothing, build_dir="builddir", v
192206 include($(repr (julia_program)) ) # include \" julia_program\" file
193207 empty!(Base.LOAD_CACHE_PATH) # reset / remove build-system-relative paths"
194208 command = ` $julia_cmd -e $expr `
195- verbose && println (" Populate \" .ji\" local cache:\n $command " )
209+ verbose && println (" Build \" .ji\" files local cache:\n $command " )
196210 run (command)
197211 command = ` $julia_cmd --output-o $o_file -e $expr `
198212 verbose && println (" Build object file \" $o_file \" :\n $command " )
0 commit comments