소스 검색

Improve opencl (#2254)

* Improve opencl

* Add build type and restrict platforms

* Add long paths policy

* Use prebuilts binaries

* Update xmake.lua

---------

Co-authored-by: ruki <[email protected]>
A2va 2 년 전
부모
커밋
55b319d09d
1개의 변경된 파일29개의 추가작업 그리고 0개의 파일을 삭제
  1. 29 0
      packages/o/opencl/xmake.lua

+ 29 - 0
packages/o/opencl/xmake.lua

@@ -3,8 +3,25 @@ package("opencl")
     set_homepage("https://opencl.org/")
     set_homepage("https://opencl.org/")
     set_description("OpenCL is an open, royalty-free industry standard that makes much faster computations possible through parallel computing.")
     set_description("OpenCL is an open, royalty-free industry standard that makes much faster computations possible through parallel computing.")
 
 
+    if is_plat("windows") then
+        if is_arch("x86", "i386") then
+            set_urls("https://github.com/KhronosGroup/OpenCL-SDK/releases/download/$(version)/OpenCL-SDK-$(version)-Win-x86.zip")
+            add_versions("v2023.04.17", "ff6fa1b4e311a3f655eff4eda28008ec48dccd559ec3ed95ce6d9a584cd3b581")
+        elseif is_arch("x64") then
+            set_urls("https://github.com/KhronosGroup/OpenCL-SDK/releases/download/$(version)/OpenCL-SDK-$(version)-Win-x64.zip")
+            add_versions("v2023.04.17", "11844a1d69a71f82dc14ce66382c6b9fc8a4aee5840c21a786c5accb1d69bc0a")
+        end
+    else 
+        set_urls("https://github.com/KhronosGroup/OpenCL-SDK.git")
+        add_versions("v2023.04.17", "ae7fcae82fe0b7bcc272e43fc324181b2d544eea")
+    end 
+    
     add_configs("vendor", {description = "Set OpenCL Vendor.", default = nil, type = "string", values = {"nvidia", "intel", "amd"}})
     add_configs("vendor", {description = "Set OpenCL Vendor.", default = nil, type = "string", values = {"nvidia", "intel", "amd"}})
 
 
+    if not is_plat("windows") then
+        add_deps("cmake")
+    end
+
     on_fetch(function (package, opt)
     on_fetch(function (package, opt)
         if opt.system then
         if opt.system then
             import("lib.detect.find_path")
             import("lib.detect.find_path")
@@ -64,3 +81,15 @@ package("opencl")
             end
             end
         end
         end
     end)
     end)
+
+    on_install("windows|x86", "windows|x64", function (package)
+        os.cp("lib", package:installdir())
+        os.cp("bin", package:installdir())
+        os.cp("include", package:installdir())
+    end)
+
+    on_install("linux", "macosx", "android", function (package)
+        local configs = {"-DOPENCL_SDK_BUILD_SAMPLES=OFF"}
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
+        import("package.tools.cmake").install(package, configs)
+    end)