1# Copyright Rene Rivera 2016 2# Distributed under the Boost Software License, Version 1.0. 3# (See accompanying file LICENSE_1_0.txt 4# or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6import feature ; 7import os ; 8import toolset ; 9import common ; 10import gcc ; 11import type ; 12 13feature.feature embind : off on : propagated ; 14feature.feature closure : off on full : propagated ; 15feature.feature link-optimization : off on full : propagated ; 16 17rule init ( version ? : command * : options * ) 18{ 19 command = [ common.get-invocation-command emscripten 20 : emcc 21 : $(command) ] ; 22 23 # Determine the version 24 if $(command) 25 { 26 local command-string = \"$(command)\" ; 27 command-string = $(command-string:J=" ") ; 28 version ?= [ MATCH "([0-9.]+)" 29 : [ SHELL "$(command-string) --version" ] ] ; 30 } 31 32 local condition = [ common.check-init-parameters emscripten 33 : version $(version) ] ; 34 35 common.handle-options emscripten : $(condition) : $(command) : $(options) ; 36} 37 38feature.extend toolset : emscripten ; 39 40toolset.inherit-generators emscripten <toolset>emscripten 41 : gcc 42 : gcc.mingw.link gcc.mingw.link.dll gcc.compile.c.pch gcc.compile.c++.pch 43 ; 44toolset.inherit-rules emscripten : gcc ; 45toolset.inherit-flags emscripten : gcc 46 : 47 <optimization>off <optimization>speed <optimization>space 48 <profiling>off <profiling>on 49 <debug-symbols>off <debug-symbols>on 50 <rtti>off <rtti>on 51 ; 52 53type.set-generated-target-suffix EXE : <toolset>emscripten : "js" ; 54type.set-generated-target-suffix OBJ : <toolset>emscripten : "bc" ; 55type.set-generated-target-suffix STATIC_LIB : <toolset>emscripten : "bc" ; 56 57toolset.flags emscripten.compile OPTIONS <flags> ; 58toolset.flags emscripten.compile OPTIONS <cflags> ; 59toolset.flags emscripten.compile.c++ OPTIONS <cxxflags> ; 60 61toolset.flags emscripten.compile OPTIONS <optimization>off : -O0 ; 62toolset.flags emscripten.compile OPTIONS <optimization>speed : -O3 ; 63toolset.flags emscripten.compile OPTIONS <optimization>space : -Oz ; 64toolset.flags emscripten.link OPTIONS <optimization>off : -O0 ; 65toolset.flags emscripten.link OPTIONS <optimization>speed : -O3 ; 66toolset.flags emscripten.link OPTIONS <optimization>space : -O3 ; 67 68toolset.flags emscripten.compile OPTIONS <profiling>on : --profiling-funcs ; 69 70toolset.flags emscripten.compile OPTIONS <inlining>off : -fno-inline ; 71toolset.flags emscripten.compile OPTIONS <inlining>on : -Wno-inline ; 72toolset.flags emscripten.compile OPTIONS <inlining>full : -Wno-inline ; 73 74toolset.flags emscripten OPTIONS <debug-symbols>off : -g0 ; 75toolset.flags emscripten OPTIONS <debug-symbols>on : -g4 -s DEMANGLE_SUPPORT=1 ; 76toolset.flags emscripten OPTIONS <rtti>off : -fno-rtti ; 77 78toolset.flags emscripten.link OPTIONS <embind>on : --bind ; 79toolset.flags emscripten.link OPTIONS <closure>on : --closure 1 ; 80toolset.flags emscripten.link OPTIONS <closure>full : --closure 2 ; 81toolset.flags emscripten.link OPTIONS <link-optimization>off : --llvm-lto 0 ; 82toolset.flags emscripten.link OPTIONS <link-optimization>on : --llvm-lto 1 ; 83toolset.flags emscripten.link OPTIONS <link-optimization>full : --llvm-lto 3 ; 84 85actions compile.c 86{ 87 "$(CONFIG_COMMAND)" -x c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" 88} 89 90actions compile.c++ 91{ 92 "$(CONFIG_COMMAND)" -x c++ $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" 93} 94 95actions archive 96{ 97 "$(CONFIG_COMMAND)" $(AROPTIONS) -o "$(<)" "$(>)" 98} 99 100toolset.flags emscripten.link USER_OPTIONS <linkflags> ; 101 102actions link bind LIBRARIES 103{ 104 "$(CONFIG_COMMAND)" $(USER_OPTIONS) -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" $(START-GROUP) $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) 105} 106