Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # -*- python -*- | |
| 2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import os | |
| 7 import sys | |
| 8 Import('env') | |
| 9 | |
| 10 # | |
| 11 # | |
| 12 # Build on x86 only. | |
| 13 # | |
| 14 # | |
| 15 if not env.Bit('target_x86'): Return() | |
| 16 | |
| 17 # ------------------------------------------------------ | |
| 18 # General adjustments to the environment for builds. | |
| 19 | |
| 20 # Make a copy of debug CRT for now. | |
| 21 # TODO(bradnelson): there should be a better way to generalize this requirement. | |
| 22 # NOTE: debug builds on windows break without this | |
| 23 crt = [] | |
| 24 if env.AllBits('windows', 'debug'): | |
| 25 for i in ['.', '$STAGING_DIR']: | |
| 26 crt += env.Replicate(i, '$VC80_DIR/vc/redist/Debug_NonRedist/' | |
| 27 'x86/Microsoft.VC80.DebugCRT') | |
| 28 crt += env.Replicate(i, '$VC80_DIR/vc/redist/x86/Microsoft.VC80.CRT') | |
| 29 | |
| 30 # TODO(bradchen): eliminate need for the following line | |
| 31 env.FilterOut(CCFLAGS=['-Wextra', '-Wswitch-enum', '-Wsign-compare']) | |
| 32 | |
| 33 # Defines the source directory where validator generated files should be added. | |
| 34 val_src_dir = '$MAIN_DIR/src/trusted/validator_ragel/generated' | |
| 35 # ------------------------------------------------------ | |
| 36 # Source generation: | |
| 37 # | |
| 38 # valgen : Regenerate any autogenerated source files. | |
| 39 | |
| 40 gen_env = env.Clone(); | |
| 41 gen_env.Append(CCFLAGS=['-DNACL_TRUSTED_BUT_NOT_TCB']) | |
| 42 | |
| 43 generate = False | |
| 44 if 'valgen' in COMMAND_LINE_TARGETS: generate = True | |
| 45 if 'valclean' in COMMAND_LINE_TARGETS: generate = True | |
| 46 | |
| 47 # Set of generated (source) decoder tables. | |
| 48 tables = [] | |
| 49 | |
| 50 # ------------------------------------------------------ | |
| 51 # Ragel generator: | |
| 52 # | |
| 53 # We have generator which reads .def files and produced machine definition. | |
| 54 | |
| 55 env_gen_decoder = env.Clone() | |
| 56 env_gen_decoder.FilterOut(CCFLAGS=['-pedantic', '-Wsign-compare']) | |
|
pasko-google - do not use
2012/04/03 15:09:40
filtering out these options smells wrong
| |
| 57 env_gen_decoder.Append(CCFLAGS=['-std=c++0x', '-O3', '-finline-limit=10000', | |
|
pasko-google - do not use
2012/04/03 15:09:40
no reason for doing -O3, only reduces overall time
khim
2012/04/03 16:45:53
Done.
| |
| 58 '-Wno-sign-compare', | |
| 59 '-DNACL_TRUSTED_BUT_NOT_TCB']) | |
| 60 | |
| 61 gen_decoder = env_gen_decoder.ComponentProgram( | |
| 62 'gen-decoder', | |
| 63 ['unreviewed/gen-decoder.cc']) | |
| 64 | |
| 65 env.Requires(gen_decoder, crt) | |
| 66 | |
| 67 # ------------------------------------------------------ | |
| 68 # Source generation step 2: Generate decoder tables. | |
| 69 # | |
| 70 # Now we are back to conditionally defining the large tables generated | |
| 71 # by ncdecode_tablegen. | |
| 72 # | |
| 73 | |
| 74 if generate: | |
| 75 # | |
| 76 # Generate 32 and 64 bit versions of decoders and validators. | |
| 77 # | |
| 78 for bits in ['32', '64']: | |
| 79 for machine in ['decoder', 'validator']: | |
| 80 rl_file = '%s/%s-x86_%s-instruction.rl' % (val_src_dir, machine, bits) | |
| 81 exe_path = '${STAGING_DIR}/${PROGPREFIX}gen-decoder${PROGSUFFIX}' | |
| 82 gen_env.Command( | |
| 83 rl_file, | |
| 84 [exe_path, | |
| 85 'unreviewed/general-purpose-instructions.def', | |
| 86 'unreviewed/system-instructions.def', | |
| 87 'unreviewed/x87-instructions.def', | |
| 88 'unreviewed/mmx-instructions.def', | |
| 89 'unreviewed/xmm-instructions.def', | |
| 90 'unreviewed/nops.def'], | |
| 91 [('${SOURCES[0]} -o ${TARGET} -m %s -d %s ${SOURCES[1]} ' | |
|
pasko-google - do not use
2012/04/03 15:09:40
this manipulation with SOURCES scares me away sinc
halyavin
2012/04/03 15:15:12
These are Command parameters (second argument of e
khim
2012/04/03 16:45:53
Well, yeah: these are files listed immediately bef
| |
| 92 '${SOURCES[2]} ${SOURCES[3]} ${SOURCES[4]} ${SOURCES[5]} ' | |
| 93 '${SOURCES[6]}') % ( | |
| 94 {'32': 'ia32', '64': 'amd64'}[bits], | |
| 95 {'decoder32': | |
| 96 'check_access,opcode,parse_operands_states,mark_data_fields', | |
| 97 'decoder64': | |
| 98 'check_access,opcode,parse_operands_states,mark_data_fields', | |
| 99 'validator32': | |
| 100 ('check_access,opcode,parse_operands,parse_operands_states,' | |
| 101 'instruction_name,mark_data_fields,nacl-forbidden,' | |
| 102 'imm_operand_action,rel_operand_action'), | |
| 103 'validator64': | |
| 104 'opcode,instruction_name,mark_data_fields,rel_operand_action,' + | |
| 105 'nacl-forbidden'}[machine+bits])] | |
| 106 ) | |
| 107 tables.append(rl_file) | |
| 108 c_file = '%s/%s-x86_%s.c' % (val_src_dir, machine, bits) | |
| 109 gen_env.Command( | |
| 110 c_file, | |
| 111 ['unreviewed/%s-x86_%s.rl' % (machine, bits), rl_file], | |
| 112 ['ragel -G2 -I%s ${SOURCES[0]} -o ${TARGET}' % (val_src_dir)] | |
| 113 ) | |
| 114 tables.append(c_file) | |
| 115 | |
| 116 # Generate 32 and 64 bit versions of decoders and validators | |
| 117 gen_env.AlwaysBuild( | |
| 118 gen_env.Alias('valgen', tables)) | |
| 119 gen_env.AlwaysBuild( | |
| 120 gen_env.Alias('valclean', action=[Delete(x) for x in tables])) | |
| OLD | NEW |