This repository was archived by the owner on Oct 31, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathxmake.lua
More file actions
137 lines (128 loc) · 4.7 KB
/
Copy pathxmake.lua
File metadata and controls
137 lines (128 loc) · 4.7 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
set_languages("cxx17")
if not is_plat("windows") and not is_plat('mingw') then
add_requires("lua")
add_defines("XMAKE_REPO")
end
-- target librimeac.dll for windows or librimeac.so for linux
-- lua static link
if is_plat("windows") then
target("librimeac")
else
target("rimeac")
end
set_kind("shared")
add_files("main.cpp")
add_links("rime")
add_defines("MODULE")
if is_plat("windows", "mingw") then
if is_plat('windows') then
add_shflags("/LARGEADDRESSAWARE")
add_cxflags("/utf-8")
else
add_shflags('-static-libgcc -static-libstdc++ -static', {force=true})
end
add_linkdirs(is_arch("x64", "x86_64") and "lib64" or "lib")
add_includedirs("include", "lua-v5.4")
add_deps("lua54_lib")
else
add_packages('lua')
end
on_install(function(target)
if is_plat("windows", "mingw") then
local function cp_file(file, src, dest)
os.trycp(path.join(src, file), dest)
print("installed " .. path.join(dest, path.filename(path.join(dest, file))))
end
local dist_path = path.join("$(projectdir)", is_arch("x64", "x86_64") and "dist64" or "dist")
cp_file(target:filename(), target:targetdir(), dist_path)
else
os.trycp(path.join(target:targetdir(), target:filename()), "$(projectdir)")
end
end)
-- prepare lua.exe and lua54.dll for windows msvc and mingw build
if is_plat("windows", "mingw") then
target("lua54_lib")
set_kind("static")
add_defines("MAKE_LIB")
add_files("lua-v5.4/onelua.c")
set_filename("lua54.lib")
before_build(function(target)
local target_dir = path.join(target:targetdir(), target:name())
if not os.exists(target_dir) then
os.mkdir(target_dir)
end
target:set("targetdir", target_dir)
target:set("filename", "lua54.lib")
end)
on_install(function(target) return end)
target("lua54")
set_kind("shared")
add_defines("MAKE_LIB", "LUA_BUILD_AS_DLL")
add_files("lua-v5.4/onelua.c")
add_rules("install_target", "add_shflags")
target("lua")
set_kind("binary")
add_files("lua-v5.4/lua.c")
add_deps("lua54", {config={shared = true}})
add_rules("install_target", "add_shflags")
rule("add_shflags")
on_load(function(target)
if is_plat("windows") then
target:add("shflags", "/LARGEADDRESSAWARE", {force=true})
else
target:add("shflags", '-static-libgcc -static-libstdc++ -static', {force=true})
end
end)
rule("install_target")
on_install(function(target)
local function cp_file(file, src, dest)
os.trycp(path.join(src, file), dest)
print("installed " .. path.join(dest, path.filename(path.join(dest, file))))
end
local dist_path = is_arch("x64", "x86_64") and "dist64" or "dist"
cp_file(target:filename(), target:targetdir(), dist_path)
end)
end
-- prepare lua.exe and lua54.dll for windows msvc build end
-- target rimeac.lua.exe
-- lua static link
target("rimeac.lua")
set_kind("binary")
add_files("main.cpp")
if is_plat("windows", "mingw") then
add_linkdirs(is_arch("x64", "x86_64") and "lib64" or "lib")
add_includedirs("include", "lua-v5.4")
add_deps("lua54_lib")
if is_plat('mingw') then
add_ldflags('-static-libgcc -static-libstdc++ -static', {force=true})
elseif is_plat('windows') then
set_symbols("debug")
add_cxflags("/utf-8")
add_ldflags("/LARGEADDRESSAWARE")
end
else
add_packages('lua')
end
add_links("rime")
on_install(function(target)
if is_plat("windows", "mingw") then
local function install_files(target, files, dist_path)
local function cp_file(file, src, dest)
if os.exists(path.join(src, file)) then
os.trycp(path.join(src, file), dest)
print("installed " .. path.join(dest, path.filename(path.join(dest, file))))
end
end
cp_file(target:filename(), target:targetdir(), dist_path)
if is_plat('windows') then cp_file(target:basename()..".pdb", target:targetdir(), dist_path) end
for _, f in ipairs(files) do cp_file(f, "$(projectdir)", dist_path) end
end
local dist_path = path.join("$(projectdir)", is_arch("x64", "x86_64") and "dist64" or "dist")
local rimedll = is_arch("x64", "x86_64") and "lib64/rime.dll" or "lib/rime.dll"
local rimepdb = is_arch("x64", "x86_64") and "lib64/rime.pdb" or "lib/rime.pdb"
os.rm(path.join(dist_path, "log"))
os.rm(path.join(dist_path, "usr"))
install_files(target, {"script.lua", "script_ext.lua", "rime_api_console.lua", "README.md", "LICENSE.txt", rimedll, rimepdb, "shared", "usr"}, dist_path)
os.rm(path.join(dist_path, "usr/.placeholder"))
elseif is_plat("linux") then os.trycp(target:targetfile(), "$(projectdir)") end
end)