27
27
28
28
import platform
29
29
import re
30
- import subprocess
31
30
import sys
32
31
import os
33
32
from os .path import join , dirname , abspath
@@ -143,9 +142,6 @@ LIBRARY_FLAGS = {
143
142
# Use visibility=default to disable this.
144
143
'CXXFLAGS' : ['-fvisibility=hidden' ]
145
144
},
146
- 'strictaliasing:off' : {
147
- 'CCFLAGS' : ['-fno-strict-aliasing' ]
148
- },
149
145
'mode:debug' : {
150
146
'CCFLAGS' : ['-g' , '-O0' ],
151
147
'CPPDEFINES' : ['ENABLE_DISASSEMBLER' , 'DEBUG' ],
@@ -655,16 +651,8 @@ def Abort(message):
655
651
sys .exit (1 )
656
652
657
653
658
- def GuessOS (env ):
659
- return utils .GuessOS ()
660
-
661
-
662
- def GuessArch (env ):
663
- return utils .GuessArchitecture ()
664
-
665
-
666
- def GuessToolchain (env ):
667
- tools = env ['TOOLS' ]
654
+ def GuessToolchain (os ):
655
+ tools = Environment ()['TOOLS' ]
668
656
if 'gcc' in tools :
669
657
return 'gcc'
670
658
elif 'msvc' in tools :
@@ -673,9 +661,7 @@ def GuessToolchain(env):
673
661
return None
674
662
675
663
676
- def GuessVisibility (env ):
677
- os = env ['os' ]
678
- toolchain = env ['toolchain' ];
664
+ def GuessVisibility (os , toolchain ):
679
665
if (os == 'win32' or os == 'cygwin' ) and toolchain == 'gcc' :
680
666
# MinGW / Cygwin can't do it.
681
667
return 'default'
@@ -685,35 +671,27 @@ def GuessVisibility(env):
685
671
return 'hidden'
686
672
687
673
688
- def GuessStrictAliasing (env ):
689
- # There seems to be a problem with gcc 4.5.x
690
- # see http://code.google.com/p/v8/issues/detail?id=884
691
- # it can be worked around by disabling strict aliasing
692
- toolchain = env ['toolchain' ];
693
- if toolchain == 'gcc' :
694
- env = Environment (tools = ['gcc' ])
695
- version = subprocess .Popen ([env ['CC' ], '-dumpversion' ],
696
- stdout = subprocess .PIPE ).communicate ()[0 ]
697
- if version .find ('4.5.' ) == 0 :
698
- return 'off'
699
- return 'default'
674
+ OS_GUESS = utils .GuessOS ()
675
+ TOOLCHAIN_GUESS = GuessToolchain (OS_GUESS )
676
+ ARCH_GUESS = utils .GuessArchitecture ()
677
+ VISIBILITY_GUESS = GuessVisibility (OS_GUESS , TOOLCHAIN_GUESS )
700
678
701
679
702
680
SIMPLE_OPTIONS = {
703
681
'toolchain' : {
704
682
'values' : ['gcc' , 'msvc' ],
705
- 'guess ' : GuessToolchain ,
706
- 'help' : 'the toolchain to use'
683
+ 'default ' : TOOLCHAIN_GUESS ,
684
+ 'help' : 'the toolchain to use (%s)' % TOOLCHAIN_GUESS
707
685
},
708
686
'os' : {
709
687
'values' : ['freebsd' , 'linux' , 'macos' , 'win32' , 'android' , 'openbsd' , 'solaris' , 'cygwin' ],
710
- 'guess ' : GuessOS ,
711
- 'help' : 'the os to build for'
688
+ 'default ' : OS_GUESS ,
689
+ 'help' : 'the os to build for (%s)' % OS_GUESS
712
690
},
713
691
'arch' : {
714
692
'values' :['arm' , 'ia32' , 'x64' , 'mips' ],
715
- 'guess ' : GuessArch ,
716
- 'help' : 'the architecture to build for'
693
+ 'default ' : ARCH_GUESS ,
694
+ 'help' : 'the architecture to build for (%s)' % ARCH_GUESS
717
695
},
718
696
'regexp' : {
719
697
'values' : ['native' , 'interpreted' ],
@@ -822,15 +800,8 @@ SIMPLE_OPTIONS = {
822
800
},
823
801
'visibility' : {
824
802
'values' : ['default' , 'hidden' ],
825
- 'guess' : GuessVisibility ,
826
- 'depends' : ['os' , 'toolchain' ],
827
- 'help' : 'shared library symbol visibility'
828
- },
829
- 'strictaliasing' : {
830
- 'values' : ['default' , 'off' ],
831
- 'guess' : GuessStrictAliasing ,
832
- 'depends' : ['toolchain' ],
833
- 'help' : 'assume strict aliasing while optimizing'
803
+ 'default' : VISIBILITY_GUESS ,
804
+ 'help' : 'shared library symbol visibility (%s)' % VISIBILITY_GUESS
834
805
},
835
806
'pgo' : {
836
807
'values' : ['off' , 'instrument' , 'optimize' ],
@@ -840,55 +811,19 @@ SIMPLE_OPTIONS = {
840
811
}
841
812
842
813
843
- def AddOption (result , name , option ):
844
- if 'guess' in option :
845
- # Option has a guess function
846
- guess = option .get ('guess' )
847
- guess_env = Environment (options = result )
848
- # Check if all options that the guess function depends on are set
849
- if 'depends' in option :
850
- for dependency in option .get ('depends' ):
851
- if not dependency in guess_env :
852
- return False
853
- default = guess (guess_env )
854
- else :
855
- # Option has a fixed default
856
- default = option .get ('default' )
857
-
858
- help = '%s (%s)' % (option .get ('help' ), ", " .join (option ['values' ]))
859
- result .Add (name , help , default )
860
- return True
861
-
862
-
863
814
def GetOptions ():
864
815
result = Options ()
865
816
result .Add ('mode' , 'compilation mode (debug, release)' , 'release' )
866
817
result .Add ('sample' , 'build sample (shell, process, lineprocessor)' , '' )
867
818
result .Add ('cache' , 'directory to use for scons build cache' , '' )
868
819
result .Add ('env' , 'override environment settings (NAME0:value0,NAME1:value1,...)' , '' )
869
820
result .Add ('importenv' , 'import environment settings (NAME0,NAME1,...)' , '' )
870
- options = SIMPLE_OPTIONS
871
- while len (options ):
872
- postpone = {}
873
- for (name , option ) in options .iteritems ():
874
- if not AddOption (result , name , option ):
875
- postpone [name ] = option
876
- options = postpone
821
+ for (name , option ) in SIMPLE_OPTIONS .iteritems ():
822
+ help = '%s (%s)' % (name , ", " .join (option ['values' ]))
823
+ result .Add (name , help , option .get ('default' ))
877
824
return result
878
825
879
826
880
- def GetTools (opts ):
881
- env = Environment (options = opts )
882
- os = env ['os' ]
883
- toolchain = env ['toolchain' ]
884
- if os == 'win32' and toolchain == 'gcc' :
885
- return ['mingw' ]
886
- elif os == 'win32' and toolchain == 'msvc' :
887
- return ['msvc' , 'mslink' , 'mslib' , 'msvs' ]
888
- else :
889
- return ['default' ]
890
-
891
-
892
827
def GetVersionComponents ():
893
828
MAJOR_VERSION_PATTERN = re .compile (r"#define\s+MAJOR_VERSION\s+(.*)" )
894
829
MINOR_VERSION_PATTERN = re .compile (r"#define\s+MINOR_VERSION\s+(.*)" )
@@ -969,7 +904,7 @@ def VerifyOptions(env):
969
904
print env ['simulator' ]
970
905
Abort ("Option unalignedaccesses only supported for the ARM architecture." )
971
906
for (name , option ) in SIMPLE_OPTIONS .iteritems ():
972
- if (not name in env ):
907
+ if (not option . get ( 'default' )) and ( name not in ARGUMENTS ):
973
908
message = ("A value for option %s must be specified (%s)." %
974
909
(name , ", " .join (option ['values' ])))
975
910
Abort (message )
@@ -1097,7 +1032,7 @@ def ParseEnvOverrides(arg, imports):
1097
1032
return overrides
1098
1033
1099
1034
1100
- def BuildSpecific (env , mode , env_overrides , tools ):
1035
+ def BuildSpecific (env , mode , env_overrides ):
1101
1036
options = {'mode' : mode }
1102
1037
for option in SIMPLE_OPTIONS :
1103
1038
options [option ] = env [option ]
@@ -1150,7 +1085,7 @@ def BuildSpecific(env, mode, env_overrides, tools):
1150
1085
(object_files , shell_files , mksnapshot ) = env .SConscript (
1151
1086
join ('src' , 'SConscript' ),
1152
1087
build_dir = join ('obj' , target_id ),
1153
- exports = 'context tools ' ,
1088
+ exports = 'context' ,
1154
1089
duplicate = False
1155
1090
)
1156
1091
@@ -1170,21 +1105,21 @@ def BuildSpecific(env, mode, env_overrides, tools):
1170
1105
library = env .SharedLibrary (library_name , object_files , PDB = pdb_name )
1171
1106
context .library_targets .append (library )
1172
1107
1173
- d8_env = Environment (tools = tools )
1108
+ d8_env = Environment ()
1174
1109
d8_env .Replace (** context .flags ['d8' ])
1175
1110
context .ApplyEnvOverrides (d8_env )
1176
1111
shell = d8_env .Program ('d8' + suffix , object_files + shell_files )
1177
1112
context .d8_targets .append (shell )
1178
1113
1179
1114
for sample in context .samples :
1180
- sample_env = Environment (tools = tools )
1115
+ sample_env = Environment ()
1181
1116
sample_env .Replace (** context .flags ['sample' ])
1182
1117
sample_env .Prepend (LIBS = [library_name ])
1183
1118
context .ApplyEnvOverrides (sample_env )
1184
1119
sample_object = sample_env .SConscript (
1185
1120
join ('samples' , 'SConscript' ),
1186
1121
build_dir = join ('obj' , 'sample' , sample , target_id ),
1187
- exports = 'sample context tools ' ,
1122
+ exports = 'sample context' ,
1188
1123
duplicate = False
1189
1124
)
1190
1125
sample_name = sample + suffix
@@ -1197,7 +1132,7 @@ def BuildSpecific(env, mode, env_overrides, tools):
1197
1132
cctest_program = cctest_env .SConscript (
1198
1133
join ('test' , 'cctest' , 'SConscript' ),
1199
1134
build_dir = join ('obj' , 'test' , target_id ),
1200
- exports = 'context object_files tools ' ,
1135
+ exports = 'context object_files' ,
1201
1136
duplicate = False
1202
1137
)
1203
1138
context .cctest_targets .append (cctest_program )
@@ -1207,9 +1142,7 @@ def BuildSpecific(env, mode, env_overrides, tools):
1207
1142
1208
1143
def Build ():
1209
1144
opts = GetOptions ()
1210
- tools = GetTools (opts )
1211
- env = Environment (options = opts , tools = tools )
1212
-
1145
+ env = Environment (options = opts )
1213
1146
Help (opts .GenerateHelpText (env ))
1214
1147
VerifyOptions (env )
1215
1148
env_overrides = ParseEnvOverrides (env ['env' ], env ['importenv' ])
@@ -1223,7 +1156,7 @@ def Build():
1223
1156
d8s = []
1224
1157
modes = SplitList (env ['mode' ])
1225
1158
for mode in modes :
1226
- context = BuildSpecific (env .Copy (), mode , env_overrides , tools )
1159
+ context = BuildSpecific (env .Copy (), mode , env_overrides )
1227
1160
libraries += context .library_targets
1228
1161
mksnapshots += context .mksnapshot_targets
1229
1162
cctests += context .cctest_targets
0 commit comments