Chromium Code Reviews| Index: src/trusted/validator_ragel/build.scons |
| =================================================================== |
| --- src/trusted/validator_ragel/build.scons (revision 0) |
| +++ src/trusted/validator_ragel/build.scons (revision 0) |
| @@ -0,0 +1,120 @@ |
| +# -*- python -*- |
| +# Copyright (c) 2011 The Native Client Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import os |
| +import sys |
| +Import('env') |
| + |
| +# |
| +# |
| +# Build on x86 only. |
| +# |
| +# |
| +if not env.Bit('target_x86'): Return() |
| + |
| +# ------------------------------------------------------ |
| +# General adjustments to the environment for builds. |
| + |
| +# Make a copy of debug CRT for now. |
| +# TODO(bradnelson): there should be a better way to generalize this requirement. |
| +# NOTE: debug builds on windows break without this |
| +crt = [] |
| +if env.AllBits('windows', 'debug'): |
| + for i in ['.', '$STAGING_DIR']: |
| + crt += env.Replicate(i, '$VC80_DIR/vc/redist/Debug_NonRedist/' |
| + 'x86/Microsoft.VC80.DebugCRT') |
| + crt += env.Replicate(i, '$VC80_DIR/vc/redist/x86/Microsoft.VC80.CRT') |
| + |
| +# TODO(bradchen): eliminate need for the following line |
| +env.FilterOut(CCFLAGS=['-Wextra', '-Wswitch-enum', '-Wsign-compare']) |
| + |
| +# Defines the source directory where validator generated files should be added. |
| +val_src_dir = '$MAIN_DIR/src/trusted/validator_ragel/generated' |
| +# ------------------------------------------------------ |
| +# Source generation: |
| +# |
| +# valgen : Regenerate any autogenerated source files. |
| + |
| +gen_env = env.Clone(); |
| +gen_env.Append(CCFLAGS=['-DNACL_TRUSTED_BUT_NOT_TCB']) |
| + |
| +generate = False |
| +if 'valgen' in COMMAND_LINE_TARGETS: generate = True |
| +if 'valclean' in COMMAND_LINE_TARGETS: generate = True |
| + |
| +# Set of generated (source) decoder tables. |
| +tables = [] |
| + |
| +# ------------------------------------------------------ |
| +# Ragel generator: |
| +# |
| +# We have generator which reads .def files and produced machine definition. |
| + |
| +env_gen_decoder = env.Clone() |
| +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
|
| +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.
|
| + '-Wno-sign-compare', |
| + '-DNACL_TRUSTED_BUT_NOT_TCB']) |
| + |
| +gen_decoder = env_gen_decoder.ComponentProgram( |
| + 'gen-decoder', |
| + ['unreviewed/gen-decoder.cc']) |
| + |
| +env.Requires(gen_decoder, crt) |
| + |
| +# ------------------------------------------------------ |
| +# Source generation step 2: Generate decoder tables. |
| +# |
| +# Now we are back to conditionally defining the large tables generated |
| +# by ncdecode_tablegen. |
| +# |
| + |
| +if generate: |
| + # |
| + # Generate 32 and 64 bit versions of decoders and validators. |
| + # |
| + for bits in ['32', '64']: |
| + for machine in ['decoder', 'validator']: |
| + rl_file = '%s/%s-x86_%s-instruction.rl' % (val_src_dir, machine, bits) |
| + exe_path = '${STAGING_DIR}/${PROGPREFIX}gen-decoder${PROGSUFFIX}' |
| + gen_env.Command( |
| + rl_file, |
| + [exe_path, |
| + 'unreviewed/general-purpose-instructions.def', |
| + 'unreviewed/system-instructions.def', |
| + 'unreviewed/x87-instructions.def', |
| + 'unreviewed/mmx-instructions.def', |
| + 'unreviewed/xmm-instructions.def', |
| + 'unreviewed/nops.def'], |
| + [('${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
|
| + '${SOURCES[2]} ${SOURCES[3]} ${SOURCES[4]} ${SOURCES[5]} ' |
| + '${SOURCES[6]}') % ( |
| + {'32': 'ia32', '64': 'amd64'}[bits], |
| + {'decoder32': |
| + 'check_access,opcode,parse_operands_states,mark_data_fields', |
| + 'decoder64': |
| + 'check_access,opcode,parse_operands_states,mark_data_fields', |
| + 'validator32': |
| + ('check_access,opcode,parse_operands,parse_operands_states,' |
| + 'instruction_name,mark_data_fields,nacl-forbidden,' |
| + 'imm_operand_action,rel_operand_action'), |
| + 'validator64': |
| + 'opcode,instruction_name,mark_data_fields,rel_operand_action,' + |
| + 'nacl-forbidden'}[machine+bits])] |
| + ) |
| + tables.append(rl_file) |
| + c_file = '%s/%s-x86_%s.c' % (val_src_dir, machine, bits) |
| + gen_env.Command( |
| + c_file, |
| + ['unreviewed/%s-x86_%s.rl' % (machine, bits), rl_file], |
| + ['ragel -G2 -I%s ${SOURCES[0]} -o ${TARGET}' % (val_src_dir)] |
| + ) |
| + tables.append(c_file) |
| + |
| + # Generate 32 and 64 bit versions of decoders and validators |
| + gen_env.AlwaysBuild( |
| + gen_env.Alias('valgen', tables)) |
| + gen_env.AlwaysBuild( |
| + gen_env.Alias('valclean', action=[Delete(x) for x in tables])) |