@@ -8,11 +8,24 @@ if haskey(ENV, "GITHUB_ACTIONS")
8
8
println (" ::warning ::Using a locally-built LLVMExtra; A bump of LLVMExtra_jll will be required before releasing LLVM.jl." )
9
9
end
10
10
11
- using Pkg, Scratch, Preferences, Libdl, CMake_jll
11
+ using Pkg, Scratch, Preferences, Libdl, CMake_jll, Ninja_jll
12
12
13
13
LLVM = Base. UUID (" 929cbde3-209d-540e-8aea-75f648917ca0" )
14
14
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
16
29
Pkg. activate (; temp= true )
17
30
llvm_assertions = try
18
31
cglobal ((:_ZN4llvm24DisableABIBreakingChecksE , Base. libllvm_path ()), Cvoid)
31
44
end
32
45
LLVM_DIR = joinpath (LLVM. artifact_dir, " lib" , " cmake" , " llvm" )
33
46
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
45
54
end
46
55
47
- # Discover built libraries
56
+ # discover built libraries
48
57
built_libs = filter (readdir (joinpath (scratch_dir, " lib" ))) do file
49
58
endswith (file, " .$(Libdl. dlext) " )
50
59
end
51
60
lib_path = joinpath (scratch_dir, " lib" , only (built_libs))
52
61
isfile (lib_path) || error (" Could not find library $lib_path in build directory" )
53
62
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
55
64
set_preferences! (
56
65
joinpath (dirname (@__DIR__ ), " LocalPreferences.toml" ),
57
66
" LLVMExtra_jll" ,
58
67
" libLLVMExtra_path" => lib_path;
59
68
force= true ,
60
69
)
61
70
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
63
72
cp (joinpath (dirname (@__DIR__ ), " LocalPreferences.toml" ),
64
73
joinpath (dirname (@__DIR__ ), " test" , " LocalPreferences.toml" ); force= true )
0 commit comments