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

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/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 env.Append(CCFLAGS=['/O0'])
23
24 # Defines the source directory where validator generated files should be added.
25 rl_src_dir = '$OBJ_ROOT/src/trusted/validator_ragel'
26 val_src_dir = '$MAIN_DIR/src/trusted/validator_ragel/generated'
27
28 # Source generation:
29 #
30 # valgen : Regenerate any autogenerated source files.
31
32 gen_env = env.Clone();
33 gen_env.Append(CCFLAGS=['-DNACL_TRUSTED_BUT_NOT_TCB'])
34
35 generate = False
36 if ('valgen' in COMMAND_LINE_TARGETS) or ('valclean' in COMMAND_LINE_TARGETS):
37 generate = True
38
39 # Set of generated (source) decoder tables.
40 tables = []
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.
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 if generate:
65 for bits in ['32', '64']:
66 for automata in ['decoder', 'validator']:
67 # We are cheating here: there are two autogenerated files:
68 # .rl and -consts.c, but we only track .rl one. This is safe because
69 # -consts.c file includes constants referenced by .rl file and if .rl
70 # file is not changed -consts.c is guaranteed to be the same (reverse
71 # is not true).
72 rl_file = '%s-x86_%s-instruction.rl' % (automata, bits)
73 const_file = '%s/%s-x86_%s-instruction-consts.c' % (
74 val_src_dir, automata, bits)
75 exe_path = '${STAGING_DIR}/${PROGPREFIX}gen-dfa${PROGSUFFIX}'
76 gen_env.Command(
77 target=rl_file,
78 source=[
79 exe_path,
80 'unreviewed/general-purpose-instructions.def',
81 'unreviewed/system-instructions.def',
82 'unreviewed/x87-instructions.def',
83 'unreviewed/mmx-instructions.def',
84 'unreviewed/xmm-instructions.def',
85 'unreviewed/nops.def'],
86 action=[('${SOURCES[0]} -o ${TARGET} -c %s -m %s -d %s ${SOURCES[1]} '
87 '${SOURCES[2]} ${SOURCES[3]} ${SOURCES[4]} ${SOURCES[5]} '
88 '${SOURCES[6]}') % (
89 # Const file (-c): not tracked by SCONS (see above)
90 const_file,
91 # Argument for CPU type (-m): either "ia32" or "amd64".
92 {'32': 'ia32', '64': 'amd64'}[bits],
93 # Argument for actions selection (-d): selects only actions we need.
94 {'decoder32':
95 'check_access,opcode,parse_operands_states,mark_data_fields',
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':
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 target=c_file,
110 source=['unreviewed/%s-x86_%s.rl' % (automata, bits), rl_file],
111 action=['ragel -G2 -I%s ${SOURCES[0]} -o ${TARGET}' % (rl_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]))
120
121 # Generate 32 and 64 bit versions of decoders and validators.
122 for bits in ['32', '64']:
123 for automata in ['decoder', 'validator']:
124 env.ComponentLibrary('%s-x86_%s' % (automata, bits),
pasko-google - do not use 2012/04/09 10:04:27 you suggest a validator library be named like: val
pasko-google - do not use 2012/04/09 10:38:54 hm, in fact it is called libvalidator-x86_64.a, bu
125 ['generated/%s-x86_%s.c' % (automata, bits)])
126
127 env.ComponentProgram(
128 'decoder-test',
129 ['unreviewed/decoder-test.c'],
130 EXTRA_LIBS=['decoder-x86_32', 'decoder-x86_64'])
131
132 env.ComponentProgram(
133 'validator-test',
134 ['unreviewed/validator-test.c'],
135 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