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

Unified Diff: src/trusted/validator_ragel/build.scons

Issue 9968039: Add ragel machine generators to SCONS (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « SConstruct ('k') | src/trusted/validator_ragel/unreviewed/decoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,118 @@
+# -*- 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.
+
+# TODO(khim): eliminate need for the following piece
+if env.Bit('windows'):
+ env.FilterOut(CCFLAGS=['/O1'])
+ env.Append(CCFLAGS=['/O0'])
+
+# 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 automata definition.
+
+env_gen_dfa = env.Clone()
+env_gen_dfa.Append(CCFLAGS=['-std=c++0x', '-DNACL_TRUSTED_BUT_NOT_TCB'])
+
+gen_dfa = env_gen_dfa.ComponentProgram(
+ 'gen-dfa',
+ ['unreviewed/gen-dfa.cc'])
+
+# Source generation step 2: Generate decoder tables.
+#
+# Now we are back to conditionally defining the large tables generated
+# by ncdecode_tablegen.
+
+# Generate 32 and 64 bit versions of decoders and validators.
+if generate:
+ for bits in ['32', '64']:
+ for automata in ['decoder', 'validator']:
+ rl_file = '%s/%s-x86_%s-instruction.rl' % (val_src_dir, automata, bits)
+ exe_path = '${STAGING_DIR}/${PROGPREFIX}gen-dfa${PROGSUFFIX}'
+ gen_env.Command(
pasko-google - do not use 2012/04/05 09:41:37 nit: see in src/trusted/validator_arm/build.scons:
khim 2012/04/05 13:39:33 Done.
+ 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]} '
+ '${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'}[automata+bits])]
+ )
+ tables.append(rl_file)
+ c_file = '%s/%s-x86_%s.c' % (val_src_dir, automata, bits)
+ gen_env.Command(
+ c_file,
+ ['unreviewed/%s-x86_%s.rl' % (automata, bits), rl_file],
pasko-google - do not use 2012/04/05 11:41:25 I think it can happen that after a change in a .de
khim 2012/04/05 13:39:33 If all .rl files are unchanged then -consts.c 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]))
+
+# Generate 32 and 64 bit versions of decoders and validators.
+for bits in ['32', '64']:
+ for automata in ['decoder', 'validator']:
+ env.ComponentLibrary('%s-x86_%s' % (automata, bits),
+ ['generated/%s-x86_%s.c' % (automata, bits)])
+
+env.ComponentProgram(
+ 'decoder-test',
+ ['unreviewed/decoder-test.c'],
+ EXTRA_LIBS=['decoder-x86_32', 'decoder-x86_64'])
+
+env.ComponentProgram(
+ 'validator-test',
+ ['unreviewed/validator-test.c'],
+ EXTRA_LIBS=['validator-x86_32', 'validator-x86_64'])
« no previous file with comments | « SConstruct ('k') | src/trusted/validator_ragel/unreviewed/decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698