Imported Upstream version 1.64.0
[platform/upstream/boost.git] / tools / build / src / tools / emscripten.jam
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
6 import feature ;
7 import os ;
8 import toolset ;
9 import common ;
10 import gcc ;
11 import type ;
12
13 feature.feature embind : off on : propagated ;
14 feature.feature closure : off on full : propagated ;
15 feature.feature link-optimization : off on full : propagated ;
16
17 rule 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
38 feature.extend toolset : emscripten ;
39
40 toolset.inherit-generators emscripten <toolset>emscripten
41     : gcc
42     : gcc.mingw.link gcc.mingw.link.dll gcc.compile.c.pch gcc.compile.c++.pch
43     ;
44 toolset.inherit-rules emscripten : gcc ;
45 toolset.inherit-flags emscripten : gcc 
46         :
47         <optimization>off <optimization>speed <optimization>space
48         <profiling>off <profiling>on
49         <inlining>off <inlining>on <inlining>full
50         <warnings>off <warnings>all <warnings>on
51         <warnings-as-errors>off <warnings-as-errors>on
52         <debug-symbols>off <debug-symbols>on
53         <rtti>off <rtti>on
54         ;
55
56 type.set-generated-target-suffix EXE : <toolset>emscripten : "js" ;
57 type.set-generated-target-suffix OBJ : <toolset>emscripten : "bc" ;
58 type.set-generated-target-suffix STATIC_LIB : <toolset>emscripten : "bc" ;
59
60 toolset.flags emscripten.compile OPTIONS <flags> ;
61 toolset.flags emscripten.compile OPTIONS <cflags> ;
62 toolset.flags emscripten.compile.c++ OPTIONS <cxxflags> ;
63
64 toolset.flags emscripten.compile OPTIONS <optimization>off : -O0 ;
65 toolset.flags emscripten.compile OPTIONS <optimization>speed : -O3 ;
66 toolset.flags emscripten.compile OPTIONS <optimization>space : -Oz ;
67 toolset.flags emscripten.link OPTIONS <optimization>off : -O0 ;
68 toolset.flags emscripten.link OPTIONS <optimization>speed : -O3 ;
69 toolset.flags emscripten.link OPTIONS <optimization>space : -O3 ;
70
71 toolset.flags emscripten.compile OPTIONS <profiling>on : --profiling-funcs ;
72
73 toolset.flags emscripten.compile OPTIONS <inlining>off : -fno-inline ;
74 toolset.flags emscripten.compile OPTIONS <inlining>on : -Wno-inline ;
75 toolset.flags emscripten.compile OPTIONS <inlining>full : -Wno-inline ;
76
77 toolset.flags emscripten.compile OPTIONS <warnings>off : -w ;
78 toolset.flags emscripten.compile OPTIONS <warnings>on : -Wall ;
79 toolset.flags emscripten.compile OPTIONS <warnings>all : -Wall -pedantic ;
80 toolset.flags emscripten.compile OPTIONS <warnings-as-errors>on : -Werror ;
81
82 toolset.flags emscripten OPTIONS <debug-symbols>off : -g0 ;
83 toolset.flags emscripten OPTIONS <debug-symbols>on : -g4 -s DEMANGLE_SUPPORT=1 ;
84 toolset.flags emscripten OPTIONS <rtti>off : -fno-rtti ;
85
86 toolset.flags emscripten.link OPTIONS <embind>on : --bind ;
87 toolset.flags emscripten.link OPTIONS <closure>on : --closure 1 ;
88 toolset.flags emscripten.link OPTIONS <closure>full : --closure 2 ;
89 toolset.flags emscripten.link OPTIONS <link-optimization>off : --llvm-lto 0 ;
90 toolset.flags emscripten.link OPTIONS <link-optimization>on : --llvm-lto 1 ;
91 toolset.flags emscripten.link OPTIONS <link-optimization>full : --llvm-lto 3 ;
92
93 actions compile.c
94 {
95     "$(CONFIG_COMMAND)" -x c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
96 }
97
98 actions compile.c++
99 {
100     "$(CONFIG_COMMAND)" -x c++ $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
101 }
102
103 actions archive
104 {
105     "$(CONFIG_COMMAND)" $(AROPTIONS) -o "$(<)" "$(>)"
106 }
107
108 toolset.flags emscripten.link USER_OPTIONS <linkflags> ;
109
110 actions link bind LIBRARIES
111 {
112     "$(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)
113 }