|
|
|
@ -1,41 +1,75 @@
@@ -1,41 +1,75 @@
|
|
|
|
|
require "Build" |
|
|
|
|
require "Utils" |
|
|
|
|
|
|
|
|
|
local llvm = "../../deps/llvm/" |
|
|
|
|
local llvm_build = "../../deps/llvm/" .. os.get() |
|
|
|
|
local llvm = "../../deps/llvm" |
|
|
|
|
|
|
|
|
|
-- If we are inside vagrant then clone and build LLVM outside the shared folder, |
|
|
|
|
-- otherwise file I/O performance will be terrible. |
|
|
|
|
if is_vagrant() then |
|
|
|
|
llvm = "~/llvm" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local llvm_build = llvm .. "/" .. os.get() |
|
|
|
|
|
|
|
|
|
function clone_llvm() |
|
|
|
|
local llvm_release = cat("LLVM-commit") |
|
|
|
|
local llvm_release = cat("../LLVM-commit") |
|
|
|
|
print("LLVM release: " .. llvm_release) |
|
|
|
|
|
|
|
|
|
local clang_release = cat("Clang-commit") |
|
|
|
|
local clang_release = cat("../Clang-commit") |
|
|
|
|
print("Clang release: " .. clang_release) |
|
|
|
|
|
|
|
|
|
if os.isdir(llvm) and not os.isdir(llvm .. "/.git") then |
|
|
|
|
error("LLVM directory is not a git repository.") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if not os.isdir(llvm) then |
|
|
|
|
git.clone(llvm, "http://llvm.org/git/llvm.git") |
|
|
|
|
git.checkout(llvm, llvm_release) |
|
|
|
|
else |
|
|
|
|
git.reset_hard(llvm, "HEAD") |
|
|
|
|
git.pull_rebase(llvm) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if not os.isdir(llvm .. "/tools/clang") then |
|
|
|
|
git.clone(llvm .. "/tools/clang", "http://llvm.org/git/clang.git") |
|
|
|
|
git.checkout(llvm .. "/tools/clang", clang_release) |
|
|
|
|
local clang = llvm .. "/tools/clang" |
|
|
|
|
if not os.isdir(clang) then |
|
|
|
|
git.clone(clang, "http://llvm.org/git/clang.git") |
|
|
|
|
else |
|
|
|
|
git.reset_hard(clang, "HEAD") |
|
|
|
|
git.pull_rebase(clang) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
git.reset_hard(llvm, llvm_release) |
|
|
|
|
git.reset_hard(clang, clang_release) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function get_llvm_package_name(rev, conf) |
|
|
|
|
return table.concat({"llvm", rev, os.get(), conf}, "-") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function extract_7z(archive, dest_dir) |
|
|
|
|
return execute(string.format("7z x %s -o%s -y", archive, dest_dir), true) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function download_llvm() |
|
|
|
|
if os.is("windows") then |
|
|
|
|
http.download("https://dl.dropboxusercontent.com/u/194502/CppSharp/llvm_windows_x86.7z") |
|
|
|
|
local base = "https://dl.dropboxusercontent.com/u/194502/CppSharp/llvm/" |
|
|
|
|
local conf = os.is("windows") and "RelWithDebInfo" or "Release" |
|
|
|
|
local rev = string.sub(cat("../LLVM-commit"), 0, 6) |
|
|
|
|
local pkg_name = get_llvm_package_name(rev, conf) |
|
|
|
|
local archive = pkg_name .. ".7z" |
|
|
|
|
|
|
|
|
|
-- check if we already have the file downloaded |
|
|
|
|
if not os.isfile(archive) then |
|
|
|
|
download(base .. archive, archive) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- extract the package |
|
|
|
|
execute("7z x llvm_windows_x86.7z -o%DEPS_PATH%\llvm -y > nul") |
|
|
|
|
if not os.isdir(pkg_name) then |
|
|
|
|
extract_7z(archive, pkg_name) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function cmake(gen, conf) |
|
|
|
|
print(os.getcwd()) |
|
|
|
|
print(llvm_build) |
|
|
|
|
local cwd = os.getcwd() |
|
|
|
|
os.chdir(llvm_build) |
|
|
|
|
print(os.getcwd()) |
|
|
|
|
local cmd = "cmake -G " .. '"' .. gen .. '"' |
|
|
|
|
.. ' -DCLANG_BUILD_EXAMPLES=false -DCLANG_INCLUDE_DOCS=false -DCLANG_INCLUDE_TESTS=false' |
|
|
|
|
.. ' -DCLANG_ENABLE_ARCMT=false -DCLANG_ENABLE_REWRITER=false -DCLANG_ENABLE_STATIC_ANALYZER=false' |
|
|
|
@ -43,6 +77,7 @@ function cmake(gen, conf)
@@ -43,6 +77,7 @@ function cmake(gen, conf)
|
|
|
|
|
.. ' -DLLVM_TARGETS_TO_BUILD="X86"' |
|
|
|
|
.. ' -DCMAKE_BUILD_TYPE=' .. conf .. ' ..' |
|
|
|
|
execute(cmd) |
|
|
|
|
os.chdir(cwd) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function clean_llvm(llvm_build) |
|
|
|
@ -64,7 +99,8 @@ function build_llvm(llvm_build)
@@ -64,7 +99,8 @@ function build_llvm(llvm_build)
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function package_llvm(conf, llvm, llvm_build) |
|
|
|
|
local out = "llvm-" .. os.get() .. "-" .. conf |
|
|
|
|
local rev = string.sub(git.rev_parse(llvm, "HEAD"), 0, 6) |
|
|
|
|
local out = get_llvm_package_name(rev, conf) |
|
|
|
|
|
|
|
|
|
if os.isdir(out) then os.rmdir(out) end |
|
|
|
|
os.mkdir(out) |
|
|
|
@ -108,10 +144,27 @@ function package_llvm(conf, llvm, llvm_build)
@@ -108,10 +144,27 @@ function package_llvm(conf, llvm, llvm_build)
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function archive_llvm(dir) |
|
|
|
|
execute("7z a " .. out .. ".7z " .. "./" .. out .. "/*") |
|
|
|
|
execute("7z a " .. dir .. ".7z " .. "./" .. dir .. "/*") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if _ACTION == "clone_llvm" then |
|
|
|
|
clone_llvm() |
|
|
|
|
os.exit() |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
clean_llvm(llvm_build) |
|
|
|
|
build_llvm(llvm_build) |
|
|
|
|
--local out = package_llvm("RelWithDebInfo", llvm, llvm_build) |
|
|
|
|
--archive_llvm(out) |
|
|
|
|
if _ACTION == "build_llvm" then |
|
|
|
|
clean_llvm(llvm_build) |
|
|
|
|
build_llvm(llvm_build) |
|
|
|
|
os.exit() |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if _ACTION == "package_llvm" then |
|
|
|
|
local pkg = package_llvm("RelWithDebInfo", llvm, llvm_build) |
|
|
|
|
archive_llvm(pkg) |
|
|
|
|
os.exit() |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if _ACTION == "download_llvm" then |
|
|
|
|
download_llvm() |
|
|
|
|
os.exit() |
|
|
|
|
end |
|
|
|
|