-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmake.lua
More file actions
160 lines (137 loc) · 5.17 KB
/
Copy pathxmake.lua
File metadata and controls
160 lines (137 loc) · 5.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
set_project("pyle")
set_version("0.1.0")
set_languages("c++17")
add_rules("mode.debug", "mode.release")
if is_mode("release") then
set_optimize("fastest")
set_symbols("hidden")
add_ldflags("-flto=thin", {force = true})
end
if is_mode("debug") then
set_policy("build.sanitizer.address", true)
set_policy("build.sanitizer.undefined", true)
end
package("lspcpp")
set_homepage("https://github.com/kuafuwang/LspCpp")
set_description("A Language Server Protocol implementation in C++")
add_urls("https://github.com/kuafuwang/LspCpp.git")
add_versions("master", "master")
add_deps("cmake")
if is_plat("windows") then
add_syslinks("ws2_32", "userenv", "bcrypt")
elseif is_plat("linux") then
add_syslinks("pthread")
end
on_install(function (package)
-- PATCH: Fix MinGW build failing on MSVC-only ppltasks.h
if package:is_plat("mingw", "msys") then
for _, file in ipairs(os.files("include/**/*.h")) do
local content = io.readfile(file)
if content and content:find("ppltasks.h", 1, true) then
content = content:gsub("_WIN32", "_MSC_VER")
io.writefile(file, content)
end
end
for _, file in ipairs(os.files("src/**/*.cpp")) do
local content = io.readfile(file)
if content and content:find("ppltasks.h", 1, true) then
content = content:gsub("_WIN32", "_MSC_VER")
io.writefile(file, content)
end
end
end
local configs = {
"-DLSPCPP_BUILD_TESTS=OFF",
"-DLSPCPP_BUILD_EXAMPLES=OFF",
"-DLSPCPP_USE_CPP17=ON",
"-DUSE_TLS=OFF",
"-DUSE_ZLIB=OFF",
"-DLSPCPP_INSTALL=ON" -- CRITICAL: Tells CMake to actually output the headers/lib
}
if package:is_plat("mingw", "msys", "linux", "macosx") then
table.insert(configs, "-DCMAKE_CXX_FLAGS=-Wno-error -Wno-shorten-64-to-32")
end
if package:is_plat("windows") and package:config("vs_runtime") == "MT" then
table.insert(configs, "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded")
end
import("package.tools.cmake").install(package, configs)
-- LspCpp's CMake install step forgets to install the 3rd party headers it relies on.
-- We manually merge them into the package's include directory so your app can find them.
local incdir = package:installdir("include")
os.cp("third_party/rapidjson/include/*", incdir)
os.cp("third_party/utfcpp/source/*", incdir)
os.cp("third_party/asio/asio/include/*", incdir)
end)
package_end()
add_requires("fmt 12.2.0", {configs = {header_only = true}})
add_requires("unordered_dense 4.8.1", "argparse 3.2", "simdjson 4.2.4")
add_requires("raylib 5.5")
add_requires("nlohmann_json 3.11.3")
add_requires("lspcpp")
add_cxxflags("/utf-8", {tools = "cl"})
add_rules("plugin.compile_commands.autoupdate")
target("libpyle")
set_kind("$(kind)")
add_files("libpyle/src/**.cpp")
add_includedirs("libpyle/include", {public = true})
add_packages("fmt", "unordered_dense", {public = true})
if is_mode("release") then
set_policy("build.optimization.lto", true)
end
target("pyle")
set_kind("binary")
add_files("pyle/src/main.cpp")
add_files("pyle/src/std/std_json.cpp")
add_packages("argparse", "simdjson")
add_deps("libpyle")
set_rundir("$(projectdir)")
if is_mode("release") then
set_policy("build.optimization.lto", true)
end
after_build(function (target)
import("core.project.project")
os.cp("$(projectdir)/std", target:targetdir())
end)
target("raylib")
set_kind("shared")
set_filename("raylib.pyled")
add_files("pyle/src/std/vendor/raylib/**.cpp")
add_packages("raylib")
add_deps("libpyle")
after_build(function (target)
local outdir = target:targetdir()
local stddir = path.join(outdir, "std")
os.mkdir(stddir)
os.cp(target:targetfile(), path.join(stddir, "raylib.pyled"))
os.cp(target:targetfile(), path.join("$(projectdir)/std", "raylib.pyled"))
end)
target("example_basic_embedding")
set_kind("binary")
set_languages("c++17")
add_files("examples_cpp/01_basic_embedding.cpp")
add_deps("libpyle")
target("example_function_binding")
set_kind("binary")
set_languages("c++17")
add_files("examples_cpp/02_function_binding.cpp")
add_deps("libpyle")
target("example_class_binding")
set_kind("binary")
set_languages("c++17")
add_files("examples_cpp/03_class_binding.cpp")
add_deps("libpyle")
target("pyle-lsp")
set_kind("binary")
add_files("pyle-lsp/src/main.cpp")
add_packages("nlohmann_json", "lspcpp")
add_deps("libpyle")
set_rundir("$(projectdir)")
set_runtimes("MT")
if is_plat("mingw", "msys") then
add_ldflags("-static", {force = true})
end
target("example_async_binding")
set_kind("binary")
set_languages("c++17")
add_files("examples_cpp/04_async_binding.cpp")
add_deps("libpyle")