@@ -25,8 +25,11 @@ import("core.project.config")
25
25
import (" core.tool.toolchain" )
26
26
import (" core.platform.platform" )
27
27
import (" lib.detect.find_tool" )
28
+ import (" lib.detect.find_file" )
29
+ import (" detect.sdks.find_emsdk" )
28
30
import (" devel.git" )
29
31
import (" net.fasturl" )
32
+ import (" package.manager.conan.configurations" )
30
33
31
34
-- get build env
32
35
function _conan_get_build_env (name , plat )
@@ -110,45 +113,6 @@ function _conan_install_xmake_generator(conan)
110
113
end
111
114
end
112
115
113
- -- get arch
114
- function _conan_get_arch (arch )
115
- local map = {x86_64 = " x86_64" ,
116
- x64 = " x86_64" ,
117
- i386 = " x86" ,
118
- x86 = " x86" ,
119
- armv7 = " armv7" ,
120
- [" armv7-a" ] = " armv7" , -- for android, deprecated
121
- [" armeabi" ] = " armv7" , -- for android, removed in ndk r17
122
- [" armeabi-v7a" ] = " armv7" , -- for android
123
- armv7s = " armv7s" , -- for iphoneos
124
- arm64 = " armv8" , -- for iphoneos
125
- [" arm64-v8a" ] = " armv8" , -- for android
126
- mips = " mips" ,
127
- mips64 = " mips64" }
128
- return assert (map [arch ], " unknown arch(%s)!" , arch )
129
- end
130
-
131
- -- get os
132
- function _conan_get_os (plat )
133
- local map = {macosx = " Macos" ,
134
- windows = " Windows" ,
135
- mingw = " Windows" ,
136
- linux = " Linux" ,
137
- cross = " Linux" ,
138
- iphoneos = " iOS" ,
139
- android = " Android" }
140
- return assert (map [plat ], " unknown os(%s)!" , plat )
141
- end
142
-
143
- -- get build type
144
- function _conan_get_build_type (mode )
145
- if mode == " debug" then
146
- return " Debug"
147
- else
148
- return " Release"
149
- end
150
- end
151
-
152
116
-- get compiler version
153
117
--
154
118
-- https://github.com/conan-io/conan/blob/353c63b16c31c90d370305b5cbb5dc175cf8a443/conan/tools/microsoft/visual.py#L13
@@ -229,6 +193,20 @@ function _conan_generate_compiler_profile(profile, configs, opt)
229
193
end
230
194
conf = {}
231
195
conf [" tools.android:ndk_path" ] = ndk :config (" ndk" )
196
+ elseif plat == " wasm" then
197
+ local emsdk = find_emsdk ()
198
+ assert (emsdk and emsdk .emscripten , " emscripten not found!" )
199
+ local emscripten_cmakefile = find_file (" Emscripten.cmake" , path .join (emsdk .emscripten , " cmake/Modules/Platform" ))
200
+ assert (emscripten_cmakefile , " Emscripten.cmake not found!" )
201
+
202
+ profile :print (" compiler=gcc" )
203
+ profile :print (" compiler.cppstd=gnu17" )
204
+ profile :print (" compiler.libcxx=libstdc++11" )
205
+ profile :print (" compiler.version=12" )
206
+
207
+ conf = {}
208
+ conf [" tools.build:compiler_executables" ] = " {'c':'emcc', 'cpp':'em++', 'ar':'emar', 'ranlib':'emranlib'}"
209
+ conf [" tools.cmake.cmaketoolchain:user_toolchain" ] = " ['" .. emscripten_cmakefile .. " ']"
232
210
else
233
211
local program , toolname = platform .tool (" cc" , plat , arch )
234
212
if toolname == " gcc" or toolname == " clang" then
261
239
function _conan_generate_build_profile (configs , opt )
262
240
local profile = io.open (" profile_build.txt" , " w" )
263
241
profile :print (" [settings]" )
264
- profile :print (" arch=%s" , _conan_get_arch (os .arch ()))
265
- profile :print (" build_type=%s" , _conan_get_build_type (opt .mode ))
266
- profile :print (" os=%s" , _conan_get_os (os .host ()))
242
+ profile :print (" arch=%s" , configurations . arch (os .arch ()))
243
+ profile :print (" build_type=%s" , configurations . build_type (opt .mode ))
244
+ profile :print (" os=%s" , configurations . plat (os .host ()))
267
245
_conan_generate_compiler_profile (profile , configs , {plat = os .host (), arch = os .arch ()})
268
246
profile :close ()
269
247
end
272
250
function _conan_generate_host_profile (configs , opt )
273
251
local profile = io.open (" profile_host.txt" , " w" )
274
252
profile :print (" [settings]" )
275
- profile :print (" arch=%s" , _conan_get_arch (opt .arch ))
276
- profile :print (" build_type=%s" , _conan_get_build_type (opt .mode ))
277
- profile :print (" os=%s" , _conan_get_os (opt .plat ))
253
+ profile :print (" arch=%s" , configurations . arch (opt .arch ))
254
+ profile :print (" build_type=%s" , configurations . build_type (opt .mode ))
255
+ profile :print (" os=%s" , configurations . plat (opt .plat ))
278
256
_conan_generate_compiler_profile (profile , configs , opt )
279
257
profile :close ()
280
258
end
0 commit comments