-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathmake.lua
More file actions
156 lines (144 loc) · 2.88 KB
/
make.lua
File metadata and controls
156 lines (144 loc) · 2.88 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
local lm = require "luamake"
local fs = require "bee.filesystem"
local function detect_emcc()
if lm.compiler == "emcc" then
return true
end
if type(lm.cc) == "string" and lm.cc:find("emcc", 1, true) then
return true
end
return false
end
local osplat = (function()
if lm.os == "windows" then
if lm.compiler == "gcc" then
return "mingw"
end
if lm.cc == "clang-cl" then
return "clang-cl"
end
return "msvc"
end
return lm.os
end)()
local plat = (function()
if detect_emcc() then
return "emcc"
end
return osplat
end)()
lm.platform = plat
lm.basedir = lm:path "."
lm.bindir = ("bin/%s/%s"):format(plat, lm.mode)
lm.osbindir = ("bin/%s/%s"):format(osplat, lm.mode)
lm:conf {
cxx = "c++20",
clang = {
c = "c11",
},
flags = {
lm.mode ~= "debug" and "-O2",
},
msvc = {
c = "c11",
flags = {
"-W3",
"-utf-8",
"-experimental:c11atomics",
"/wd4244",
"/wd4267",
"/wd4305",
"/wd4996",
"/wd4018",
"/wd4113",
},
defines = {
"_CRT_SECURE_NO_WARNINGS",
"_CRT_NONSTDC_NO_DEPRECATE",
"_CRT_SECURE_NO_DEPRECATE"
},
},
mingw = {
c = "c99",
},
gcc = {
c = "c11",
flags = {
"-Wall",
},
defines = {
"_POSIX_C_SOURCE=199309L",
"_GNU_SOURCE",
},
links = {
"m",
(lm.os ~= "windows" and lm.platform ~= "emcc") and "fontconfig",
},
},
emcc = {
c = "c11",
flags = {
"-Wall",
"-pthread",
"-fPIC",
"--use-port=emdawnwebgpu",
},
links = {
"idbfs.js",
},
ldflags = {
"--js-library=src/platform/wasm/soluna_ime.js",
"--js-library=src/platform/wasm/soluna_openurl.js",
"--use-port=emdawnwebgpu",
"-s ALLOW_MEMORY_GROWTH",
"-s FORCE_FILESYSTEM=1",
'-s EXPORTED_RUNTIME_METHODS=\'["FS","FS_createPath","FS_createDataFile","IDBFS"]\'',
"-s USE_PTHREADS=1",
"-s PTHREAD_POOL_SIZE='Math.max(2,navigator.hardwareConcurrency)'",
"-s PTHREAD_POOL_SIZE_STRICT=2",
lm.mode == "debug" and "-s ASSERTIONS=2",
-- lm.mode == "debug" and "-s SAFE_HEAP=1",
lm.mode == "debug" and "-s STACK_OVERFLOW_CHECK=1",
lm.mode == "debug" and "-s PTHREADS_DEBUG=1",
},
defines = {
"_POSIX_C_SOURCE=200809L",
"_GNU_SOURCE",
},
},
defines = {
-- lm.mode == "debug" and "DEBUGLOG",
lm.mode == "debug" and "SOKOL_DEBUG",
}
}
local deps = { "soluna_src" }
for path in fs.pairs(lm.basedir .. "/clibs") do
local name = path:stem():string()
if name ~= "soluna" and fs.exists(path / "make.lua") then
local makefile = ("clibs/%s/make.lua"):format(name)
lm:import(makefile)
deps[#deps + 1] = name .. "_src"
end
end
lm:import "clibs/soluna/make.lua"
lm:exe "soluna" {
deps = deps,
emcc = {
ldflags = {
"-s MAIN_MODULE=1",
"-Wl,-u,emscripten_builtin_memalign",
"-Wl,--export=emscripten_builtin_memalign",
},
},
}
lm:dll "sample" {
sources = {
"extlua/extlua.c",
"extlua/extlua_sample.c",
},
includes = {
"3rd/lua",
},
}
lm:import "script/act_targets.lua"
lm:default "soluna"