Skip to content

Commit 24f2764

Browse files
authored
add enoki and fcpw (#5002)
* add enoki * add fcpw * fix enoki on mingw * test on more platforms
1 parent e0241c0 commit 24f2764

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

packages/e/enoki/xmake.lua

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package("enoki")
2+
3+
set_homepage("https://github.com/mitsuba-renderer/enoki")
4+
set_description("Enoki: structured vectorization and differentiation on modern processor architectures")
5+
set_license("BSD-3-Clause")
6+
7+
add_urls("https://github.com/mitsuba-renderer/enoki.git")
8+
add_versions("2024.04.19", "63a5f4c0a35a8513a39393a9ee92646ce44a386e")
9+
10+
add_configs("shared", {description = "Build shared library", default = true, type = "boolean", readonly = true})
11+
add_configs("cuda", {description = "Build Enoki CUDA library", default = false, type = "boolean"})
12+
add_configs("cudacc", {description = "CUDA compute capability", default = "75", type = "string", values = {"35", "50", "52", "60", "61", "70", "75", "80", "86", "89", "90"}})
13+
add_configs("autodiff", {description = "Build Enoki automatic differentation library", default = false, type = "boolean"})
14+
add_configs("python", {description = "Build pybind11 interface to CUDA & automatic differentiation libraries", default = false, type = "boolean"})
15+
16+
on_load(function (package)
17+
if package:config("cuda") then
18+
package:add("deps", "cuda")
19+
end
20+
if package:config("python") then
21+
package:add("deps", "python 3.x")
22+
end
23+
if package:config("cuda") or package:config("autodiff") then
24+
package:add("deps", "cmake")
25+
else
26+
package:set("kind", "library", {headeronly = true})
27+
end
28+
end)
29+
30+
on_install("windows", "macosx", "linux", "mingw", function (package)
31+
os.cp("include/enoki", package:installdir("include"))
32+
if package:config("cuda") or package:config("autodiff") then
33+
local configs = {}
34+
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
35+
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
36+
table.insert(configs, "-DENOKI_CUDA=" .. (package:config("cuda") and "ON" or "OFF"))
37+
if package:config("cuda") then
38+
table.insert(configs, "-DENOKI_CUDA_COMPUTE_CAPABILITY=" .. package:config("cudacc"))
39+
end
40+
table.insert(configs, "-DENOKI_AUTODIFF=" .. (package:config("autodiff") and "ON" or "OFF"))
41+
table.insert(configs, "-DENOKI_PYTHON=" .. (package:config("python") and "ON" or "OFF"))
42+
import("package.tools.cmake").install(package, configs)
43+
end
44+
end)
45+
46+
on_test(function (package)
47+
assert(package:check_cxxsnippets({test = [[
48+
#ifndef _USE_MATH_DEFINES
49+
#define _USE_MATH_DEFINES
50+
#endif
51+
#include <enoki/array.h>
52+
void test() {
53+
enoki::Array<int, 4> idx(1, 2, 3, 4);
54+
using MyFloat = enoki::Array<float, 4>;
55+
MyFloat a = enoki::zero<MyFloat>();
56+
}
57+
]]}, {configs = {languages = "c++17"}}))
58+
end)

packages/f/fcpw/xmake.lua

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package("fcpw")
2+
set_homepage("https://github.com/rohan-sawhney/fcpw")
3+
set_description("FCPW: Fastest Closest Points in the West")
4+
set_license("MIT")
5+
6+
add_urls("https://github.com/rohan-sawhney/fcpw.git")
7+
add_versions("v1.0.5", "9a0c41ae44fbcbf32a1740adec7a2a79eded249f")
8+
9+
add_configs("enoki", {description = "Build enoki backend", default = false, type = "boolean"})
10+
add_configs("gpu", {description = "Enable GPU support", default = false, type = "boolean"})
11+
add_configs("python", {description = "Build python binding", default = false, type = "boolean"})
12+
13+
add_deps("eigen")
14+
on_load(function (package)
15+
if package:config("enoki") then
16+
package:add("deps", "enoki")
17+
package:add("defines", "FCPW_USE_ENOKI")
18+
-- define FCPW_SIMD_WIDTH by user
19+
end
20+
if package:config("gpu") then
21+
package:add("defines", "FCPW_USE_GPU")
22+
end
23+
if package:config("python") then
24+
package:add("deps", "cmake")
25+
package:add("deps", "python 3.x")
26+
else
27+
package:set("kind", "library", {headeronly = true})
28+
end
29+
end)
30+
31+
on_install(function (package)
32+
os.cp("include/fcpw", package:installdir("include"))
33+
if package:config("python") then
34+
local configs = {}
35+
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
36+
table.insert(configs, "-DFCPW_USE_ENOKI=" .. (package:config("enoki") and "ON" or "OFF"))
37+
table.insert(configs, "-DFCPW_ENABLE_GPU_SUPPORT=" .. (package:config("gpu") and "ON" or "OFF"))
38+
table.insert(configs, "-DFCPW_BUILD_BINDINGS=" .. (package:config("python") and "ON" or "OFF"))
39+
import("package.tools.cmake").install(package, configs)
40+
end
41+
end)
42+
43+
on_test(function (package)
44+
assert(package:check_cxxsnippets({test = [[
45+
#include <fcpw/fcpw.h>
46+
void test() {
47+
fcpw::Scene<3> scene;
48+
scene.setObjectCount(1);
49+
scene.build(fcpw::AggregateType::Bvh_SurfaceArea, true);
50+
}
51+
]]}, {configs = {languages = "c++17"}}))
52+
end)

0 commit comments

Comments
 (0)