-
Notifications
You must be signed in to change notification settings - Fork 12
Simplify/automate the compilation and use of a system image #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ffevotte
wants to merge
6
commits into
non-Jedi:master
Choose a base branch
from
ffevotte:ff/sysimage
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+199
−20
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3f83555
Simplify compilation and use of system images
ffevotte d240070
Automatic detection of system images
ffevotte 0659415
Opt-in mechanism + more robust sysimage naming convention
ffevotte 78a6530
Make `enable-sysimage` and `language-server-project` compatible
ffevotte d0ba475
Update README.org
ffevotte 3146865
Resolve environments before compiling sysimages
ffevotte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Usage: | ||
| # julia path/to/eglot-jl/compile.jl [LANGUAGESERVER_PROJECT_DIR] | ||
|
|
||
| # Path to the LanguageServer project. In order of increasing priority: | ||
| # - path to eglot-jl: @__DIR__ | ||
| # - command-line: ARGS[1] | ||
| dir = length(ARGS) >= 1 ? ARGS[1] : @__DIR__ | ||
|
|
||
| using Pkg | ||
| Pkg.activate(dir) | ||
| include("utils.jl") | ||
| pkg_resolve() | ||
|
|
||
| # Get a suitable system image name | ||
| sysimage = sysimage_path(dir) | ||
|
|
||
| # This tells `eglot-jl.jl` to switch to TEST mode, in which the server | ||
| # immediately reads an `exit` command after having started | ||
| ENV["EGLOT_JL_TEST"] = "1" | ||
|
|
||
|
|
||
| @info "Creating system image" path = sysimage | ||
|
|
||
| using PackageCompiler | ||
| create_sysimage([:LanguageServer, :SymbolServer]; | ||
| sysimage_path = sysimage, | ||
| precompile_execution_file = joinpath(@__DIR__, "eglot-jl.jl")) | ||
|
|
||
| @assert isfile(sysimage) | ||
| @info "Successfully generated system image" path = sysimage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import SHA | ||
| import Pkg | ||
|
|
||
| """ | ||
| pkg_resolve() | ||
|
|
||
| Resolve the currently active environment, in order to make sure it is compatible | ||
| with the Julia version in use. | ||
| """ | ||
| function pkg_resolve() | ||
| # Resolving the environment is necessary for cases where the shipped | ||
| # Manifest.toml is not compatible with the Julia version. | ||
| for _ in 1:2 | ||
| try | ||
| Pkg.resolve(io=stderr) | ||
| @info "Environment successfully resolved" | ||
| break | ||
| catch err | ||
| # Downgrading from 1.6 to 1.5 sometimes causes temporary errors | ||
| @warn "Error while resolving the environment; retrying..." err | ||
| end | ||
| end | ||
|
|
||
| # In julia 1.4 this operation takes under a second. This can be | ||
| # crushingly slow in older versions of julia though. | ||
| Pkg.instantiate() | ||
| end | ||
|
|
||
| """ | ||
| sysimage_path(dir) | ||
|
|
||
| Return a suitable name for the system image of a project in `dir`. In order to | ||
| avoid problems when/if Julia or the project dependencies get updated, all | ||
| versions get encoded in the system image file name. | ||
| """ | ||
| function sysimage_path(dir) | ||
| ext = if Sys.iswindows() | ||
| "dll" | ||
| elseif Sys.isapple() | ||
| "dylib" | ||
| else | ||
| "so" | ||
| end | ||
|
|
||
| hash = open(SHA.sha1, joinpath(dir, "Manifest.toml")) |> bytes2hex | ||
|
|
||
| joinpath(dir, "eglot-jl_$(Base.VERSION)_$hash.$ext") | ||
| end | ||
|
|
||
|
|
||
| # When used as a script: resolve the environment and print a suitable sysimage | ||
| # name | ||
| if abspath(PROGRAM_FILE) == @__FILE__ | ||
| pkg_resolve() | ||
| print(sysimage_path(ARGS[1])) | ||
| end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.