Skip to content

Commit b8b2ac0

Browse files
committed
add documentation
1 parent 38dc02a commit b8b2ac0

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

src/PackageCompiler.jl

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,22 @@ function copy_system_image(src, dest, ignore_missing = false)
6767
end
6868
end
6969

70+
71+
"""
72+
Builds a clean system image, similar to a fresh Julia install.
73+
Can also be used to build a native system image for a downloaded cross compiled julia binary.
74+
"""
7075
function build_clean_image(debug = false)
7176
backup = sysimgbackup_folder()
7277
build_sysimg(backup, "native")
7378
copy_system_image(backup, default_sysimg_path(debug))
7479
end
7580

76-
81+
"""
82+
Reverts a forced compilation of the system image.
83+
This will restore any previously backed up system image files, or
84+
build a new, clean system image
85+
"""
7786
function revert(debug = false)
7887
syspath = default_sysimg_path(debug)
7988
sysimg_backup = sysimgbackup_folder()
@@ -114,7 +123,13 @@ function package_folder(package...)
114123
normpath(abspath(joinpath(packages, package...)))
115124
end
116125

126+
"""
127+
compile_package(packages...; kw_args...)
117128
129+
with packages being either a string naming a package, or a tuple (package_name, precompile_file).
130+
If no precompile file is given, it will use the packages runtests.jl, which is a good canditate
131+
for figuring out what functions to compile!
132+
"""
118133
function compile_package(packages...; kw_args...)
119134
args = map(packages) do package
120135
# If no explicit path to a seperate precompile file, use runtests
@@ -125,6 +140,11 @@ function compile_package(packages...; kw_args...)
125140
compile_package(args...; kw_args...)
126141
end
127142

143+
"""
144+
snoop_userimg(userimg, packages::Tuple{String, String}...)
145+
146+
Traces all function calls in packages and writes out `precompile` statements into the file `userimg`
147+
"""
128148
function snoop_userimg(userimg, packages::Tuple{String, String}...)
129149
snooped_precompiles = map(packages) do package_snoopfile
130150
package, snoopfile = package_snoopfile
@@ -153,6 +173,14 @@ function snoop_userimg(userimg, packages::Tuple{String, String}...)
153173
userimg
154174
end
155175

176+
177+
"""
178+
compile_package(packages::Tuple{String, String}...; force = false, reuse = false, debug = false)
179+
180+
Compile a list of packages. Each package comes as a tuple of `(package_name, precompile_file)`
181+
where the precompile file should contain all function calls, that should get compiled into the system image.
182+
Usually the runtests.jl file is a good candidate, since it should run all important functions of a package.
183+
"""
156184
function compile_package(packages::Tuple{String, String}...; force = false, reuse = false, debug = false)
157185
userimg = sysimg_folder("precompile.jl")
158186
if !reuse
@@ -190,7 +218,9 @@ function compile_package(packages::Tuple{String, String}...; force = false, reus
190218
end
191219
end
192220

193-
221+
"""
222+
Replaces the julia system image forcefully with a system image located at `image_path`
223+
"""
194224
function replace_jl_sysimg(image_path, debug = false)
195225
syspath = default_sysimg_path(debug)
196226
backup = sysimgbackup_folder()
@@ -202,6 +232,9 @@ function replace_jl_sysimg(image_path, debug = false)
202232
end
203233

204234

235+
export compile_package, revert, build_clean_image
236+
237+
205238
end # module
206239

207240

0 commit comments

Comments
 (0)