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

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
« no previous file with comments | « SConstruct ('k') | src/trusted/validator_ragel/unreviewed/Makefile » ('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) 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 generate = False
32 if ('valgen' in COMMAND_LINE_TARGETS) or ('valclean' in COMMAND_LINE_TARGETS):
33 generate = True
34
35 if generate:
36 # Set of generated (source) decoder automatas.
37 automatas = []
38
39 # Source generation step 1: Build generator of ragel files.
40 #
41 # We have generator which reads .def files and produced automata definition.
42 #
43 # Ragel is included in most Linux distributions, but it's not standard tool
44 # on MacOS/Windows thus we only support gneration of automata under Linux.
45 # This also means that we don't need to make sure gen-dfa.cc is portable to
46 # non-POSIX platforms (in particular it's not Windows compatible).
47
48 env_gen_dfa = env.Clone()
49 env_gen_dfa.Append(CCFLAGS=['-std=c++0x', '-DNACL_TRUSTED_BUT_NOT_TCB'])
50
51 gen_dfa = env_gen_dfa.ComponentProgram(
52 'gen-dfa',
53 ['unreviewed/gen-dfa.cc'])
54
55 # Source generation step 2: Generate decoder automatas.
56 #
57 # Now we are back to conditionally defining the large automatas generated
58 # by gen-dfa.
59
60 # Generate 32 and 64 bit versions of decoders and validators.
61 for bits in ['32', '64']:
62 for automata in ['decoder', 'validator']:
63 # We are cheating here: there are two autogenerated files:
64 # .rl and -consts.c, but we only track .rl one. This is safe because
65 # -consts.c file includes constants referenced by .rl file and if .rl
66 # file is not changed -consts.c is guaranteed to be the same (reverse
67 # is not true).
68 rl_file = '%s-x86_%s-instruction.rl' % (automata, bits)
69 const_file = '%s/%s-x86_%s-instruction-consts.c' % (
70 val_src_dir, automata, bits)
71 exe_path = '${STAGING_DIR}/${PROGPREFIX}gen-dfa${PROGSUFFIX}'
72 env.Command(
73 target=rl_file,
74 source=[
75 exe_path,
76 'unreviewed/general-purpose-instructions.def',
77 'unreviewed/system-instructions.def',
78 'unreviewed/x87-instructions.def',
79 'unreviewed/mmx-instructions.def',
80 'unreviewed/xmm-instructions.def',
81 'unreviewed/nops.def'],
82 action=[('${SOURCES[0]} -o ${TARGET} -c %s -m %s -d %s ${SOURCES[1]} '
83 '${SOURCES[2]} ${SOURCES[3]} ${SOURCES[4]} ${SOURCES[5]} '
84 '${SOURCES[6]}') % (
85 # Const file (-c): not tracked by SCONS (see above)
86 const_file,
87 # Argument for CPU type (-m): either "ia32" or "amd64".
88 {'32': 'ia32', '64': 'amd64'}[bits],
89 # Argument for actions selection (-d): selects only actions we need.
90 {'decoder32':
91 'check_access,opcode,parse_operands_states,mark_data_fields',
92 'decoder64':
93 'check_access,opcode,parse_operands_states,mark_data_fields',
94 'validator32':
95 ('check_access,opcode,parse_operands,parse_operands_states,'
96 'instruction_name,mark_data_fields,nacl-forbidden,'
97 'imm_operand_action,rel_operand_action'),
98 'validator64':
99 ('opcode,instruction_name,mark_data_fields,rel_operand_action,'
100 'nacl-forbidden')}[automata+bits])]
101 )
102 automatas.append(rl_file)
103 c_file = '%s/%s-x86_%s.c' % (val_src_dir, automata, bits)
104 env.Command(
105 target=c_file,
106 source=['unreviewed/%s-x86_%s.rl' % (automata, bits), rl_file],
107 action=['ragel -G2 -I%s ${SOURCES[0]} -o ${TARGET}' % (rl_src_dir)]
108 )
109 automatas.append(c_file)
110
111 # Generate 32 and 64 bit versions of decoders and validators
112 env.AlwaysBuild(env.Alias('valgen', automatas))
113 env.AlwaysBuild(env.Alias('valclean', action=[Delete(x) for x in automatas]))
114
115 # Generate 32 and 64 bit versions of decoders and validators.
116 for bits in ['32', '64']:
117 for automata in ['decoder', 'validator']:
118 env.ComponentLibrary('%s_x86_%s' % (automata, bits),
119 ['gen/%s-x86_%s.c' % (automata, bits)])
120
121 env.ComponentProgram(
122 'decoder-test',
123 ['unreviewed/decoder-test.c'],
124 EXTRA_LIBS=['decoder_x86_32', 'decoder_x86_64'])
125
126 env.ComponentProgram(
127 'validator-test',
128 ['unreviewed/validator-test.c'],
129 EXTRA_LIBS=['validator_x86_32', 'validator_x86_64'])
OLDNEW
« 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