Make ncval-annotate and ncval-stubout executable
[nativeclient.git] / ncv / SConscript
blob5ae301dcdad87650c2aab00f698fe9ccf7de70b9
1 # Copyright 2008, Google Inc.
2 # All rights reserved.
3
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
7
8 #     * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 #     * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the
13 # distribution.
14 #     * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived from
16 # this software without specific prior written permission.
17
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 import sys
32 Import('env')
34 env.Append(
35     CPPPATH = [
36        '$SOURCE_ROOT/googleclient',
37        # So we can use generated things with paths from googleclient.
38        # TODO: figure out a better way to do this.
39        '.',
40     ],
43 if env['TARGET_PLATFORM'] != 'WINDOWS':
44   env.Append(
45     CCFLAGS = [
46         '-Wsign-compare',
47     ],
48   )
50 # TODO: clean this up more
51 sdl_env = env.Clone()
52 sdl_env.Tool('sdl')
53 sdl_dll = []
54 if env.Bit('windows'):
55   sdl_dll += sdl_env.Replicate('$STAGING_DIR', '$SDL_DIR/lib/SDL.dll')
56   sdl_dll += sdl_env.Replicate('.', '$SDL_DIR/lib/SDL.dll')
57 elif env.Bit('mac'):
58   sdl_dll += sdl_env.Replicate('$TARGET_ROOT/Frameworks',
59                                '$SDL_DIR/SDL.framework')
60   sdl_dll += sdl_env.Replicate('$OBJ_ROOT/Frameworks', '$SDL_DIR/SDL.framework')
61 elif env.Bit('linux'):
62   sdl_dll += sdl_env.Replicate('$STAGING_DIR', '$SDL_DIR/lib/libSDL-1.2.so.0')
63   sdl_dll += sdl_env.Replicate('.', '$SDL_DIR/lib/libSDL-1.2.so.0')
65 # Make a copy of debug CRT for now.
66 # TODO: there should be a better way to generalize this requirement.
67 crt = []
68 if env.AllBits('windows', 'debug'):
69   for i in ['.', '$STAGING_DIR']:
70     crt += env.Replicate(i, '$VC80_DIR/vc/redist/Debug_NonRedist/'
71                          'x86/Microsoft.VC80.DebugCRT')
72     crt += env.Replicate(i, '$VC80_DIR/vc/redist/x86/Microsoft.VC80.CRT')
75 # Isolate the environment for ncdecode_table to prevent a cycle.
76 env_decode_table = env.Clone()
77 env_decode_table['COVERAGE_LINKCOM_EXTRAS'] = None
78 ncdecode_table = env_decode_table.ComponentProgram('ncdecode_table',
79                                                    'ncdecode_table.c')
80 env.Requires(ncdecode_table, crt)
81 env.Requires(ncdecode_table, sdl_dll)
83 # Link everyone else to ncvalidate.
84 env.Append(LIBS = ['ncvalidate', 'ncvtest'])
86 ncvalidate_inputs = [
87     'nacl_cpuid.c',
88     'ncdecode.c',
89     'ncvalidate.c',
92 ncv_test_inputs = [
93     'ncdecode_tests.c',
94     'ncfileutil.c',
97 env.ComponentLibrary('ncvalidate', ncvalidate_inputs)
98 env.ComponentLibrary('ncvtest', ncv_test_inputs)
100 env.Command(
101     ['native_client/ncv/ncdecodetab.h', 'native_client/ncv/ncdisasmtab.h'],
102     ncdecode_table,
103     'cd ${TARGET.dir} && ${SOURCE.abspath}')
105 nacl_cpuid = env.ComponentProgram('nacl_cpuid', 'nacl_cpuid_test.c')
106 env.Requires(nacl_cpuid, crt)
107 env.Requires(nacl_cpuid, sdl_dll)
109 env.ComponentProgram('ncdis', 'ncdis.c')
110 ncval = env.ComponentProgram('ncval', ['ncval.c', 'ncval_tests.c'])
111 env.Requires(ncval, crt)
112 env.Requires(ncval, sdl_dll)
115 # TODO: get OSX and Windows working below here
116 if env['TARGET_PLATFORM'] in ['WINDOWS', 'MAC']:
117   Return()
120 node = env.Command('nacl_cpuid_test.out',
121                    nacl_cpuid,
122                    '${SOURCES[0].abspath} > ${TARGET}')
124 env.ComponentTestOutput('cpuid_test', node)
126 env.AddNodeToLargeTestsSuite(node)
127 AlwaysBuild(node)