Skip to content

Commit c69cf8b

Browse files
committed
Build with Ninja.
1 parent 363a66f commit c69cf8b

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

deps/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ CMake_jll = "3f4e10e2-61f2-5801-8945-23b9d642d0e6"
33
Git = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2"
44
LLVMExtra_jll = "dad2f222-ce93-54a1-a47d-0025e8a3acab"
55
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
6+
Ninja_jll = "76642167-d241-5cee-8c94-7a494e8cb7b7"
67
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
78
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
89
Scratch = "6c6a2e73-6563-6170-7368-637461726353"

deps/build_local.jl

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,24 @@ if haskey(ENV, "GITHUB_ACTIONS")
88
println("::warning ::Using a locally-built LLVMExtra; A bump of LLVMExtra_jll will be required before releasing LLVM.jl.")
99
end
1010

11-
using Pkg, Scratch, Preferences, Libdl, CMake_jll
11+
using Pkg, Scratch, Preferences, Libdl, CMake_jll, Ninja_jll
1212

1313
LLVM = Base.UUID("929cbde3-209d-540e-8aea-75f648917ca0")
1414

15-
# 1. Ensure that an appropriate LLVM_full_jll is installed
15+
# get scratch directories
16+
scratch_dir = get_scratch!(LLVM, "build")
17+
isdir(scratch_dir) && rm(scratch_dir; recursive=true)
18+
source_dir = joinpath(@__DIR__, "LLVMExtra")
19+
20+
# get build directory
21+
build_dir = if isempty(ARGS)
22+
mktempdir()
23+
else
24+
ARGS[1]
25+
end
26+
mkpath(build_dir)
27+
28+
# download LLVM
1629
Pkg.activate(; temp=true)
1730
llvm_assertions = try
1831
cglobal((:_ZN4llvm24DisableABIBreakingChecksE, Base.libllvm_path()), Cvoid)
@@ -31,34 +44,30 @@ else
3144
end
3245
LLVM_DIR = joinpath(LLVM.artifact_dir, "lib", "cmake", "llvm")
3346

34-
# 2. Get a scratch directory
35-
scratch_dir = get_scratch!(LLVM, "build")
36-
isdir(scratch_dir) && rm(scratch_dir; recursive=true)
37-
source_dir = joinpath(@__DIR__, "LLVMExtra")
38-
39-
# Build!
40-
mktempdir() do build_dir
41-
@info "Building" source_dir scratch_dir build_dir LLVM_DIR
42-
run(`$(cmake()) -DLLVM_DIR=$(LLVM_DIR) -DCMAKE_INSTALL_PREFIX=$(scratch_dir) -B$(build_dir) -S$(source_dir)`)
43-
run(`$(cmake()) --build $(build_dir)`)
44-
run(`$(cmake()) --install $(build_dir)`)
47+
# build and install
48+
@info "Building" source_dir scratch_dir build_dir LLVM_DIR
49+
cmake() do cmake_path
50+
ninja() do ninja_path
51+
run(`$cmake_path -GNinja -DLLVM_DIR=$(LLVM_DIR) -DCMAKE_INSTALL_PREFIX=$(scratch_dir) -B$(build_dir) -S$(source_dir)`)
52+
run(`$ninja_path -C $(build_dir) install`)
53+
end
4554
end
4655

47-
# Discover built libraries
56+
# discover built libraries
4857
built_libs = filter(readdir(joinpath(scratch_dir, "lib"))) do file
4958
endswith(file, ".$(Libdl.dlext)")
5059
end
5160
lib_path = joinpath(scratch_dir, "lib", only(built_libs))
5261
isfile(lib_path) || error("Could not find library $lib_path in build directory")
5362

54-
# Tell LLVMExtra_jll to load our library instead of the default artifact one
63+
# tell LLVMExtra_jll to load our library instead of the default artifact one
5564
set_preferences!(
5665
joinpath(dirname(@__DIR__), "LocalPreferences.toml"),
5766
"LLVMExtra_jll",
5867
"libLLVMExtra_path" => lib_path;
5968
force=true,
6069
)
6170

62-
# Copy the preferences to `test/` as well to work around Pkg.jl#2500
71+
# copy the preferences to `test/` as well to work around Pkg.jl#2500
6372
cp(joinpath(dirname(@__DIR__), "LocalPreferences.toml"),
6473
joinpath(dirname(@__DIR__), "test", "LocalPreferences.toml"); force=true)

0 commit comments

Comments
 (0)