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() | |
|
Mark Seaborn
2012/04/03 17:13:37
Our Python style is to use multiple lines:
if X:
khim
2012/04/03 17:48:04
Hmm... All validator files use this style, but Ok.
| |
| 16 | |
| 17 # ------------------------------------------------------ | |
|
Mark Seaborn
2012/04/03 17:13:37
Please don't put spacers like this in comments.
khim
2012/04/03 17:48:04
Again: our validator's build.scons files use them.
| |
| 18 # General adjustments to the environment for builds. | |
| 19 | |
| 20 # Make a copy of debug CRT for now. | |
|
Mark Seaborn
2012/04/03 17:13:37
This appears to be cargo-culted. Please remove th
khim
2012/04/03 17:48:04
I'm not sure if we need it or not, but it's includ
| |
| 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 | |
|
Mark Seaborn
2012/04/03 17:13:37
TODOs are supposed to contain the name of the pers
| |
| 31 env.FilterOut(CCFLAGS=['-Wextra', '-Wswitch-enum', '-Wsign-compare']) | |
|
Mark Seaborn
2012/04/03 17:13:37
Do you really need this? Can you fix your code to
khim
2012/04/03 17:48:04
I'll check: I think only generator needs these and
| |
| 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 automata definition. | |
| 54 | |
| 55 env_gen_dfa = env.Clone() | |
| 56 env_gen_dfa.FilterOut(CCFLAGS=['-pedantic', '-Wsign-compare']) | |
| 57 env_gen_dfa.Append(CCFLAGS=['-std=c++0x', '-Wno-sign-compare', | |
|
Mark Seaborn
2012/04/03 17:13:37
I thought you guys were going to eliminate the use
khim
2012/04/03 17:48:04
No. We've removed C++11 features not implemented i
| |
| 58 '-DNACL_TRUSTED_BUT_NOT_TCB']) | |
|
Mark Seaborn
2012/04/03 17:13:37
Fix indentation to line up with '['
khim
2012/04/03 17:48:04
Done.
| |
| 59 | |
| 60 gen_dfa = env_gen_dfa.ComponentProgram( | |
| 61 'gen-dfa', | |
| 62 ['unreviewed/gen-dfa.cc']) | |
| 63 | |
| 64 env.Requires(gen_dfa, crt) | |
| 65 | |
| 66 # ------------------------------------------------------ | |
| 67 # Source generation step 2: Generate decoder tables. | |
| 68 # | |
| 69 # Now we are back to conditionally defining the large tables generated | |
| 70 # by ncdecode_tablegen. | |
| 71 # | |
| 72 | |
| 73 if generate: | |
| 74 # | |
| 75 # Generate 32 and 64 bit versions of decoders and validators. | |
| 76 # | |
| 77 for bits in ['32', '64']: | |
| 78 for automata in ['decoder', 'validator']: | |
| 79 rl_file = '%s/%s-x86_%s-instruction.rl' % (val_src_dir, automata, bits) | |
| 80 exe_path = '${STAGING_DIR}/${PROGPREFIX}gen-dfa${PROGSUFFIX}' | |
| 81 gen_env.Command( | |
| 82 rl_file, | |
| 83 [exe_path, | |
| 84 'unreviewed/general-purpose-instructions.def', | |
| 85 'unreviewed/system-instructions.def', | |
| 86 'unreviewed/x87-instructions.def', | |
| 87 'unreviewed/mmx-instructions.def', | |
| 88 'unreviewed/xmm-instructions.def', | |
| 89 'unreviewed/nops.def'], | |
| 90 [('${SOURCES[0]} -o ${TARGET} -m %s -d %s ${SOURCES[1]} ' | |
| 91 '${SOURCES[2]} ${SOURCES[3]} ${SOURCES[4]} ${SOURCES[5]} ' | |
| 92 '${SOURCES[6]}') % ( | |
| 93 {'32': 'ia32', '64': 'amd64'}[bits], | |
| 94 {'decoder32': | |
| 95 'check_access,opcode,parse_operands_states,mark_data_fields', | |
| 96 'decoder64': | |
| 97 'check_access,opcode,parse_operands_states,mark_data_fields', | |
| 98 'validator32': | |
| 99 ('check_access,opcode,parse_operands,parse_operands_states,' | |
| 100 'instruction_name,mark_data_fields,nacl-forbidden,' | |
| 101 'imm_operand_action,rel_operand_action'), | |
| 102 'validator64': | |
| 103 'opcode,instruction_name,mark_data_fields,rel_operand_action,' + | |
| 104 'nacl-forbidden'}[automata+bits])] | |
| 105 ) | |
| 106 tables.append(rl_file) | |
| 107 c_file = '%s/%s-x86_%s.c' % (val_src_dir, automata, bits) | |
| 108 gen_env.Command( | |
| 109 c_file, | |
| 110 ['unreviewed/%s-x86_%s.rl' % (automata, bits), rl_file], | |
| 111 ['ragel -G2 -I%s ${SOURCES[0]} -o ${TARGET}' % (val_src_dir)] | |
| 112 ) | |
| 113 tables.append(c_file) | |
| 114 | |
| 115 # Generate 32 and 64 bit versions of decoders and validators | |
| 116 gen_env.AlwaysBuild( | |
| 117 gen_env.Alias('valgen', tables)) | |
| 118 gen_env.AlwaysBuild( | |
| 119 gen_env.Alias('valclean', action=[Delete(x) for x in tables])) | |
| OLD | NEW |