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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « SConstruct ('k') | src/trusted/validator_ragel/unreviewed/gen-dfa.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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'):
16 Return()
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(khim): 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 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',
58 '-DNACL_TRUSTED_BUT_NOT_TCB'])
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',
Nick Bray 2012/04/07 00:17:46 4x spaces.
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':
Nick Bray 2012/04/07 00:17:46 Horizontal alignment.
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]))
OLDNEW
« no previous file with comments | « SConstruct ('k') | src/trusted/validator_ragel/unreviewed/gen-dfa.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698