Skip to content

Commit 0ed06a0

Browse files
committed
use old name for script
1 parent 204cf85 commit 0ed06a0

File tree

1 file changed

+131
-0
lines changed

1 file changed

+131
-0
lines changed

juliac.jl

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
## Assumptions:
2+
## 1. gcc / x86_64-w64-mingw32-gcc is available and is in path
3+
## 2. Package ArgParse is installed
4+
5+
using PackageCompiler, ArgParse
6+
7+
function main(args)
8+
9+
s = ArgParseSettings("Static Julia Compiler",
10+
version = "$(basename(@__FILE__)) version 0.7-DEV",
11+
add_version = true)
12+
13+
@add_arg_table s begin
14+
"juliaprog"
15+
arg_type = String
16+
required = true
17+
help = "Julia program to compile"
18+
"cprog"
19+
arg_type = String
20+
default = nothing
21+
help = "C program to compile (required only when building an executable; if not provided a minimal driver program is used)"
22+
"builddir"
23+
arg_type = String
24+
default = "builddir"
25+
help = "build directory, either absolute or relative to the Julia program directory"
26+
"--verbose", "-v"
27+
action = :store_true
28+
help = "increase verbosity"
29+
"--quiet", "-q"
30+
action = :store_true
31+
help = "suppress non-error messages"
32+
"--clean", "-c"
33+
action = :store_true
34+
help = "delete builddir"
35+
"--sysimage", "-J"
36+
arg_type = String
37+
default = nothing
38+
metavar = "<file>"
39+
help = "start up with the given system image file"
40+
"--compile"
41+
arg_type = String
42+
default = nothing
43+
metavar = "{yes|no|all|min}"
44+
range_tester = (x -> x == "yes" || x == "no" || x == "all" || x == "min")
45+
help = "enable or disable JIT compiler, or request exhaustive compilation"
46+
"--cpu-target", "-C"
47+
arg_type = String
48+
default = nothing
49+
metavar = "<target>"
50+
help = "limit usage of CPU features up to <target>"
51+
"--optimize", "-O"
52+
arg_type = Int
53+
default = nothing
54+
metavar = "{0,1,2,3}"
55+
range_tester = (x -> 0 <= x <= 3)
56+
help = "set optimization level"
57+
"-g"
58+
arg_type = Int
59+
default = nothing
60+
dest_name = "debug"
61+
metavar = "{0,1,2}"
62+
range_tester = (x -> 0 <= x <= 2)
63+
help = "set debugging information level"
64+
"--inline"
65+
arg_type = String
66+
default = nothing
67+
metavar = "{yes|no}"
68+
range_tester = (x -> x == "yes" || x == "no")
69+
help = "control whether inlining is permitted"
70+
"--check-bounds"
71+
arg_type = String
72+
default = nothing
73+
metavar = "{yes|no}"
74+
range_tester = (x -> x == "yes" || x == "no")
75+
help = "emit bounds checks always or never"
76+
"--math-mode"
77+
arg_type = String
78+
default = nothing
79+
metavar = "{ieee,fast}"
80+
range_tester = (x -> x == "ieee" || x == "fast")
81+
help = "set floating point optimizations"
82+
"--depwarn"
83+
arg_type = String
84+
default = nothing
85+
metavar = "{yes|no|error}"
86+
range_tester = (x -> x == "yes" || x == "no" || x == "error")
87+
help = "set syntax and method deprecation warnings"
88+
"--autodeps", "-a"
89+
action = :store_true
90+
help = "automatically build required dependencies"
91+
"--object", "-o"
92+
action = :store_true
93+
help = "build object file"
94+
"--shared", "-s"
95+
action = :store_true
96+
help = "build shared library"
97+
"--executable", "-e"
98+
action = :store_true
99+
help = "build executable file"
100+
"--julialibs", "-j"
101+
action = :store_true
102+
help = "sync Julia libraries to builddir"
103+
end
104+
105+
s.epilog = """
106+
examples:\n
107+
\ua0\ua0juliac.jl -vae hello.jl # verbose, build executable and deps\n
108+
\ua0\ua0juliac.jl -vae hello.jl prog.c # embed into user defined C program\n
109+
\ua0\ua0juliac.jl -qo hello.jl # quiet, build object file only\n
110+
\ua0\ua0juliac.jl -vosej hello.jl # build all and sync Julia libs\n
111+
"""
112+
113+
parsed_args = parse_args(args, s)
114+
115+
# TODO: in future it may be possible to broadcast dictionary indexing, see: https://discourse.julialang.org/t/accessing-multiple-values-of-a-dictionary/8648
116+
if !any(getindex.(parsed_args, ["clean", "object", "shared", "executable", "julialibs"]))
117+
parsed_args["quiet"] || println("Nothing to do, exiting\nTry \"$(basename(@__FILE__)) -h\" for more information")
118+
exit(0)
119+
end
120+
121+
kw_args = map(parsed_args) do kv
122+
Symbol(replace(kv[1], "-", "_")) => kv[2]
123+
end
124+
kw_args = filter((k, v)-> k != :juliaprog, kw_args)
125+
PackageCompiler.julia_compile(
126+
parsed_args["juliaprog"];
127+
kw_args...
128+
)
129+
end
130+
131+
main(ARGS)

0 commit comments

Comments
 (0)