Skip to content

Commit 7a75241

Browse files
Willaaaaaaaluadebugstar-hengxing
authored
dynareadout: update url and add py-bind config (#8623)
* dynareadout: refactor package configuration and add Python support * fix(dynareadout): update boost dependency to disable filesystem support on macOS * fix(dynareadout): enable filesystem support for boost on macOS * fix(dynareadout): add boost dependency for macOS support in C++ target * [WIP]improve xmake port, add py-bind opt * improve xmake.lua * update xmake.lua * fix mac * fix windows --------- Co-authored-by: Saikari <lin@sz.cn.eu.org> Co-authored-by: star9029 <hengxings783@gmail.com>
1 parent 3c66ef1 commit 7a75241

File tree

2 files changed

+87
-35
lines changed

2 files changed

+87
-35
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
set_project("dynareadout")
2+
add_rules("mode.debug", "mode.release")
3+
4+
option("build_cpp", {default = true})
5+
option("build_python", {default = false})
6+
option("profiling", {default = false, defines = "PROFILING"})
7+
8+
target("dynareadout")
9+
set_kind("$(kind)")
10+
set_languages("ansi")
11+
add_options("profiling")
12+
add_files("src/*.c")
13+
if not has_config("profiling") then
14+
remove_files("src/profiling.c")
15+
end
16+
add_headerfiles("src/*.h")
17+
if is_kind("shared") then
18+
add_rules("utils.symbols.export_all")
19+
end
20+
target_end()
21+
22+
if has_config("build_cpp", "build_python") then
23+
if is_plat("macosx") then
24+
add_requires("boost", {configs = {filesystem = true}})
25+
end
26+
target("dynareadout_cpp")
27+
set_kind("$(kind)")
28+
set_languages("cxx17")
29+
add_deps("dynareadout")
30+
add_includedirs("src")
31+
add_files("src/cpp/*.cpp")
32+
add_headerfiles("src/cpp/*.hpp")
33+
if is_kind("shared") then
34+
add_rules("utils.symbols.export_all", {export_classes = true})
35+
end
36+
if is_plat("macosx") then
37+
add_packages("boost", {public = true})
38+
end
39+
target_end()
40+
end
41+
42+
if has_config("build_python") then
43+
add_requires("pybind11")
44+
target("pybind11_module")
45+
set_languages("cxx17")
46+
add_deps("dynareadout_cpp")
47+
add_packages("pybind11")
48+
add_rules("python.module")
49+
set_basename("dynareadout" .. (is_mode("debug") and "_d" or ""))
50+
add_options("profiling")
51+
add_files("src/python/*.cpp")
52+
add_headerfiles("src/python/*.hpp")
53+
add_includedirs("src", "src/cpp")
54+
add_rpathdirs("@executable_path")
55+
end

packages/d/dynareadout/xmake.lua

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,57 @@
11
package("dynareadout")
2-
32
set_homepage("https://github.com/PucklaJ/dynareadout")
43
set_description("High-Performance C/C++ library for parsing binary output files and key files of LS Dyna (d3plot, binout, input deck)")
54
set_license("zlib")
65

7-
add_urls("https://github.com/PucklaJ/dynareadout/archive/refs/tags/$(version).tar.gz",
8-
"https://github.com/PucklaJ/dynareadout.git")
9-
add_versions("24.07", "9b43e0e16d86b04f02d3bb45d7b999cb559ef229b85455a403b89415e761e7bb")
10-
add_versions("24.05", "86e045f23d1e1d3ed2e002774f8f04badc5c974c3441bdc07f3a82c5711328c9")
11-
add_versions("24.03", "d91feb2ebfa604b543dd6d98c3dd5aee5c489e6987159fef78dfcea1aad64bd5")
12-
add_versions("22.12", "2e430c718c610d4425e23d4c6c87fe4794bb8c76d3cc015988706dbf5027daa4")
13-
add_versions("23.01", "578080c734927cc925e7e91a52317bc3e710965071f1da50853b1e48f81a1c0f")
14-
add_versions("23.02", "054949a8774089fc217d7c0ec02996b53d331794c41941ed5006b90715bb4d30")
15-
add_versions("23.04", "929efad70c68931f35c76336ea8b23bf2da46022d5fd570f4efc06d776a94604")
16-
add_versions("23.05", "d33bb3acf6f62f7801c58755efbd49bfec2def37aee5397a17e2c38d8216bff6")
17-
add_versions("23.06", "515f0b0d20c46e00f393fb9bb0f2baf303244d39e35a080741276681eb454926")
18-
add_versions("23.07", "6db52a13771cdb7613b97cf0d2bcffdb87ce0cce4cba7e6d80330977b2ac6210")
19-
add_versions("23.08", "5be972426f67ce63a7ac3beaf3866b824abbc9c15af2d47d1fea21687417b493")
20-
add_versions("23.09", "a62e0575521aacf3f567dfd578d6edc51edc07d4b744e5b5ae5d30f662be424b")
21-
add_versions("23.10", "834d356e80019a7288001c2796c9ce14c2a8e5494c1051fae402f4503b10c1e5")
22-
add_versions("23.10.1", "6ebb6e9d9b3db637476cc9bd5342e4779be175f87225261da35c9270790e77d7")
23-
add_versions("23.11", "2222bea87af9289dbc1a52adc5f09058863c503003e94193ca9388eff9e4ff04")
24-
add_versions("23.12", "6afc9c0857b6227e39466aae00db606d3376e61d518bb73544d8240fe3a66a90")
25-
add_versions("24.01", "f39094567272816c9a7dd84d3eaa0ef5c26309eeeadba814cac12f82e93ae0e1")
26-
add_versions("24.02", "acd483bd737a7769087befa1eb2010426c1328bb84ab0481ea11cdeb7655c64e")
6+
add_urls("https://github.com/xmake-mirror/dynareadout/releases/download/$(version)/$(version).tar.gz")
7+
add_versions("24.07", "11138c1236f44434adf99ad86dc3315fcba17e59dd4b0ae0e6564972e2de12c5")
8+
9+
add_configs("cpp_bind", {description = "Build the C++ bindings", default = true, type = "boolean"})
10+
add_configs("profiling", {description = "Build with profiling features", default = true, type = "boolean"})
11+
if is_plat("mingw") then
12+
add_configs("python_bind", {description = "Build the python bindings", default = false, type = "boolean", readonly = true})
13+
else
14+
add_configs("python_bind", {description = "Build the python bindings", default = true, type = "boolean"})
15+
end
2716

28-
add_configs("cpp", {description = "Build the C++ bindings", default = true, type = "boolean"})
29-
add_configs("profiling", {description = "Build with profiling features", default = false, type = "boolean"})
30-
add_configs("thread_safe", {description = "Build with synchronisation for thread safety", default = true, type = "boolean"})
17+
on_check("windows", function (package)
18+
if package:config("python_bind") then
19+
if not package:is_arch("x64", "arm64") or package:is_cross() then
20+
raise("package(dynareadout) python bind is only supported windows x64/arm64 native build")
21+
end
22+
end
23+
end)
3124

3225
on_load(function (package)
33-
if package:config("cpp") then
26+
wprint("The original repository PucklaJ/dynareadout is no longer public. You are using a mirror of this repository.")
27+
if package:config("cpp_bind") then
3428
package:add("links", "dynareadout_cpp", "dynareadout")
3529
else
3630
package:add("links", "dynareadout")
3731
end
32+
if package:config("python_bind") and not package:is_plat("mingw") then
33+
package:add("deps", "pybind11")
34+
end
3835
if package:is_plat("macosx") then
39-
package:add("deps", "boost")
36+
package:add("deps", "boost", {configs = {filesystem = true}})
4037
end
4138
end)
4239

4340
on_install("windows", "linux", "macosx", "mingw", function (package)
4441
local configs = {}
45-
configs.build_test = "n"
46-
configs.build_cpp = package:config("cpp") and "y" or "n"
47-
configs.profiling = package:config("profiling") and "y" or "n"
48-
configs.thread_safe = package:config("thread_safe") and "y" or "n"
42+
configs.build_cpp = package:config("cpp_bind")
43+
configs.profiling = package:config("profiling")
44+
configs.build_python = package:config("python_bind")
45+
46+
os.cd("lib/dynareadout")
47+
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
4948
import("package.tools.xmake").install(package, configs)
5049
end)
5150

5251
on_test(function (package)
5352
assert(package:has_cfuncs("binout_open", {includes = "binout.h", configs = {languages = "ansi"}}))
5453
assert(package:has_cfuncs("d3plot_open", {includes = "d3plot.h", configs = {languages = "ansi"}}))
55-
if package:config("cpp") then
54+
if package:config("cpp_bind") then
5655
assert(package:has_cxxtypes("dro::Binout", {includes = "binout.hpp", configs = {languages = "cxx17"}}))
5756
assert(package:has_cxxtypes("dro::D3plot", {includes = "d3plot.hpp", configs = {languages = "cxx17"}}))
5857
assert(package:has_cxxtypes("dro::Array<int32_t>", {includes = {"array.hpp", "cstdint"}, configs = {languages = "cxx17"}}))
@@ -68,8 +67,6 @@ package("dynareadout")
6867
}
6968
]]}, {includes = "profiling.h", configs = {languages = "ansi"}}))
7069
end
71-
if package:config("thread_safe") then
72-
assert(package:has_cfuncs("sync_create", {includes = "sync.h", configs = {languages = "ansi"}}))
73-
assert(package:has_cfuncs("sync_lock", {includes = "sync.h", configs = {languages = "ansi"}}))
74-
end
70+
assert(package:has_cfuncs("sync_create", {includes = "sync.h", configs = {languages = "ansi"}}))
71+
assert(package:has_cfuncs("sync_lock", {includes = "sync.h", configs = {languages = "ansi"}}))
7572
end)

0 commit comments

Comments
 (0)