@@ -25,8 +25,11 @@ import("core.project.config")
2525import (" core.tool.toolchain" )
2626import (" core.platform.platform" )
2727import (" lib.detect.find_tool" )
28+ import (" lib.detect.find_file" )
29+ import (" detect.sdks.find_emsdk" )
2830import (" devel.git" )
2931import (" net.fasturl" )
32+ import (" package.manager.conan.configurations" )
3033
3134-- get build env
3235function _conan_get_build_env (name , plat )
@@ -110,45 +113,6 @@ function _conan_install_xmake_generator(conan)
110113 end
111114end
112115
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-
152116-- get compiler version
153117--
154118-- 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)
229193 end
230194 conf = {}
231195 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 .. " ']"
232210 else
233211 local program , toolname = platform .tool (" cc" , plat , arch )
234212 if toolname == " gcc" or toolname == " clang" then
261239function _conan_generate_build_profile (configs , opt )
262240 local profile = io.open (" profile_build.txt" , " w" )
263241 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 ()))
267245 _conan_generate_compiler_profile (profile , configs , {plat = os .host (), arch = os .arch ()})
268246 profile :close ()
269247end
272250function _conan_generate_host_profile (configs , opt )
273251 local profile = io.open (" profile_host.txt" , " w" )
274252 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 ))
278256 _conan_generate_compiler_profile (profile , configs , opt )
279257 profile :close ()
280258end
0 commit comments