浏览代码

improve llvm

ruki 4 年之前
父节点
当前提交
d65dade80e
共有 1 个文件被更改,包括 20 次插入5 次删除
  1. 20 5
      packages/l/llvm/xmake.lua

+ 20 - 5
packages/l/llvm/xmake.lua

@@ -57,10 +57,6 @@ package("llvm")
         end
     end
 
-    on_install("@macosx", "@windows", "@msys", "@bsd", function (package)
-        os.cp("*", package:installdir())
-    end)
-
     on_load("@linux", function (package)
         if linuxos.name() == "ubuntu" and linuxos.version():eq("20.04") and os.arch() == "x86_64" then
             return
@@ -69,6 +65,22 @@ package("llvm")
         end
     end)
 
+    if on_fetch then
+        on_fetch(function (package, opt)
+            local version = try {function() return os.iorunv("llvm-config --version") end}
+            if version then
+                import("core.base.semver")
+                if semver.satisfies(version:trim(), opt.require_version) then
+                    return true
+                end
+            end
+        end)
+    end
+
+    on_install("@macosx", "@windows", "@msys", "@bsd", function (package)
+        os.cp("*", package:installdir())
+    end)
+
     on_install("@linux", function (package)
 
         if linuxos.name() == "ubuntu" and linuxos.version():eq("20.04") and os.arch() == "x86_64" then
@@ -144,5 +156,8 @@ package("llvm")
     end)
 
     on_test(function (package)
-        os.vrun("clang --version")
+        os.vrun("llvm-config --version")
+        if package:config("clang") then
+            os.vrun("clang --version")
+        end
     end)