OLD | NEW |
| (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'): Return() | |
16 | |
17 # ------------------------------------------------------ | |
18 # General adjustments to the environment for builds. | |
19 | |
20 # TODO(bradchen): eliminate need for the following line | |
21 env.FilterOut(CCFLAGS=['-Wextra', '-Wswitch-enum', '-Wsign-compare']) | |
22 | |
23 # Defines the source directory where validator generated files should be added. | |
24 val_src_dir = '$MAIN_DIR/src/trusted/validator/x86/ncval_seg_sfi' | |
25 # ------------------------------------------------------ | |
26 # Source generation: | |
27 # | |
28 # Source generation is controlled by to command line directives, and can be | |
29 # built in either the x86-32 or the x86-64 platform. The two directives are: | |
30 # | |
31 # valclean : Delete the existing versions of the generated files. | |
32 # This step should be done whenever ANY change may effect | |
33 # the generated sources. | |
34 # | |
35 # valgen : Regenerate any deleted source files. Note: some generated | |
36 # source files do understand dependencies and do not need to be | |
37 # deleted before calling valgen. However, do not count on this, | |
38 # as some dependencies are not caught. To be safe, if you have | |
39 # modified a file that effects source generation, run "valclean" | |
40 # followed by a "valgen" to guarantee that generated sources are | |
41 # up to date. | |
42 | |
43 | |
44 gen_env = env.Clone() | |
45 gen_env.Append(CCFLAGS=['-DNACL_TRUSTED_BUT_NOT_TCB']) | |
46 | |
47 generate = False | |
48 if 'valgen' in COMMAND_LINE_TARGETS: generate = True | |
49 if 'valclean' in COMMAND_LINE_TARGETS: generate = True | |
50 | |
51 # Set of generated (source) decoder tables. | |
52 tables = [] | |
53 | |
54 # ------------------------------------------------------ | |
55 # Table generators: | |
56 # | |
57 # In the middle of generating, we unconditionally add ncdecode_table and | |
58 # ncdecode_tablegen so that the tests which depend on it, can run correctly. | |
59 # This step sits in the middle because of dependency order, where the next | |
60 # generation step requires this executable. | |
61 | |
62 # Add x86 decoder table generator for segment SFI sandboxing validator. | |
63 # | |
64 # | |
65 # Isolate the environment for ncdecode_table to prevent a cycle. | |
66 env_decode_table = env.Clone() | |
67 env_decode_table.Append(CCFLAGS=['-DNACL_TRUSTED_BUT_NOT_TCB']) | |
68 | |
69 # TODO: This should be handled more cleanly, by just building | |
70 # Testing type programs for coverage. But for the moment, we need sel_ldr | |
71 # and others to have coverage, so it's easier to gate it off here. | |
72 env_decode_table['COVERAGE_LINKCOM_EXTRAS'] = None | |
73 | |
74 ncdecode_table = env_decode_table.ComponentProgram( | |
75 'ncdecode_table', | |
76 ['ncdecode_table.c'], | |
77 EXTRA_LIBS=[env_decode_table.NaClTargetArchSuffix('ncval_base_verbose')]) | |
78 | |
79 # ------------------------------------------------------ | |
80 # Source generation step 2: Generate decoder tables. | |
81 # | |
82 # Now we are back to conditionally defining the large tables generated | |
83 # by ncdecode_tablegen. | |
84 # | |
85 if generate: | |
86 # | |
87 # Generate 32 and 64 bit versions of ncdecodetab and ncdisasmtab. | |
88 # | |
89 for bits in ['32', '64']: | |
90 ncv_decodetab_h = '%s/gen/%s_%s.h' % (val_src_dir, 'ncdecodetab', bits) | |
91 ncv_disasmtab_h = '%s/gen/%s_%s.h' % (val_src_dir, 'ncdisasmtab', bits) | |
92 ncv_badprefixmask_h= '%s/gen/%s_%s.h' % ( | |
93 val_src_dir, 'ncbadprefixmask', bits) | |
94 exe_path = '${STAGING_DIR}/${PROGPREFIX}ncdecode_table${PROGSUFFIX}' | |
95 gen_env.Command( | |
96 [ncv_decodetab_h, ncv_disasmtab_h, ncv_badprefixmask_h], | |
97 exe_path, | |
98 ['%s -m%s %s %s %s' % (exe_path, bits, ncv_decodetab_h, | |
99 ncv_disasmtab_h, ncv_badprefixmask_h )] | |
100 ) | |
101 tables.append(ncv_decodetab_h) | |
102 tables.append(ncv_disasmtab_h) | |
103 tables.append(ncv_badprefixmask_h) | |
104 | |
105 # Generate 32 and 64 bit versions of ncval_opcode_table (validator | |
106 # decoder tables) | |
107 gen_env.AlwaysBuild( | |
108 gen_env.Alias('valgen', tables)) | |
109 gen_env.AlwaysBuild( | |
110 gen_env.Alias('valclean', action=[Delete(x) for x in tables])) | |
OLD | NEW |