Skip to content

Commit ee2b551

Browse files
authored
Add --Release flag (#103)
1 parent a12e751 commit ee2b551

File tree

4 files changed

+33
-26
lines changed

4 files changed

+33
-26
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Run `juliac.jl -h` for help:
6464

6565
```
6666
usage: juliac.jl [-v] [-q] [-d <dir>] [-n <name>] [-p <file>] [-c]
67-
[-a] [-o] [-s] [-e] [-t] [-j] [-f <filelist>] [-r]
67+
[-a] [-o] [-s] [-e] [-t] [-j] [-f <file>] [-r] [-R]
6868
[-J <file>] [--precompiled {yes|no}]
6969
[--compilecache {yes|no}] [-H <dir>]
7070
[--startup-file {yes|no}] [--handle-signals {yes|no}]
@@ -80,7 +80,7 @@ Static Julia Compiler
8080
positional arguments:
8181
juliaprog Julia program to compile
8282
cprog C program to compile (required only when
83-
building an executable; if not provided a
83+
building an executable, if not provided a
8484
minimal driver program is used)
8585
8686
optional arguments:
@@ -100,7 +100,10 @@ optional arguments:
100100
-f, --copy-file <file>
101101
copy file to build directory, can be repeated
102102
for multiple files
103-
-r, --release build in release mode, with `-O3 -g0`
103+
-r, --release build in release mode, implies `-O3 -g0`
104+
unless otherwise specified
105+
-R, --Release perform a fully automated release build,
106+
equivalent to `-caetjr`
104107
-J, --sysimage <file>
105108
start up with the given system image file
106109
--precompiled {yes|no}
@@ -145,6 +148,7 @@ examples:
145148
juliac.jl -vae hello.jl prog.c # embed into user defined C program
146149
juliac.jl -qo hello.jl # quiet, build object file only
147150
juliac.jl -vosej hello.jl # build all and copy Julia libs
151+
juliac.jl -vR hello.jl # fully automated release build
148152
```
149153

150154
## Building a shared library

juliac.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ Base.@ccallable function julia_main(args::Vector{String})::Cint
6161
help = "copy file to build directory, can be repeated for multiple files"
6262
"--release", "-r"
6363
action = :store_true
64-
help = "build in release mode, with `-O3 -g0`"
64+
help = "build in release mode, implies `-O3 -g0` unless otherwise specified"
65+
"--Release", "-R"
66+
action = :store_true
67+
help = "perform a fully automated release build, equivalent to `-caetjr`"
6568
"--sysimage", "-J"
6669
arg_type = String
6770
metavar = "<file>"
@@ -144,15 +147,16 @@ Base.@ccallable function julia_main(args::Vector{String})::Cint
144147
\ua0\ua0juliac.jl -vae hello.jl # verbose, build executable and deps\n
145148
\ua0\ua0juliac.jl -vae hello.jl prog.c # embed into user defined C program\n
146149
\ua0\ua0juliac.jl -qo hello.jl # quiet, build object file only\n
147-
\ua0\ua0juliac.jl -vosej hello.jl # build all and copy Julia libs
150+
\ua0\ua0juliac.jl -vosej hello.jl # build all and copy Julia libs\n
151+
\ua0\ua0juliac.jl -vR hello.jl # fully automated release build
148152
"""
149153

150154
parsed_args = parse_args(args, s)
151155

152156
parsed_args["copy-files"] == String[] && (parsed_args["copy-files"] = nothing)
153157

154158
# TODO: in future it may be possible to broadcast dictionary indexing, see: https://discourse.julialang.org/t/accessing-multiple-values-of-a-dictionary/8648
155-
if getindex.(Ref(parsed_args), ["clean", "object", "shared", "executable", "rmtemp", "copy-julialibs", "copy-files"]) == [false, false, false, false, false, false, nothing]
159+
if getindex.(Ref(parsed_args), ["clean", "object", "shared", "executable", "rmtemp", "copy-julialibs", "copy-files", "Release"]) == [false, false, false, false, false, false, nothing, false]
156160
parsed_args["quiet"] || println("nothing to do, exiting\ntry \"$(basename(@__FILE__)) -h\" for more information")
157161
exit(0)
158162
end

src/api.jl

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ end
3636
"""
3737
build_shared_lib(
3838
julia_program, output_name = nothing;
39-
snoopfile = nothing, builddir = nothing,
40-
verbose = false, quiet = false, copy_julialibs = true, copy_files = nothing,
41-
release = false,
39+
snoopfile = nothing, builddir = nothing, verbose = false, quiet = false,
40+
copy_julialibs = true, copy_files = nothing, release = false, Release = false,
4241
sysimage = nothing, precompiled = nothing, compilecache = nothing,
4342
home = nothing, startup_file = nothing, handle_signals = nothing,
4443
compile = nothing, cpu_target = nothing, optimize = nothing, debug = nothing,
@@ -51,9 +50,8 @@ end
5150
"""
5251
function build_shared_lib(
5352
julia_program, output_name = nothing;
54-
snoopfile = nothing, builddir = nothing,
55-
verbose = false, quiet = false, copy_julialibs = true, copy_files = nothing,
56-
release = false,
53+
snoopfile = nothing, builddir = nothing, verbose = false, quiet = false,
54+
copy_julialibs = true, copy_files = nothing, release = false, Release = false,
5755
sysimage = nothing, precompiled = nothing, compilecache = nothing,
5856
home = nothing, startup_file = nothing, handle_signals = nothing,
5957
compile = nothing, cpu_target = nothing, optimize = nothing, debug = nothing,
@@ -62,9 +60,8 @@ function build_shared_lib(
6260
)
6361
static_julia(
6462
julia_program, verbose = verbose, quiet = quiet,
65-
builddir = builddir, outname = output_name, snoopfile = snoopfile,
66-
autodeps = true, shared = true, copy_julialibs = copy_julialibs, copy_files = copy_files,
67-
release = release,
63+
builddir = builddir, outname = output_name, snoopfile = snoopfile, autodeps = true, shared = true,
64+
copy_julialibs = copy_julialibs, copy_files = copy_files, release = release, Release = release,
6865
sysimage = sysimage, precompiled = precompiled, compilecache = compilecache,
6966
home = home, startup_file = startup_file, handle_signals = handle_signals,
7067
compile = compile, cpu_target = cpu_target, optimize = optimize, debug = debug,
@@ -76,9 +73,8 @@ end
7673
"""
7774
build_executable(
7875
julia_program, output_name = nothing, c_program = nothing;
79-
snoopfile = nothing, builddir = nothing,
80-
verbose = false, quiet = false, copy_julialibs = true, copy_files = nothing,
81-
release = false,
76+
snoopfile = nothing, builddir = nothing, verbose = false, quiet = false,
77+
copy_julialibs = true, copy_files = nothing, release = false, Release = false,
8278
sysimage = nothing, precompiled = nothing, compilecache = nothing,
8379
home = nothing, startup_file = nothing, handle_signals = nothing,
8480
compile = nothing, cpu_target = nothing, optimize = nothing, debug = nothing,
@@ -91,9 +87,8 @@ end
9187
"""
9288
function build_executable(
9389
julia_program, output_name = nothing, c_program = nothing;
94-
snoopfile = nothing, builddir = nothing,
95-
verbose = false, quiet = false, copy_julialibs = true, copy_files = nothing,
96-
release = false,
90+
snoopfile = nothing, builddir = nothing, verbose = false, quiet = false,
91+
copy_julialibs = true, copy_files = nothing, release = false, Release = false,
9792
sysimage = nothing, precompiled = nothing, compilecache = nothing,
9893
home = nothing, startup_file = nothing, handle_signals = nothing,
9994
compile = nothing, cpu_target = nothing, optimize = nothing, debug = nothing,
@@ -102,9 +97,8 @@ function build_executable(
10297
)
10398
static_julia(
10499
julia_program, cprog = c_program, verbose = verbose, quiet = quiet,
105-
builddir = builddir, outname = output_name, snoopfile = snoopfile,
106-
autodeps = true, executable = true, copy_julialibs = copy_julialibs, copy_files = copy_files,
107-
release = release,
100+
builddir = builddir, outname = output_name, snoopfile = snoopfile, autodeps = true, executable = true,
101+
copy_julialibs = copy_julialibs, copy_files = copy_files, release = release, Release = release,
108102
sysimage = sysimage, precompiled = precompiled, compilecache = compilecache,
109103
home = home, startup_file = startup_file, handle_signals = handle_signals,
110104
compile = compile, cpu_target = cpu_target, optimize = optimize, debug = debug,

src/static_julia.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ compiles the Julia file at path `juliaprog` with keyword arguments:
4343
rmtemp remove temporary build files
4444
copy_julialibs copy Julia libraries to build directory
4545
copy_files copy user-specified files to build directory (either `nothing` or a string array)
46-
release build in release mode, with `-O3 -g0`
46+
release build in release mode, implies `-O3 -g0` unless otherwise specified
47+
Release perform a fully automated release build, equivalent to `-caetjr`
4748
sysimage <file> start up with the given system image file
4849
precompiled {yes|no} use precompiled code from system image if available
4950
compilecache {yes|no} enable/disable incremental precompilation of modules
@@ -65,7 +66,7 @@ function static_julia(
6566
juliaprog;
6667
cprog = nothing, verbose = false, quiet = false, builddir = nothing, outname = nothing, snoopfile = nothing,
6768
clean = false, autodeps = false, object = false, shared = false, executable = false, rmtemp = false,
68-
copy_julialibs = false, copy_files = nothing, release = false,
69+
copy_julialibs = false, copy_files = nothing, release = false, Release = false,
6970
sysimage = nothing, precompiled = nothing, compilecache = nothing,
7071
home = nothing, startup_file = nothing, handle_signals = nothing,
7172
compile = nothing, cpu_target = nothing, optimize = nothing, debug = nothing,
@@ -80,6 +81,10 @@ function static_julia(
8081

8182
verbose && quiet && (quiet = false)
8283

84+
if Release
85+
clean = autodeps = executable = rmtemp = copy_julialibs = release = true
86+
end
87+
8388
if autodeps
8489
executable && (shared = true)
8590
shared && (object = true)

0 commit comments

Comments
 (0)