Skip to content

Commit 1d4c243

Browse files
rokupstritao
authored andcommitted
Cloning llvm from git replaced with downloading archives of exacty commits from github. This is much faster.
1 parent caacaa8 commit 1d4c243

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

build/scripts/LLVM.lua

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,38 @@ function clone_llvm()
2525
local clang_release = get_clang_rev()
2626
print("Clang release: " .. clang_release)
2727

28-
if os.isdir(llvm) and not os.isdir(llvm .. "/.git") then
29-
error("LLVM directory is not a git repository.")
28+
if os.ishost("windows") then
29+
extract = extract_7z
30+
else
31+
extract = extract_tar_gz
3032
end
3133

32-
local quotedLLVM = '"' .. llvm .. '"'
33-
if not os.isdir(llvm) then
34-
git.clone(quotedLLVM, "https://github.com/llvm-mirror/llvm.git")
34+
local archive = 'llvm-'..llvm_release..'.tar.gz'
35+
if os.isfile(archive) then
36+
print('Archive '..archive..' already exists.')
3537
else
36-
git.reset_hard(quotedLLVM, "HEAD")
37-
git.pull_rebase(quotedLLVM)
38+
download('https://github.com/llvm-mirror/llvm/archive/'..llvm_release..'.tar.gz', archive)
3839
end
3940

40-
local clang = llvm .. "/tools/clang"
41-
local quotedClang = '"' .. clang .. '"'
42-
if not os.isdir(clang) then
43-
git.clone(quotedClang, "https://github.com/llvm-mirror/clang.git")
44-
else
45-
git.reset_hard(quotedClang, "HEAD")
46-
git.pull_rebase(quotedClang)
41+
if os.isdir(llvm) then
42+
os.rmdir(llvm)
43+
if os.isdir(llvm) then
44+
print('Removing '..llvm..' directory failed. Please remove it manually and restart.')
45+
return
46+
end
4747
end
4848

49-
git.reset_hard(quotedLLVM, llvm_release)
50-
git.reset_hard(quotedClang, clang_release)
49+
extract(archive, '.')
50+
os.rename('llvm-'..llvm_release, llvm)
51+
52+
archive = 'clang-'..clang_release..'.tar.gz'
53+
if os.isfile(archive) then
54+
print('Archive '..archive..' already exists.')
55+
else
56+
download('https://github.com/llvm-mirror/clang/archive/'..clang_release..'.tar.gz', archive)
57+
end
58+
extract(archive, '.')
59+
os.rename('clang-'..clang_release, llvm..'/tools/clang')
5160
end
5261
function get_vs_version()
5362
local function map_msvc_to_vs_version(major, minor)
@@ -129,6 +138,11 @@ function extract_tar_xz(archive, dest_dir)
129138
return execute_or_die(string.format("tar xJf %s -C %s", archive, dest_dir), true)
130139
end
131140

141+
function extract_tar_gz(archive, dest_dir)
142+
execute("mkdir -p " .. dest_dir, true)
143+
return execute_or_die(string.format("tar xf %s -C %s", archive, dest_dir), true)
144+
end
145+
132146
local use_7zip = os.ishost("windows")
133147
local archive_ext = use_7zip and ".7z" or ".tar.xz"
134148

0 commit comments

Comments
 (0)