Skip to content

Commit 1a334ba

Browse files
committed
Build only explicitly requested targets by default
1 parent b42cfe4 commit 1a334ba

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
Helper script to build libraries and executables from Julia code.
44

55
```
6-
usage: juliac.jl [-v] [-q] [-c] [-J <file>] [-C <target>]
6+
usage: juliac.jl [-v] [-q] [-c] [-J <file>]
7+
[--compile {yes|no|all|min}] [-C <target>]
78
[-O {0,1,2,3}] [-g {0,1,2}] [--inline {yes|no}]
89
[--check-bounds {yes|no}] [--math-mode {ieee,fast}]
9-
[--depwarn {yes|no|error}] [-o] [-s] [-e] [-j]
10+
[--depwarn {yes|no|error}] [-a] [-o] [-s] [-e] [-j]
1011
[--version] [-h] juliaprog [cprog] [builddir]
1112
1213
positional arguments:
@@ -39,6 +40,7 @@ optional arguments:
3940
set floating point optimizations
4041
--depwarn {yes|no|error}
4142
set syntax and method deprecation warnings
43+
-a, --auto automatically build required dependencies
4244
-o, --object build object file
4345
-s, --shared build shared library
4446
-e, --executable build executable file
@@ -47,9 +49,9 @@ optional arguments:
4749
-h, --help show this help message and exit
4850
4951
examples:
50-
juliac.jl -ve hello.jl # verbose, build executable
51-
juliac.jl -ve hello.jl myprog.c # embed into user defined C program
52-
juliac.jl -qo hello.jl # quiet, build object file
52+
juliac.jl -vae hello.jl # verbose, auto, build executable
53+
juliac.jl -vae hello.jl myprog.c # embed into user defined C program
54+
juliac.jl -qo hello.jl # quiet, build object file only
5355
juliac.jl -vosej hello.jl # build all and sync Julia libs
5456
```
5557

juliac.jl

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
\ua0\ua0juliac.jl -ve hello.jl # verbose, build executable\n
106-
\ua0\ua0juliac.jl -ve hello.jl myprog.c # embed into user defined C program\n
107-
\ua0\ua0juliac.jl -qo hello.jl # quiet, build object file\n
108+
\ua0\ua0juliac.jl -vae hello.jl # verbose, auto, build executable\n
109+
\ua0\ua0juliac.jl -vae hello.jl myprog.c # embed into user defined C program\n
110+
\ua0\ua0juliac.jl -qo hello.jl # quiet, build object file only\n
108111
\ua0\ua0juliac.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
141145
function 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

Comments
 (0)