1 # Copyright 2008, Google Inc.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
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
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.
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.
35 # TODO: Prepend (vs Append) shouldn't be needed but is for
39 '$SOURCE_ROOT/googleclient',
40 '$SOURCE_ROOT/googleclient/third_party/gtest/include',
55 if not env.Bit('windows'):
64 # Make a copy of debug CRT for now.
65 # TODO: there should be a better way to generalize this requirement.
67 if env.AllBits('windows', 'debug'):
68 for i in ['.', '$STAGING_DIR']:
69 crt += env.Replicate(i, '$VC80_DIR/vc/redist/Debug_NonRedist/'
70 'x86/Microsoft.VC80.DebugCRT')
71 crt += env.Replicate(i, '$VC80_DIR/vc/redist/x86/Microsoft.VC80.CRT')
74 if env.Bit('windows'):
75 syscall_impl = 'win/nacl_syscall_impl.c'
77 syscall_impl = 'linux/nacl_syscall_impl.c'
80 env.Command(target='nacl_syscall_handlers.c',
81 source=[syscall_impl, 'nacl_syscall_handlers_gen2.py'],
82 action=[Copy('${TARGET}.tmp', '$SOURCE'),
83 Chmod('${TARGET}.tmp', 0755),
84 Action('$PYTHON ${SOURCES[1]}'
85 ' $GEN2_FLAGS < $SOURCE >>${TARGET}.tmp'),
86 Move('$TARGET', '${TARGET}.tmp')])
96 'nacl_desc_effector_cleanup.c',
97 'nacl_desc_effector_ldr.c',
98 'nacl_desc_semaphore.c',
101 'nacl_memory_object.c',
102 'nacl_switch_to_app.c',
104 'nacl_syscall_common.c',
105 'nacl_syscall_handlers.c',
106 'nacl_syscall_hook.c',
109 'sel_ldr_standard.c',
114 'sel_validate_image.c',
116 '$NACL_PLATFORM/nacl_ldt.c',
124 if env.Bit('windows'):
125 nacl_thread_inputs = [
126 'win/nacl_threads.c',
132 'win/sel_segments.c',
135 nacl_thread_inputs = [
136 'linux/nacl_threads.c',
140 'linux/sel_memory.c',
141 'linux/sel_segments.c',
144 nacl_thread_inputs = [
145 'linux/nacl_threads.c',
149 'linux/sel_memory.c',
150 'linux/sel_segments.c',
153 # ----------------------------------------------------------
155 # NOTE: there are some more sdl hacks in ../SConstruct
156 # ----------------------------------------------------------
157 sdl_mode = ARGUMENTS.get('sdl', 'hermetic')
158 # Require a valid sdl mode.
159 if sdl_mode not in ['hermetic', 'local', 'none']:
161 if sdl_mode != 'none':
164 print 'SDL build enabled, this is somewhat experimental'
165 print env.subst('Using version in $SDL_DIR')
167 env.Replace(GEN2_FLAGS='-c')
169 CPPDEFINES = ['HAVE_SDL'],
171 if env.Bit('windows'):
173 env.Append(LINKFLAGS = ['/SUBSYSTEM:CONSOLE'])
175 env.Append(LINKFLAGS = ['/SUBSYSTEM:WINDOWS'])
177 env_sdlmain = env.Clone()
178 env_sdlmain.FilterOut(CCFLAGS=['-Werror'])
180 env_sdlmain.ComponentObject(
182 '$MAIN_DIR/common/SDLApplication.m'),
186 # ----------------------------------------------------------
188 # ----------------------------------------------------------
189 env.ComponentLibrary('naclthread', nacl_thread_inputs)
190 env.ComponentLibrary('sel', ldr_inputs)
192 env_no_strict_aliasing = env.Clone()
194 env_no_strict_aliasing.Append(CFLAGS = ['-fno-strict-aliasing'])
196 nrd_xfer_obj = env_no_strict_aliasing.ComponentObject('nrd_xfer_lib/nrd_xfer.c')
201 'nacl_desc_conn_cap.c',
204 'nacl_desc_imc_bound_desc.c',
205 'nacl_desc_imc_shm.c',
208 'nacl_global_secure_random.c',
209 'nacl_host_desc_common.c',
210 'nacl_interruptible_condvar.c',
211 'nacl_interruptible_mutex.c',
213 'nacl_secure_random_common.c',
215 'nacl_sync_checked.c',
219 'nrd_xfer_lib/nrd_all_modules.c',
221 'nrd_xfer_lib/nrd_xfer_effector.c',
224 if env.Bit('windows'):
226 'win/condition_variable.cc',
228 'win/lock_impl_win.cc',
230 'win/nacl_host_desc.c',
231 'win/nacl_host_dir.c',
232 'win/nacl_semaphore.c',
233 'win/nacl_secure_random.c',
234 'win/nacl_timestamp.c',
236 'win/xlate_system_error.c',
240 'linux/condition_variable.cc',
243 'linux/nacl_host_desc.c',
244 'osx/nacl_host_dir.c',
245 'osx/nacl_semaphore.c',
246 'linux/nacl_secure_random.c',
247 'linux/nacl_timestamp.c',
248 'linux/time_linux.cc',
252 'linux/condition_variable.cc',
255 'linux/nacl_host_desc.c',
256 'linux/nacl_host_dir.c',
257 'linux/nacl_semaphore.c',
258 'linux/nacl_secure_random.c',
259 'linux/nacl_timestamp.c',
260 'linux/time_linux.cc',
263 env.ComponentLibrary('nrd_xfer', nrd_lib_inputs)
269 'gio_mem_snapshot.c',
271 env.ComponentLibrary('gio', gio_inputs)
274 # NOTE: these extra libs were orignially only added to the
276 if env.Bit('windows'):
282 # TODO: ntdll.lib is required for sem_get_value implementation but
283 # it is available in Windows DDK only. The DDK is not
284 # in googleclient/third_party, but we might need to add it if we want to use it.
289 # TODO: clean this up more
291 if env.Bit('windows'):
292 sdl_dll += env.Replicate('$STAGING_DIR', '$SDL_DIR/lib/SDL.dll')
293 sdl_dll += env.Replicate('.', '$SDL_DIR/lib/SDL.dll')
295 sdl_dll += env.Replicate('$TARGET_ROOT/Frameworks', '$SDL_DIR/SDL.framework')
296 sdl_dll += env.Replicate('$OBJ_ROOT/Frameworks', '$SDL_DIR/SDL.framework')
297 elif env.Bit('linux'):
298 sdl_dll += env.Replicate('$STAGING_DIR', '$SDL_DIR/lib/libSDL-1.2.so.0')
299 sdl_dll += env.Replicate('.', '$SDL_DIR/lib/libSDL-1.2.so.0')
302 if not env.get('COVERAGE_ENABLED') or not env.Bit('windows'):
303 SEL_LDR_NODE = env.ComponentProgram('sel_ldr', 'sel_main.c')
304 env.ComponentProgram('sel_universal', 'sel_universal.c')
305 env.ComponentProgram('nacl_ldt_unittest', 'nacl_ldt_unittest.c')
306 env.Requires(SEL_LDR_NODE, crt)
307 env.Requires(SEL_LDR_NODE, sdl_dll)
309 # ----------------------------------------------------------
311 # ----------------------------------------------------------
315 'sel_memory_unittest.cc',
316 'nacl_sync_unittest.cc',
318 UNITTEST_OUTPUT = env.subst('$TARGET_ROOT/test_results/service_runtime/gtest_output.xml')
319 env['ENV']['GTEST_OUTPUT'] = 'xml:' + UNITTEST_OUTPUT
321 unit_tests_exe = env.ComponentProgram('service_runtime_tests', unittest_inputs,
322 OTHER_LIBS = ['gtest'])
323 env.Requires(unit_tests_exe, sdl_dll)
325 env.ComponentProgram('mmap_test', 'mmap_test.c')
327 # TODO: the "-d" argument does nothing, however Hammer doesn't run
328 # the test if it is launched without any arguments.
333 env.AddNodeToSmallTestsSuite(node)
335 env.ComponentTestOutput('run_service_runtime_tests', node)
337 # TODO: this test is missing a dependency to the binaries it runs
339 '$TARGET_ROOT/test_results/simple_tests_results.xml',
340 '$SCONSTRUCT_DIR/tools/simple_tests_list.txt',
341 '$PYTHON $SCONSTRUCT_DIR/tools/run_simple_tests.py $SOURCE $TARGET $OBJ_ROOT')
342 env.AddNodeToSmallTestsSuite(node)
344 env.ComponentTestOutput('simple_tests', node)
347 # ----------------------------------------------------------
349 # ----------------------------------------------------------
350 node = env.CommandSelLdrTestNacl(
352 env.File('testdata/mandel.nexe'),
353 stdin='$SCONSTRUCT_DIR/tests/mandel/test.stdin',
354 stdout='$SCONSTRUCT_DIR/tests/mandel/test.stdout',
358 env.AddNodeToSmokeTestSuite(node)
359 env.AddNodeToMediumTestsSuite(node)
361 node = env.CommandSelLdrTestNacl(
362 "fib_scalar_canned.out",
363 env.File('testdata/fib_scalar.nexe'),
364 stdin='$SCONSTRUCT_DIR/tests/fib/fib_scalar_test.stdin',
365 stdout='$SCONSTRUCT_DIR/tests/fib/fib_scalar_test.stdout',
368 env.AddNodeToSmokeTestSuite(node)
369 env.AddNodeToMediumTestsSuite(node)
371 node = env.CommandSelLdrTestNacl(
372 "fib_array_canned.out",
373 env.File('testdata/fib_array.nexe'),
374 stdin='$SCONSTRUCT_DIR/tests/fib/fib_array_test.stdin',
375 stdout='$SCONSTRUCT_DIR/tests/fib/fib_array_test.stdout',
378 env.AddNodeToSmokeTestSuite(node)
379 env.AddNodeToMediumTestsSuite(node)