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

Side by Side Diff: src/trusted/validator_ragel/build.scons

Issue 9967015: Revert 8203: Revert 8202 - Add ragel decoder/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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # -*- python -*-
2 # Copyright (c) 2012 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('env')
7
8 #
9 #
10 # Build on x86 only.
11 #
12 #
13 if not env.Bit('target_x86'):
14 Return()
15
16 # General adjustments to the environment for builds.
17
18 # TODO(khim): eliminate need for the following piece
19 # See http://code.google.com/p/nativeclient/issues/detail?id=2718 for details.
20 if env.Bit('windows'):
21 env.FilterOut(CCFLAGS=['/O1'])
22
23 # Defines the source directory where validator generated files should be added.
24 rl_src_dir = '$OBJ_ROOT/src/trusted/validator_ragel'
25 val_src_dir = '$MAIN_DIR/src/trusted/validator_ragel/gen'
26
27 # Source generation:
28 #
29 # valgen : Regenerate any autogenerated source files.
30
31 gen_env = env.Clone();
32 gen_env.Append(CCFLAGS=['-DNACL_TRUSTED_BUT_NOT_TCB'])
pasko-google - do not use 2012/04/10 09:32:41 gen_env only runs ragel and gen-dfa, there should
khim 2012/04/10 12:29:38 This exactly why we need to define NACL_TRUSTED_BU
33
34 generate = False
35 if ('valgen' in COMMAND_LINE_TARGETS) or ('valclean' in COMMAND_LINE_TARGETS):
36 generate = True
37
38 if generate:
39 # Set of generated (source) decoder tables.
40 tables = []
pasko-google - do not use 2012/04/10 09:32:41 just noticed: the naming is hm .. copypasted, we d
khim 2012/04/10 12:29:38 I've replaced tables with automatas...
41
42 # Ragel generator:
43 #
44 # We have generator which reads .def files and produced automata definition.
45 #
46 # Ragel is included in most Linux distributions, but it's not standard tool
47 # on MacOS/Windows thus we only support gneration of automata under Linux.
48 # This also means that we don't need to make sure gen-dfa.cc is portable to
49 # non-POSIX platforms (in particular it's not Windows compatible).
50
51 env_gen_dfa = env.Clone()
52 env_gen_dfa.Append(CCFLAGS=['-std=c++0x', '-DNACL_TRUSTED_BUT_NOT_TCB'])
53
54 gen_dfa = env_gen_dfa.ComponentProgram(
55 'gen-dfa',
56 ['unreviewed/gen-dfa.cc'])
57
58 # Source generation step 2: Generate decoder tables.
pasko-google - do not use 2012/04/10 09:32:41 there is step 2, but there is no step 1 the comme
khim 2012/04/10 12:29:38 It's not useless. The fact that step 1 is not name
59 #
60 # Now we are back to conditionally defining the large tables generated
61 # by gen-dfa.
62
63 # Generate 32 and 64 bit versions of decoders and validators.
64 for bits in ['32', '64']:
65 for automata in ['decoder', 'validator']:
66 # We are cheating here: there are two autogenerated files:
pasko-google - do not use 2012/04/10 09:32:41 thank you for this comment
67 # .rl and -consts.c, but we only track .rl one. This is safe because
68 # -consts.c file includes constants referenced by .rl file and if .rl
69 # file is not changed -consts.c is guaranteed to be the same (reverse
70 # is not true).
71 rl_file = '%s-x86_%s-instruction.rl' % (automata, bits)
72 const_file = '%s/%s-x86_%s-instruction-consts.c' % (
73 val_src_dir, automata, bits)
74 exe_path = '${STAGING_DIR}/${PROGPREFIX}gen-dfa${PROGSUFFIX}'
75 gen_env.Command(
76 target=rl_file,
77 source=[
78 exe_path,
79 'unreviewed/general-purpose-instructions.def',
80 'unreviewed/system-instructions.def',
81 'unreviewed/x87-instructions.def',
82 'unreviewed/mmx-instructions.def',
83 'unreviewed/xmm-instructions.def',
84 'unreviewed/nops.def'],
85 action=[('${SOURCES[0]} -o ${TARGET} -c %s -m %s -d %s ${SOURCES[1]} '
86 '${SOURCES[2]} ${SOURCES[3]} ${SOURCES[4]} ${SOURCES[5]} '
87 '${SOURCES[6]}') % (
88 # Const file (-c): not tracked by SCONS (see above)
89 const_file,
90 # Argument for CPU type (-m): either "ia32" or "amd64".
91 {'32': 'ia32', '64': 'amd64'}[bits],
92 # Argument for actions selection (-d): selects only actions we need.
93 {'decoder32':
94 'check_access,opcode,parse_operands_states,mark_data_fields',
95 'decoder64':
96 'check_access,opcode,parse_operands_states,mark_data_fields',
97 'validator32':
98 ('check_access,opcode,parse_operands,parse_operands_states,'
99 'instruction_name,mark_data_fields,nacl-forbidden,'
100 'imm_operand_action,rel_operand_action'),
101 'validator64':
102 ('opcode,instruction_name,mark_data_fields,rel_operand_action,'
103 'nacl-forbidden')}[automata+bits])]
104 )
105 tables.append(rl_file)
106 c_file = '%s/%s-x86_%s.c' % (val_src_dir, automata, bits)
107 gen_env.Command(
108 target=c_file,
109 source=['unreviewed/%s-x86_%s.rl' % (automata, bits), rl_file],
110 action=['ragel -G2 -I%s ${SOURCES[0]} -o ${TARGET}' % (rl_src_dir)]
111 )
112 tables.append(c_file)
113
114 # Generate 32 and 64 bit versions of decoders and validators
115 gen_env.AlwaysBuild(
116 gen_env.Alias('valgen', tables))
117 gen_env.AlwaysBuild(
118 gen_env.Alias('valclean', action=[Delete(x) for x in tables]))
119
120 # Generate 32 and 64 bit versions of decoders and validators.
121 for bits in ['32', '64']:
122 for automata in ['decoder', 'validator']:
123 env.ComponentLibrary('%s_x86_%s' % (automata, bits),
124 ['gen/%s-x86_%s.c' % (automata, bits)])
125
126 env.ComponentProgram(
127 'decoder-test',
128 ['unreviewed/decoder-test.c'],
129 EXTRA_LIBS=['decoder_x86_32', 'decoder_x86_64'])
130
131 env.ComponentProgram(
132 'validator-test',
133 ['unreviewed/validator-test.c'],
134 EXTRA_LIBS=['validator_x86_32', 'validator_x86_64'])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698