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

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
Nick Bray 2012/04/07 00:17:46 Document why, and/or link to a bug.
khim 2012/04/07 13:26:53 Created a bug. This is serious work (we've already
19 if env.Bit('windows'):
20 env.FilterOut(CCFLAGS=['/O1'])
21 env.Append(CCFLAGS=['/O0'])
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/generated'
26
27 # Source generation:
28 #
Nick Bray 2012/04/07 00:17:46 Comments for space aren't done anywhere else. Ref
khim 2012/04/07 13:26:53 How? This is copy-pasted from Karl's validator fil
29 # valgen : Regenerate any autogenerated source files.
30
31 gen_env = env.Clone();
32 gen_env.Append(CCFLAGS=['-DNACL_TRUSTED_BUT_NOT_TCB'])
33
34 generate = False
35 if 'valgen' in COMMAND_LINE_TARGETS: generate = True
36 if 'valclean' in COMMAND_LINE_TARGETS: generate = True
Nick Bray 2012/04/07 00:17:46 Two lines for each if, merge the conditions if you
khim 2012/04/07 13:26:53 Again: this is copy-pasted from Karl's validator.
37
38 # Set of generated (source) decoder tables.
39 tables = []
40
41 # Ragel generator:
42 #
43 # We have generator which reads .def files and produced automata definition.
44
45 env_gen_dfa = env.Clone()
46 env_gen_dfa.Append(CCFLAGS=['-std=c++0x', '-DNACL_TRUSTED_BUT_NOT_TCB'])
47
48 gen_dfa = env_gen_dfa.ComponentProgram(
49 'gen-dfa',
50 ['unreviewed/gen-dfa.cc'])
51
52 # Source generation step 2: Generate decoder tables.
53 #
54 # Now we are back to conditionally defining the large tables generated
55 # by gen-dfa.
56
57 # Generate 32 and 64 bit versions of decoders and validators.
58 if generate:
59 for bits in ['32', '64']:
60 for automata in ['decoder', 'validator']:
61 rl_file = '%s-x86_%s-instruction.rl' % (automata, bits)
62 const_file = '%s/%s-x86_%s-instruction-consts.c' % (
63 rl_src_dir, automata, bits)
64 exe_path = '${STAGING_DIR}/${PROGPREFIX}gen-dfa${PROGSUFFIX}'
65 gen_env.Command(
66 target=rl_file,
67 source=[exe_path,
Nick Bray 2012/04/07 00:17:46 Put on its own line line so it lines up with its s
khim 2012/04/07 13:26:53 Well... It's kinda special, but Ok.
68 'unreviewed/general-purpose-instructions.def',
69 'unreviewed/system-instructions.def',
70 'unreviewed/x87-instructions.def',
71 'unreviewed/mmx-instructions.def',
72 'unreviewed/xmm-instructions.def',
73 'unreviewed/nops.def'],
74 action=[('${SOURCES[0]} -o ${TARGET} -m %s -d %s ${SOURCES[1]} '
75 '${SOURCES[2]} ${SOURCES[3]} ${SOURCES[4]} ${SOURCES[5]} '
76 '${SOURCES[6]} && { ! test -e %s || mv -f %s %s/ ; }') % (
Nick Bray 2012/04/07 00:17:46 Embedding shell scripts into a SCons action seems
khim 2012/04/07 13:26:53 Why is it unexpected? This is normal practice in m
pasko-google - do not use 2012/04/09 08:35:10 I do not quite understand what you guys are referr
77 {'32': 'ia32', '64': 'amd64'}[bits],
78 {'decoder32':
79 'check_access,opcode,parse_operands_states,mark_data_fields',
80 'decoder64':
81 'check_access,opcode,parse_operands_states,mark_data_fields',
82 'validator32':
83 ('check_access,opcode,parse_operands,parse_operands_states,'
84 'instruction_name,mark_data_fields,nacl-forbidden,'
85 'imm_operand_action,rel_operand_action'),
86 'validator64':
87 'opcode,instruction_name,mark_data_fields,rel_operand_action,' +
88 'nacl-forbidden'}[automata+bits],
89 const_file, const_file, val_src_dir)]
90 )
91 tables.append(rl_file)
92 c_file = '%s/%s-x86_%s.c' % (val_src_dir, automata, bits)
93 gen_env.Command(
94 target=c_file,
95 source=['unreviewed/%s-x86_%s.rl' % (automata, bits), rl_file],
96 action=['ragel -G2 -I%s ${SOURCES[0]} -o ${TARGET}' % (rl_src_dir)]
97 )
98 tables.append(c_file)
99
100 # Generate 32 and 64 bit versions of decoders and validators
101 gen_env.AlwaysBuild(
102 gen_env.Alias('valgen', tables))
103 gen_env.AlwaysBuild(
104 gen_env.Alias('valclean', action=[Delete(x) for x in tables]))
105
106 # Generate 32 and 64 bit versions of decoders and validators.
107 for bits in ['32', '64']:
108 for automata in ['decoder', 'validator']:
109 env.ComponentLibrary('%s-x86_%s' % (automata, bits),
110 ['generated/%s-x86_%s.c' % (automata, bits)])
111
112 env.ComponentProgram(
113 'decoder-test',
114 ['unreviewed/decoder-test.c'],
115 EXTRA_LIBS=['decoder-x86_32', 'decoder-x86_64'])
116
117 env.ComponentProgram(
118 'validator-test',
119 ['unreviewed/validator-test.c'],
120 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