@@ -86,6 +86,9 @@ function main(args)
8686 metavar = " {yes|no|error}"
8787 range_tester = (x -> x == " yes" || x == " no" || x == " error" )
8888 help = " set syntax and method deprecation warnings"
89+ " --auto" , " -a"
90+ action = :store_true
91+ help = " automatically build required dependencies"
8992 " --object" , " -o"
9093 action = :store_true
9194 help = " build object file"
@@ -102,9 +105,9 @@ function main(args)
102105
103106 s. epilog = """
104107 examples:\n
105- \u a0\u a0juliac.jl -ve hello.jl # verbose, build executable\n
106- \u a0\u a0juliac.jl -ve hello.jl myprog.c # embed into user defined C program\n
107- \u a0\u a0juliac.jl -qo hello.jl # quiet, build object file\n
108+ \u a0\u a0juliac.jl -vae hello.jl # verbose, auto , build executable\n
109+ \u a0\u a0juliac.jl -vae hello.jl myprog.c # embed into user defined C program\n
110+ \u a0\u a0juliac.jl -qo hello.jl # quiet, build object file only \n
108111 \u a0\u a0juliac.jl -vosej hello.jl # build all and sync Julia libs\n
109112 """
110113
@@ -131,6 +134,7 @@ function main(args)
131134 parsed_args[" check-bounds" ],
132135 parsed_args[" math-mode" ],
133136 parsed_args[" depwarn" ],
137+ parsed_args[" auto" ],
134138 parsed_args[" object" ],
135139 parsed_args[" shared" ],
136140 parsed_args[" executable" ],
@@ -141,10 +145,15 @@ end
141145function julia_compile (julia_program, c_program= nothing , build_dir= " builddir" , verbose= false , quiet= false ,
142146 clean= false , sysimage = nothing , compile= nothing , cpu_target= nothing , optimize= nothing ,
143147 debug= nothing , inline= nothing , check_bounds= nothing , math_mode= nothing , depwarn= nothing ,
144- object= false , shared= false , executable= true , julialibs= true )
148+ auto = false , object= false , shared= false , executable= true , julialibs= true )
145149
146150 verbose && quiet && (verbose = false )
147151
152+ if auto
153+ executable && (shared = true )
154+ shared && (object = true )
155+ end
156+
148157 julia_program = abspath (julia_program)
149158 isfile (julia_program) || error (" Cannot find file:\n \" $julia_program \" " )
150159 quiet || println (" Julia program file:\n \" $julia_program \" " )
@@ -191,7 +200,7 @@ function julia_compile(julia_program, c_program=nothing, build_dir="builddir", v
191200 shlibdir = is_windows () ? JULIA_HOME : abspath (JULIA_HOME, Base. LIBDIR)
192201 private_shlibdir = abspath (JULIA_HOME, Base. PRIVATE_LIBDIR)
193202
194- if object || shared || executable
203+ if object
195204 julia_cmd = ` $(Base. julia_cmd ()) `
196205 if length (julia_cmd. exec) != 5 || ! all (startswith .(julia_cmd. exec[2 : 5 ], [" -C" , " -J" , " --compile" , " --depwarn" ]))
197206 error (" Unexpected format of \" Base.julia_cmd()\" , you may be using an incompatible version of Julia" )
@@ -229,7 +238,7 @@ function julia_compile(julia_program, c_program=nothing, build_dir="builddir", v
229238 cc = is_windows () ? " x86_64-w64-mingw32-gcc" : " gcc"
230239 end
231240
232- if shared || executable
241+ if shared
233242 command = ` $cc -m64 -shared -o $s_file $(joinpath (tmp_dir, o_file)) $cflags $ldflags $ldlibs `
234243 if is_apple ()
235244 command = ` $command -Wl,-install_name,@rpath/lib$julia_program_basename .dylib`
0 commit comments