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

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

Issue 10031039: Add ragel validator to SCONS (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 8 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/Makefile » ('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,132 @@
+# -*- python -*-
+# Copyright (c) 2012 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('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
+# See http://code.google.com/p/nativeclient/issues/detail?id=2718 for details.
+if env.Bit('windows'):
+ env.FilterOut(CCFLAGS=['/O1'])
+# XCode 4.2 takes too long to compile with -Os, LLVM for MacOS times out.
+if env.Bit('mac') or env.Bit('asan'):
+ env.FilterOut(CCFLAGS=['-Os'])
+
+# Defines the source directory where validator generated files should be added.
+rl_src_dir = '$OBJ_ROOT/src/trusted/validator_ragel'
+val_src_dir = '$MAIN_DIR/src/trusted/validator_ragel/gen'
+
+# Source generation:
+#
+# valgen : Regenerate any autogenerated source files.
+
+generate = False
+if ('valgen' in COMMAND_LINE_TARGETS) or ('valclean' in COMMAND_LINE_TARGETS):
+ generate = True
+
+if generate:
+ # Set of generated (source) decoder automatas.
+ automatas = []
+
+ # Source generation step 1: Build generator of ragel files.
+ #
+ # We have generator which reads .def files and produced automata definition.
+ #
+ # Ragel is included in most Linux distributions, but it's not standard tool
+ # on MacOS/Windows thus we only support gneration of automata under Linux.
+ # This also means that we don't need to make sure gen-dfa.cc is portable to
+ # non-POSIX platforms (in particular it's not Windows compatible).
+
+ 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 automatas.
+ #
+ # Now we are back to conditionally defining the large automatas generated
+ # by gen-dfa.
+
+ # Generate 32 and 64 bit versions of decoders and validators.
+ for bits in ['32', '64']:
+ for automata in ['decoder', 'validator']:
+ # We are cheating here: there are two autogenerated files:
+ # .rl and -consts.c, but we only track .rl one. This is safe because
+ # -consts.c file includes constants referenced by .rl file and if .rl
+ # file is not changed -consts.c is guaranteed to be the same (reverse
+ # is not true).
+ rl_file = '%s-x86_%s-instruction.rl' % (automata, bits)
+ const_file = '%s/%s-x86_%s-instruction-consts.c' % (
+ val_src_dir, automata, bits)
+ exe_path = '${STAGING_DIR}/${PROGPREFIX}gen-dfa${PROGSUFFIX}'
+ env.Command(
+ target=rl_file,
+ source=[
+ 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'],
+ action=[('${SOURCES[0]} -o ${TARGET} -c %s -m %s -d %s ${SOURCES[1]} '
+ '${SOURCES[2]} ${SOURCES[3]} ${SOURCES[4]} ${SOURCES[5]} '
+ '${SOURCES[6]}') % (
+ # Const file (-c): not tracked by SCONS (see above)
+ const_file,
+ # Argument for CPU type (-m): either "ia32" or "amd64".
+ {'32': 'ia32', '64': 'amd64'}[bits],
+ # Argument for actions selection (-d): selects only actions we need.
+ {'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])]
+ )
+ automatas.append(rl_file)
+ c_file = '%s/%s-x86_%s.c' % (val_src_dir, automata, bits)
+ env.Command(
+ target=c_file,
+ source=['unreviewed/%s-x86_%s.rl' % (automata, bits), rl_file],
+ action=['ragel -G2 -I%s ${SOURCES[0]} -o ${TARGET}' % (rl_src_dir)]
+ )
+ automatas.append(c_file)
+
+ # Generate 32 and 64 bit versions of decoders and validators
+ env.AlwaysBuild(env.Alias('valgen', automatas))
+ env.AlwaysBuild(env.Alias('valclean', action=[Delete(x) for x in automatas]))
+
+# 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),
+ ['gen/%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/Makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698