|
@@ -4,8 +4,8 @@ package("llvm")
|
|
|
set_homepage("https://llvm.org/")
|
|
|
set_description("The LLVM Compiler Infrastructure")
|
|
|
|
|
|
- if is_host("windows") then
|
|
|
- if os.arch() == "x86" then
|
|
|
+ if is_plat("windows") then
|
|
|
+ if is_arch("x86") then
|
|
|
set_urls("https://github.com/xmake-mirror/llvm-windows/releases/download/$(version)/clang+llvm-$(version)-win32.zip")
|
|
|
add_versions("11.0.0", "268043ae0b656cf6272ccb9b8e3f21f51170b74ed8997ddc0b99587983b821ca")
|
|
|
add_versions("14.0.0", "63afc3c472cb279978c5a7efc25b8783a700aeb416df67886b7057eba52a8742")
|
|
@@ -14,20 +14,20 @@ package("llvm")
|
|
|
add_versions("11.0.0", "db5b3a44f8f784ebc71f716b54eb63c0d8d21aead12449f36291ab00820271c7")
|
|
|
add_versions("14.0.0", "c1e1ddf11aa73c58073956d9217086550544328ed5e6ec64c1a709badb231711")
|
|
|
end
|
|
|
- elseif is_host("macosx") then
|
|
|
- if os.arch() == "x86_64" then
|
|
|
+ elseif is_plat("macosx") then
|
|
|
+ if is_arch("x86_64") then
|
|
|
set_urls("https://github.com/llvm/llvm-project/releases/download/llvmorg-$(version)/clang+llvm-$(version)-x86_64-apple-darwin.tar.xz")
|
|
|
add_versions("11.0.0", "b93886ab0025cbbdbb08b46e5e403a462b0ce034811c929e96ed66c2b07fe63a")
|
|
|
add_versions("14.0.0", "cf5af0f32d78dcf4413ef6966abbfd5b1445fe80bba57f2ff8a08f77e672b9b3")
|
|
|
- elseif os.arch() == "arm64" then
|
|
|
+ elseif is_arch("arm64") then
|
|
|
set_urls("https://github.com/llvm/llvm-project/releases/download/llvmorg-$(version)/clang+llvm-$(version)-arm64-apple-darwin21.0.tar.xz")
|
|
|
add_versions("15.0.0", "cfd5c3fa07d7fccea0687f5b4498329a6172b7a15bbc45b547d0ac86bd3452a5")
|
|
|
end
|
|
|
- elseif is_host("bsd") then
|
|
|
- if os.arch() == "x86_64" then
|
|
|
+ elseif is_plat("bsd") then
|
|
|
+ if is_arch("x86_64") then
|
|
|
set_urls("https://github.com/llvm/llvm-project/releases/download/llvmorg-$(version)/clang+llvm-$(version)-amd64-unknown-freebsd13.tar.xz")
|
|
|
add_versions("14.0.0", "b68d73fd57be385e7f06046a87381f7520c8861f492c294e6301d2843d9a1f57")
|
|
|
- elseif os.arch() == "i386" then
|
|
|
+ elseif is_arch("i386") then
|
|
|
set_urls("https://github.com/llvm/llvm-project/releases/download/llvmorg-$(version)/clang+llvm-$(version)-i386-unknown-freebsd13.tar.xz")
|
|
|
add_versions("14.0.0", "81f49eb466ce9149335ac8918a5f02fa724d562a94464ed13745db0165b4a220")
|
|
|
end
|
|
@@ -37,6 +37,8 @@ package("llvm")
|
|
|
add_versions("14.0.0", "35ce9edbc8f774fe07c8f4acdf89ec8ac695c8016c165dd86b8d10e7cba07e23")
|
|
|
end
|
|
|
|
|
|
+ add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
|
|
|
+
|
|
|
add_configs("all", {description = "Enable all projects.", default = false, type = "boolean"})
|
|
|
add_configs("bolt", {description = "Enable bolt project.", default = false, type = "boolean"})
|
|
|
add_configs("clang", {description = "Enable clang project.", default = true, type = "boolean"})
|
|
@@ -56,44 +58,37 @@ package("llvm")
|
|
|
add_configs("libcxxabi", {description = "Enable libcxxabi runtime.", default = true, type = "boolean"})
|
|
|
add_configs("openmp", {description = "Enable openmp runtime.", default = false, type = "boolean"})
|
|
|
|
|
|
- if is_host("linux") then
|
|
|
- add_deps("cmake")
|
|
|
- add_deps("python 3.x", {kind = "binary", host = true})
|
|
|
- add_deps("zlib", "libffi", {host = true})
|
|
|
- add_deps("binutils", {host = true}) -- needed for gold and strip
|
|
|
- end
|
|
|
-
|
|
|
- on_load("@linux", "@bsd", function (package)
|
|
|
- if package:config("openmp") then
|
|
|
- package:add("deps", "libelf", {host = true})
|
|
|
+ on_load(function (package)
|
|
|
+ if package:is_plat("linux") then
|
|
|
+ package:add("deps", "cmake")
|
|
|
+ package:add("deps", "python 3.x", {kind = "binary", host = true})
|
|
|
+ package:add("deps", "zlib", "libffi", {host = true})
|
|
|
+ package:add("deps", "binutils", {host = true}) -- needed for gold and strip
|
|
|
end
|
|
|
- end)
|
|
|
-
|
|
|
- on_fetch(function (package, opt)
|
|
|
- if opt.system then
|
|
|
- local llvm_config = "llvm-config"
|
|
|
- if is_host("macosx") then
|
|
|
- import("lib.detect.find_tool")
|
|
|
- local llvm = try {function () return os.iorunv("brew", {"--prefix", "llvm"}) end}
|
|
|
- if llvm then
|
|
|
- local ret = find_tool("llvm-config", {paths = path.join(llvm:trim(), "bin")})
|
|
|
- if ret then
|
|
|
- llvm_config = ret.program
|
|
|
- end
|
|
|
- end
|
|
|
+ if package:is_plat("linux", "bsd") then
|
|
|
+ if package:config("openmp") then
|
|
|
+ package:add("deps", "libelf", {host = true})
|
|
|
end
|
|
|
- local version = try {function() return os.iorunv(llvm_config, {"--version"}) end}
|
|
|
- if version then
|
|
|
- return {version = version:trim()}
|
|
|
+ end
|
|
|
+ -- add components
|
|
|
+ if package:is_library() then
|
|
|
+ local components = {"mlir", "clang", "libunwind"}
|
|
|
+ for _, name in ipairs(components) do
|
|
|
+ if package:config(name) or package:config("all") then
|
|
|
+ package:add("components", name, {deps = "base"})
|
|
|
+ end
|
|
|
end
|
|
|
+ package:add("components", "base", {default = true})
|
|
|
end
|
|
|
end)
|
|
|
|
|
|
- on_install("@macosx", "@windows", "@msys", "@bsd", function (package)
|
|
|
+ on_fetch("fetch")
|
|
|
+
|
|
|
+ on_install("macosx", "windows", "msys", "bsd", function (package)
|
|
|
os.cp("*", package:installdir())
|
|
|
end)
|
|
|
|
|
|
- on_install("@linux", function (package)
|
|
|
+ on_install("linux", function (package)
|
|
|
local projects = {
|
|
|
"bolt",
|
|
|
"clang",
|
|
@@ -169,11 +164,18 @@ package("llvm")
|
|
|
import("package.tools.cmake").install(package, configs)
|
|
|
end)
|
|
|
|
|
|
+ on_component("mlir", "components.mlir")
|
|
|
+ on_component("clang", "components.clang")
|
|
|
+ on_component("libunwind", "components.libunwind")
|
|
|
+ on_component("base", "components.base")
|
|
|
+
|
|
|
on_test(function (package)
|
|
|
- if not is_host("windows") then
|
|
|
- os.vrun("llvm-config --version")
|
|
|
- end
|
|
|
- if package:config("clang") then
|
|
|
- os.vrun("clang --version")
|
|
|
+ if package:is_toolchain() and not package:is_cross() then
|
|
|
+ if not package:is_plat("windows") then
|
|
|
+ os.vrun("llvm-config --version")
|
|
|
+ end
|
|
|
+ if package:config("clang") then
|
|
|
+ os.vrun("clang --version")
|
|
|
+ end
|
|
|
end
|
|
|
end)
|