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