Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: SConstruct

Issue 6772002: Introduce scons target to build preparser libraray and proof-of-concept command line process. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | preparser/SConscript » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2010 the V8 project authors. All rights reserved. 1 # Copyright 2010 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without 2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are 3 # modification, are permitted provided that the following conditions are
4 # met: 4 # met:
5 # 5 #
6 # * Redistributions of source code must retain the above copyright 6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above 8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following 9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided 10 # disclaimer in the documentation and/or other materials provided
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 'LIBPATH': ['.'], 497 'LIBPATH': ['.'],
498 'CCFLAGS': ['-fno-rtti', '-fno-exceptions'] 498 'CCFLAGS': ['-fno-rtti', '-fno-exceptions']
499 }, 499 },
500 'os:linux': { 500 'os:linux': {
501 'LIBS': ['pthread'], 501 'LIBS': ['pthread'],
502 }, 502 },
503 'os:macos': { 503 'os:macos': {
504 'LIBS': ['pthread'], 504 'LIBS': ['pthread'],
505 }, 505 },
506 'os:freebsd': { 506 'os:freebsd': {
507 'LIBPATH' : ['/usr/local/lib'], 507 'LIBPATH' : ['/usr/local/lib'],
508 'LIBS': ['execinfo', 'pthread'] 508 'LIBS': ['execinfo', 'pthread']
509 }, 509 },
510 'os:solaris': { 510 'os:solaris': {
511 'LIBPATH' : ['/usr/local/lib'], 511 'LIBPATH' : ['/usr/local/lib'],
512 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'], 512 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
513 'LINKFLAGS': ['-mt'] 513 'LINKFLAGS': ['-mt']
514 }, 514 },
515 'os:openbsd': { 515 'os:openbsd': {
516 'LIBPATH' : ['/usr/local/lib'], 516 'LIBPATH' : ['/usr/local/lib'],
517 'LIBS': ['execinfo', 'pthread'] 517 'LIBS': ['execinfo', 'pthread']
518 }, 518 },
519 'os:win32': { 519 'os:win32': {
520 'LIBS': ['winmm', 'ws2_32'] 520 'LIBS': ['winmm', 'ws2_32']
521 },
522 'os:android': {
523 'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__',
524 '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'],
525 'CCFLAGS': ANDROID_FLAGS,
526 'CPPPATH': ANDROID_INCLUDES,
527 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib',
528 ANDROID_TOP + '/prebuilt/linux-x86/toolchain/arm-eabi-4.4. 0/lib/gcc/arm-eabi/4.4.0/interwork'],
529 'LINKFLAGS': ANDROID_LINKFLAGS,
530 'LIBS': ['log', 'c', 'stdc++', 'm', 'gcc'],
531 'mode:release': {
532 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG']
533 }
534 },
535 'arch:arm': {
536 'LINKFLAGS': ARM_LINK_FLAGS
537 },
538 'arch:ia32': {
539 'CCFLAGS': ['-m32'],
540 'LINKFLAGS': ['-m32']
541 },
542 'arch:x64': {
543 'CCFLAGS': ['-m64'],
544 'LINKFLAGS': ['-m64']
545 },
546 'arch:mips': {
547 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
548 'simulator:none': {
549 'CCFLAGS': ['-EL', '-mips32r2', '-Wa,-mips32r2', '-fno-inline'],
550 'LINKFLAGS': ['-EL'],
551 'LDFLAGS': ['-EL']
552 }
553 },
554 'simulator:arm': {
555 'CCFLAGS': ['-m32'],
556 'LINKFLAGS': ['-m32']
557 },
558 'simulator:mips': {
559 'CCFLAGS': ['-m32'],
560 'LINKFLAGS': ['-m32']
561 },
562 'mode:release': {
563 'CCFLAGS': ['-O2']
564 },
565 'mode:debug': {
566 'CCFLAGS': ['-g', '-O0'],
567 'CPPDEFINES': ['DEBUG']
568 },
569 },
570 'msvc': {
571 'all': {
572 'LIBS': ['winmm', 'ws2_32']
573 },
574 'verbose:off': {
575 'CCFLAGS': ['/nologo'],
576 'LINKFLAGS': ['/NOLOGO']
577 },
578 'verbose:on': {
579 'LINKFLAGS': ['/VERBOSE']
580 },
581 'library:shared': {
582 'CPPDEFINES': ['USING_V8_SHARED']
583 },
584 'prof:on': {
585 'LINKFLAGS': ['/MAP']
586 },
587 'mode:release': {
588 'CCFLAGS': ['/O2'],
589 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'],
590 'msvcrt:static': {
591 'CCFLAGS': ['/MT']
592 },
593 'msvcrt:shared': {
594 'CCFLAGS': ['/MD']
595 },
596 'msvcltcg:on': {
597 'CCFLAGS': ['/GL'],
598 'pgo:off': {
599 'LINKFLAGS': ['/LTCG'],
600 },
601 },
602 'pgo:instrument': {
603 'LINKFLAGS': ['/LTCG:PGI']
604 },
605 'pgo:optimize': {
606 'LINKFLAGS': ['/LTCG:PGO']
607 }
608 },
609 'arch:ia32': {
610 'CPPDEFINES': ['V8_TARGET_ARCH_IA32', 'WIN32'],
611 'LINKFLAGS': ['/MACHINE:X86']
612 },
613 'arch:x64': {
614 'CPPDEFINES': ['V8_TARGET_ARCH_X64', 'WIN32'],
615 'LINKFLAGS': ['/MACHINE:X64', '/STACK:2091752']
616 },
617 'mode:debug': {
618 'CCFLAGS': ['/Od'],
619 'LINKFLAGS': ['/DEBUG'],
620 'CPPDEFINES': ['DEBUG'],
621 'msvcrt:static': {
622 'CCFLAGS': ['/MTd']
623 },
624 'msvcrt:shared': {
625 'CCFLAGS': ['/MDd']
626 }
627 }
628 }
629 }
630
631
632 PREPARSER_FLAGS = {
633 'all': {
634 'CPPPATH': [join(abspath('.'), 'include'), join(abspath('.'), 'src')]
635 },
636 'gcc': {
637 'all': {
638 'LIBPATH': ['.'],
639 'CCFLAGS': ['-fno-rtti', '-fno-exceptions']
640 },
641 'os:win32': {
642 'LIBS': ['winmm', 'ws2_32']
521 }, 643 },
522 'os:android': { 644 'os:android': {
523 'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__', 645 'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__',
524 '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'], 646 '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'],
525 'CCFLAGS': ANDROID_FLAGS, 647 'CCFLAGS': ANDROID_FLAGS,
526 'CPPPATH': ANDROID_INCLUDES, 648 'CPPPATH': ANDROID_INCLUDES,
527 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib', 649 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib',
528 ANDROID_TOP + '/prebuilt/linux-x86/toolchain/arm-eabi-4.4. 0/lib/gcc/arm-eabi/4.4.0/interwork'], 650 ANDROID_TOP + '/prebuilt/linux-x86/toolchain/arm-eabi-4.4. 0/lib/gcc/arm-eabi/4.4.0/interwork'],
529 'LINKFLAGS': ANDROID_LINKFLAGS, 651 'LINKFLAGS': ANDROID_LINKFLAGS,
530 'LIBS': ['log', 'c', 'stdc++', 'm', 'gcc'], 652 'LIBS': ['log', 'c', 'stdc++', 'm', 'gcc'],
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 1109
988 def __init__(self, options, env_overrides, samples): 1110 def __init__(self, options, env_overrides, samples):
989 self.library_targets = [] 1111 self.library_targets = []
990 self.mksnapshot_targets = [] 1112 self.mksnapshot_targets = []
991 self.cctest_targets = [] 1113 self.cctest_targets = []
992 self.sample_targets = [] 1114 self.sample_targets = []
993 self.d8_targets = [] 1115 self.d8_targets = []
994 self.options = options 1116 self.options = options
995 self.env_overrides = env_overrides 1117 self.env_overrides = env_overrides
996 self.samples = samples 1118 self.samples = samples
1119 self.preparser_targets = []
997 self.use_snapshot = (options['snapshot'] != 'off') 1120 self.use_snapshot = (options['snapshot'] != 'off')
998 self.build_snapshot = (options['snapshot'] == 'on') 1121 self.build_snapshot = (options['snapshot'] == 'on')
999 self.flags = None 1122 self.flags = None
1000 1123
1001 def AddRelevantFlags(self, initial, flags): 1124 def AddRelevantFlags(self, initial, flags):
1002 result = initial.copy() 1125 result = initial.copy()
1003 toolchain = self.options['toolchain'] 1126 toolchain = self.options['toolchain']
1004 if toolchain in flags: 1127 if toolchain in flags:
1005 self.AppendFlags(result, flags[toolchain].get('all')) 1128 self.AppendFlags(result, flags[toolchain].get('all'))
1006 for option in sorted(self.options.keys()): 1129 for option in sorted(self.options.keys()):
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 del user_environ['ENV'] 1240 del user_environ['ENV']
1118 except KeyError: 1241 except KeyError:
1119 pass 1242 pass
1120 1243
1121 library_flags = context.AddRelevantFlags(user_environ, LIBRARY_FLAGS) 1244 library_flags = context.AddRelevantFlags(user_environ, LIBRARY_FLAGS)
1122 v8_flags = context.AddRelevantFlags(library_flags, V8_EXTRA_FLAGS) 1245 v8_flags = context.AddRelevantFlags(library_flags, V8_EXTRA_FLAGS)
1123 mksnapshot_flags = context.AddRelevantFlags(library_flags, MKSNAPSHOT_EXTRA_FL AGS) 1246 mksnapshot_flags = context.AddRelevantFlags(library_flags, MKSNAPSHOT_EXTRA_FL AGS)
1124 dtoa_flags = context.AddRelevantFlags(library_flags, DTOA_EXTRA_FLAGS) 1247 dtoa_flags = context.AddRelevantFlags(library_flags, DTOA_EXTRA_FLAGS)
1125 cctest_flags = context.AddRelevantFlags(v8_flags, CCTEST_EXTRA_FLAGS) 1248 cctest_flags = context.AddRelevantFlags(v8_flags, CCTEST_EXTRA_FLAGS)
1126 sample_flags = context.AddRelevantFlags(user_environ, SAMPLE_FLAGS) 1249 sample_flags = context.AddRelevantFlags(user_environ, SAMPLE_FLAGS)
1250 preparser_flags = context.AddRelevantFlags(user_environ, PREPARSER_FLAGS)
1127 d8_flags = context.AddRelevantFlags(library_flags, D8_FLAGS) 1251 d8_flags = context.AddRelevantFlags(library_flags, D8_FLAGS)
1128 1252
1129 context.flags = { 1253 context.flags = {
1130 'v8': v8_flags, 1254 'v8': v8_flags,
1131 'mksnapshot': mksnapshot_flags, 1255 'mksnapshot': mksnapshot_flags,
1132 'dtoa': dtoa_flags, 1256 'dtoa': dtoa_flags,
1133 'cctest': cctest_flags, 1257 'cctest': cctest_flags,
1134 'sample': sample_flags, 1258 'sample': sample_flags,
1135 'd8': d8_flags 1259 'd8': d8_flags,
1260 'preparser': preparser_flags
1136 } 1261 }
1137 1262
1138 # Generate library base name. 1263 # Generate library base name.
1139 target_id = mode 1264 target_id = mode
1140 suffix = SUFFIXES[target_id] 1265 suffix = SUFFIXES[target_id]
1141 library_name = 'v8' + suffix 1266 library_name = 'v8' + suffix
1267 preparser_library_name = 'v8preparser' + suffix
1142 version = GetVersion() 1268 version = GetVersion()
1143 if context.options['soname'] == 'on': 1269 if context.options['soname'] == 'on':
1144 # When building shared object with SONAME version the library name. 1270 # When building shared object with SONAME version the library name.
1145 library_name += '-' + version 1271 library_name += '-' + version
1146 1272
1147 # Generate library SONAME if required by the build. 1273 # Generate library SONAME if required by the build.
1148 if context.options['soname'] == 'on': 1274 if context.options['soname'] == 'on':
1149 soname = GetSpecificSONAME() 1275 soname = GetSpecificSONAME()
1150 if soname == '': 1276 if soname == '':
1151 soname = 'lib' + library_name + '.so' 1277 soname = 'lib' + library_name + '.so'
1152 env['SONAME'] = soname 1278 env['SONAME'] = soname
1153 1279
1154 # Build the object files by invoking SCons recursively. 1280 # Build the object files by invoking SCons recursively.
1155 (object_files, shell_files, mksnapshot) = env.SConscript( 1281 (object_files, shell_files, mksnapshot, preparser_files) = env.SConscript(
1156 join('src', 'SConscript'), 1282 join('src', 'SConscript'),
1157 build_dir=join('obj', target_id), 1283 build_dir=join('obj', target_id),
1158 exports='context', 1284 exports='context',
1159 duplicate=False 1285 duplicate=False
1160 ) 1286 )
1161 1287
1162 context.mksnapshot_targets.append(mksnapshot) 1288 context.mksnapshot_targets.append(mksnapshot)
1163 1289
1164 # Link the object files into a library. 1290 # Link the object files into a library.
1165 env.Replace(**context.flags['v8']) 1291 env.Replace(**context.flags['v8'])
1166 1292
1167 context.ApplyEnvOverrides(env) 1293 context.ApplyEnvOverrides(env)
1168 if context.options['library'] == 'static': 1294 if context.options['library'] == 'static':
1169 library = env.StaticLibrary(library_name, object_files) 1295 library = env.StaticLibrary(library_name, object_files)
1296 preparser_library = env.StaticLibrary(preparser_library_name,
1297 preparser_files)
1170 else: 1298 else:
1171 # There seems to be a glitch in the way scons decides where to put 1299 # There seems to be a glitch in the way scons decides where to put
1172 # PDB files when compiling using MSVC so we specify it manually. 1300 # PDB files when compiling using MSVC so we specify it manually.
1173 # This should not affect any other platforms. 1301 # This should not affect any other platforms.
1174 pdb_name = library_name + '.dll.pdb' 1302 pdb_name = library_name + '.dll.pdb'
1175 library = env.SharedLibrary(library_name, object_files, PDB=pdb_name) 1303 library = env.SharedLibrary(library_name, object_files, PDB=pdb_name)
1304 preparser_pdb_name = preparser_library_name + '.dll.pdb';
1305 preparser_library = env.SharedLibrary(preparser_library_name,
1306 preparser_files,
1307 PDB=preparser_pdb_name)
1176 context.library_targets.append(library) 1308 context.library_targets.append(library)
1309 context.library_targets.append(preparser_library)
1177 1310
1178 d8_env = Environment() 1311 d8_env = Environment()
1179 d8_env.Replace(**context.flags['d8']) 1312 d8_env.Replace(**context.flags['d8'])
1180 context.ApplyEnvOverrides(d8_env) 1313 context.ApplyEnvOverrides(d8_env)
1181 shell = d8_env.Program('d8' + suffix, object_files + shell_files) 1314 shell = d8_env.Program('d8' + suffix, object_files + shell_files)
1182 context.d8_targets.append(shell) 1315 context.d8_targets.append(shell)
1183 1316
1184 for sample in context.samples: 1317 for sample in context.samples:
1185 sample_env = Environment() 1318 sample_env = Environment()
1186 sample_env.Replace(**context.flags['sample']) 1319 sample_env.Replace(**context.flags['sample'])
(...skipping 13 matching lines...) Expand all
1200 cctest_env = env.Copy() 1333 cctest_env = env.Copy()
1201 cctest_env.Prepend(LIBS=[library_name]) 1334 cctest_env.Prepend(LIBS=[library_name])
1202 cctest_program = cctest_env.SConscript( 1335 cctest_program = cctest_env.SConscript(
1203 join('test', 'cctest', 'SConscript'), 1336 join('test', 'cctest', 'SConscript'),
1204 build_dir=join('obj', 'test', target_id), 1337 build_dir=join('obj', 'test', target_id),
1205 exports='context object_files', 1338 exports='context object_files',
1206 duplicate=False 1339 duplicate=False
1207 ) 1340 )
1208 context.cctest_targets.append(cctest_program) 1341 context.cctest_targets.append(cctest_program)
1209 1342
1343 preparser_env = env.Copy()
1344 preparser_env.Replace(**context.flags['preparser'])
1345 preparser_env.Prepend(LIBS=[preparser_library_name])
1346 context.ApplyEnvOverrides(preparser_env)
1347 preparser_object = preparser_env.SConscript(
1348 join('preparser', 'SConscript'),
1349 build_dir=join('obj', 'preparser', target_id),
1350 exports='context',
1351 duplicate=False
1352 )
1353 preparser_name = join('obj', 'preparser', target_id, 'preparser' + suffix)
1354 preparser_program = preparser_env.Program(preparser_name, preparser_object);
1355 preparser_env.Depends(preparser_program, preparser_library)
1356 context.preparser_targets.append(preparser_program)
1357
1210 return context 1358 return context
1211 1359
1212 1360
1213 def Build(): 1361 def Build():
1214 opts = GetOptions() 1362 opts = GetOptions()
1215 env = Environment(options=opts) 1363 env = Environment(options=opts)
1216 Help(opts.GenerateHelpText(env)) 1364 Help(opts.GenerateHelpText(env))
1217 VerifyOptions(env) 1365 VerifyOptions(env)
1218 env_overrides = ParseEnvOverrides(env['env'], env['importenv']) 1366 env_overrides = ParseEnvOverrides(env['env'], env['importenv'])
1219 1367
1220 SourceSignatures(env['sourcesignatures']) 1368 SourceSignatures(env['sourcesignatures'])
1221 1369
1222 libraries = [] 1370 libraries = []
1223 mksnapshots = [] 1371 mksnapshots = []
1224 cctests = [] 1372 cctests = []
1225 samples = [] 1373 samples = []
1374 preparsers = []
1226 d8s = [] 1375 d8s = []
1227 modes = SplitList(env['mode']) 1376 modes = SplitList(env['mode'])
1228 for mode in modes: 1377 for mode in modes:
1229 context = BuildSpecific(env.Copy(), mode, env_overrides) 1378 context = BuildSpecific(env.Copy(), mode, env_overrides)
1230 libraries += context.library_targets 1379 libraries += context.library_targets
1231 mksnapshots += context.mksnapshot_targets 1380 mksnapshots += context.mksnapshot_targets
1232 cctests += context.cctest_targets 1381 cctests += context.cctest_targets
1233 samples += context.sample_targets 1382 samples += context.sample_targets
1383 preparsers += context.preparser_targets
1234 d8s += context.d8_targets 1384 d8s += context.d8_targets
1235 1385
1236 env.Alias('library', libraries) 1386 env.Alias('library', libraries)
1237 env.Alias('mksnapshot', mksnapshots) 1387 env.Alias('mksnapshot', mksnapshots)
1238 env.Alias('cctests', cctests) 1388 env.Alias('cctests', cctests)
1239 env.Alias('sample', samples) 1389 env.Alias('sample', samples)
1240 env.Alias('d8', d8s) 1390 env.Alias('d8', d8s)
1391 env.Alias('preparser', preparsers)
1241 1392
1242 if env['sample']: 1393 if env['sample']:
1243 env.Default('sample') 1394 env.Default('sample')
1244 else: 1395 else:
1245 env.Default('library') 1396 env.Default('library')
1246 1397
1247 if env['cache']: 1398 if env['cache']:
1248 CacheDir(env['cache']) 1399 CacheDir(env['cache'])
1249 1400
1250 # We disable deprecation warnings because we need to be able to use 1401 # We disable deprecation warnings because we need to be able to use
1251 # env.Copy without getting warnings for compatibility with older 1402 # env.Copy without getting warnings for compatibility with older
1252 # version of scons. Also, there's a bug in some revisions that 1403 # version of scons. Also, there's a bug in some revisions that
1253 # doesn't allow this flag to be set, so we swallow any exceptions. 1404 # doesn't allow this flag to be set, so we swallow any exceptions.
1254 # Lovely. 1405 # Lovely.
1255 try: 1406 try:
1256 SetOption('warn', 'no-deprecated') 1407 SetOption('warn', 'no-deprecated')
1257 except: 1408 except:
1258 pass 1409 pass
1259 1410
1260 1411
1261 Build() 1412 Build()
OLDNEW
« no previous file with comments | « no previous file | preparser/SConscript » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698