Skip to content

Commit 6d28fa5

Browse files
committed
add function for building executables
1 parent 6332431 commit 6d28fa5

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

src/api.jl

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ end
3535
function build_shared_lib(
3636
library, library_name;
3737
verbose = false, quiet = false,
38-
cpu_target = "native", optimize = nothing, debug = nothing,
38+
cpu_target = nothing, optimize = nothing, debug = nothing,
3939
inline = nothing, check_bounds = nothing, math_mode = nothing
4040
)
4141
julia_compile(
@@ -53,13 +53,40 @@ function build_shared_lib(
5353
)
5454
end
5555

56+
function build_executable(
57+
library,
58+
library_name = splitext(basename(library))[1],
59+
cprogram = joinpath(@__DIR__, "..", "examples", "program.c");
60+
61+
snoopfile = nothing, builddir = "build",
62+
verbose = false, quiet = false,
63+
cpu_target = "native", optimize = nothing, debug = nothing,
64+
inline = nothing, check_bounds = nothing, math_mode = nothing
65+
)
66+
julia_compile(
67+
68+
library, julia_program_basename = library_name,
69+
70+
cpu_target = cpu_target, optimize = optimize,
71+
debug = debug, inline = inline, check_bounds = check_bounds,
72+
math_mode = math_mode, verbose = verbose, quiet = quiet,
73+
74+
cprog = cprogram, builddir = builddir,
75+
clean = false, sysimage = nothing,
76+
compile = nothing, depwarn = nothing, autodeps = false,
77+
object = true, shared = true, executable = true, julialibs = true,
78+
)
79+
end
80+
5681

5782
"""
83+
build_native_image()
5884
Builds a clean system image, similar to a fresh Julia install.
5985
Can also be used to build a native system image for a downloaded cross compiled julia binary.
6086
"""
61-
function build_native_image(debug = false)
87+
function build_native_image(debug = false) # debug is ignored right now
6288
backup = sysimgbackup_folder()
89+
# Build in backup dir, so we have a clean backup!
6390
compile_system_image(joinpath(backup, "sys"), "native")
6491
copy_system_image(backup, default_sysimg_path(debug))
6592
end

0 commit comments

Comments
 (0)