2 # Copyright 2008, Google Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
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
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.
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.
36 sys
.path
.append("./common")
41 Dir('gtest').addRepository(Dir('../third_party/gtest/files'))
46 # ----------------------------------------------------------
47 # Base environment for both nacl and non-nacl variants.
48 pre_base_env
= Environment(
49 tools
= ['component_setup'],
50 # Makes SOURCE_ROOT independent of site_init.
51 SOURCE_ROOT
= Dir('#/../..').abspath
,
52 # Publish dlls as final products (to staging).
53 COMPONENT_LIBRARY_PUBLISH
= True,
55 pre_base_env
.Append(BUILD_GROUPS
=['most'])
56 # ----------------------------------------------------------
57 # Small tests are usually unit tests
59 def AddNodeToSmallTestsSuite(env
, node
):
60 Alias('small_tests', node
)
62 pre_base_env
.AddMethod(AddNodeToSmallTestsSuite
)
64 # ----------------------------------------------------------
66 Alias('unit_tests', 'small_tests')
68 # ----------------------------------------------------------
69 # Medium tests are usually larger than unit tests, but don't take as much time
71 def AddNodeToMediumTestsSuite(env
, node
):
72 Alias('medium_tests', node
)
74 pre_base_env
.AddMethod(AddNodeToMediumTestsSuite
)
76 # ----------------------------------------------------------
77 # Large tests are usually long tests
79 def AddNodeToLargeTestsSuite(env
, node
):
80 Alias('large_tests', node
)
82 pre_base_env
.AddMethod(AddNodeToLargeTestsSuite
)
84 # ----------------------------------------------------------
86 def AddNodeToSmokeTestSuite(env
, node
):
87 env
.Alias('smoke_test', node
)
89 pre_base_env
.AddMethod(AddNodeToSmokeTestSuite
)
91 def _SmokeTestIntro(**args
):
92 Banner("Running Smoke Test")
94 node
= pre_base_env
.Command(target
='dummy',
96 action
=_SmokeTestIntro
)
99 pre_base_env
.AddNodeToSmokeTestSuite(node
)
101 # ----------------------------------------------------------
107 pre_base_env
.AddMethod(Banner
)
110 def FindLikelySelLdr(directory
):
112 if (nacl_util
.GetSelLdr('opt')):
113 candidates
.append(nacl_util
.GetSelLdr('opt'))
114 if (nacl_util
.GetSelLdr('dbg')):
115 candidates
.append(nacl_util
.GetSelLdr('dbg'))
118 mtime
= os
.stat(c
)[stat
.ST_MTIME
]
119 if mtime
> latest
[1]:
124 def CommandSelLdrTestNacl(env
, name
, exe
, guess_sel_ldr
=False, flags
='" "',
125 stdin
='None', stdout
='None', filter='""',
127 stderr_filter
=('"^(NeverMatched AlwaysIgnoreStderr)'
130 log_golden
='None', log_filter
='".*"',
132 # the default for stderr_filter is a heuristic: it should only
133 # match the phrase "NeverMatched AlwaysIgnoreStderr" repeated 999
134 # times, so should serve as a filter that ignores all stderr
135 # output. (There is, AFAIK, no regexp that always fails to match.)
136 # Since for non-death tests we had been ignoring stderr output,
137 # this way we get (approximately) the same behavior.
138 script
= '${SCONSTRUCT_DIR}/tools/sel_ldr_tester.py'
140 sel_ldr
= FindLikelySelLdr(env
.subst('$DESTINATION_ROOT'))
141 # Bail out if sel_ldr can't be found.
142 if not sel_ldr
: return []
144 sel_ldr
= '$STAGING_DIR/${PROGPREFIX}sel_ldr${PROGSUFFIX}'
145 deps
= [script
, sel_ldr
, exe
]
146 if stdin
!= 'None': deps
.append(stdin
)
147 if stdout
!= 'None': deps
.append(stdout
)
149 if log_golden
!= 'None':
150 log_output
= '${TARGET}.log'
151 # TODO: consider redirecting output into tests/results
152 return env
.Command(name
, deps
,
153 '$PYTHON ${SOURCES[0].abspath} '
154 '${SOURCES[1].abspath} '
155 '${SOURCES[2].abspath} '
156 '%s %s %s %s %s %s %d %s %s %d %s > $TARGET' % (
157 flags
, stdin
, stdout
, filter,
158 stderr
, stderr_filter
, exit_status
,
159 log_golden
, log_filter
, log_verbosity
, log_output
))
161 pre_base_env
.AddMethod(CommandSelLdrTestNacl
)
163 # ----------------------------------------------------------
164 if ARGUMENTS
.get('pp', 0):
165 def CommandPrettyPrinter(cmd
, targets
, source
, env
):
166 prefix
= env
.subst('$SOURCE_ROOT') + '/googleclient/'
168 cmd_tokens
= cmd
.split()
169 if "python" in cmd_tokens
[0]:
170 cmd_name
= cmd_tokens
[1]
172 cmd_name
= cmd_tokens
[0].split('(')[0]
173 if cmd_name
.startswith(prefix
):
174 cmd_name
= cmd_name
[len(prefix
):]
175 env_name
= env
.subst('${BUILD_TYPE}${BUILD_SUBTYPE}')
176 print '[%s] [%s] %s' % (cmd_name
, env_name
, target
.get_path())
177 pre_base_env
.Append(PRINT_CMD_LINE_FUNC
= CommandPrettyPrinter
)
179 # ----------------------------------------------------------
180 base_env
= pre_base_env
.Clone()
183 BUILD_SCONSCRIPTS
= [
184 # NOTE: this dir also has a SConscript.nacl
185 'tests/npapi_bridge/SConscript',
187 'platform_qual_test',
189 'service_runtime/nrd_xfer_lib',
191 'tools/npapi_runtime',
194 'npapi_plugin/install.scons',
200 ['NACL_BLOCK_SHIFT', '5'],
201 ['NACL_BLOCK_SIZE', '32'],
203 GEN2_FLAGS
= '-c -f "Video|Audio|Multimedia"',
206 SDL_HERMETIC_LINUX_DIR
='$MAIN_DIR/../third_party/sdl/linux/v1_2_13',
207 SDL_HERMETIC_MAC_DIR
='$MAIN_DIR/../third_party/sdl/osx/v1_2_13',
208 SDL_HERMETIC_WINDOWS_DIR
='$MAIN_DIR/../third_party/sdl/win/v1_2_13',
213 # Optionally ignore the build process.
214 DeclareBit('prebuilt', 'Disable all build steps, only support install steps')
215 base_env
.SetBitFromOption('prebuilt', False)
216 if base_env
.Bit('prebuilt'):
217 base_env
.Replace(BUILD_SCONSCRIPTS
= ['npapi_plugin/install.scons'])
219 # Add the sdk root path (without setting up the tools).
220 base_env
['NACL_SDK_ROOT_ONLY'] = True
221 base_env
.Tool('naclsdk')
225 ======================================================================
227 ======================================================================
233 * build mandel: scons MODE=all mandel.nexe
234 * some unittests: scons small_tests
235 * a smoke test: scons -k pp=1 smoke_test
236 * 2nd smoke test: scons -k pp=1 MODE=nacl smoke_test
237 * documentation: scons MODE=doc
238 * firefox plugin: scons MODE=opt-linux npGoogleNaClPlugin
239 * sel_ldr: scons MODE=opt-linux sel_ldr
240 * firefox install: scons firefox_install
241 * firefox install pre-built copy : scons firefox_install --prebuilt
245 pp=1 use command line pretty printing (more concise output)
246 sdl=<mode> where <mode>:
247 'none': don't use SDL (default)
248 'local': use locally installed SDL
249 'hermetic': use the hermetic SDL copy
250 naclsdk_mode=<mode> where <mode>:
251 'local': use locally installed sdk kit
252 'download': use the download copy (default)
253 'custom:<path>': use kit at <path>
255 --prebuilt Do not build things, just do install steps
257 Automagically generated help:
258 -----------------------------
261 # ----------------------------------------------------------
262 windows_env
= base_env
.Clone(
263 tools
= ['target_platform_windows'],
264 ASCOM
= '$ASPPCOM /E | as -o $TARGET',
265 PDB
= '${TARGET.base}.pdb',
269 ['NACL_WINDOWS', '1'],
272 ['_WIN32_WINNT', '0x0501']
274 NACL_PLATFORM
= 'win',
275 LIBS
= ['wsock32', 'advapi32'],
276 CCFLAGS
= ['/EHsc', '/WX'],
279 windows_debug_env
= windows_env
.Clone(
280 tools
= ['target_debug'],
281 BUILD_TYPE
= 'dbg-win',
282 BUILD_TYPE_DESCRIPTION
= 'Windows debug build',
285 windows_debug_env
.Append(BUILD_GROUPS
= ['default'])
286 environment_list
.append(windows_debug_env
)
288 windows_optimized_env
= windows_env
.Clone(
289 tools
= ['target_optimized'],
290 BUILD_TYPE
= 'opt-win',
291 BUILD_TYPE_DESCRIPTION
= 'Windows optimized build',
293 environment_list
.append(windows_optimized_env
)
295 if ARGUMENTS
.get('sdl', 'hermetic') != 'none':
296 # These will only apply to sdl!=none builds!
297 windows_debug_env
.Append(
301 windows_optimized_env
.Append(
306 if '/MT' in windows_optimized_env
['CCFLAGS']:
307 windows_optimized_env
.FilterOut(CCFLAGS
=['/MT']);
308 windows_optimized_env
.Append(CCFLAGS
=['/MD']);
309 if '/MTd' in windows_debug_env
['CCFLAGS']:
310 windows_debug_env
.FilterOut(CCFLAGS
=['/MTd']);
311 windows_debug_env
.Append(CCFLAGS
=['/MDd']);
312 # this doesn't feel right, but fixes dbg-win
313 windows_debug_env
.Append(LINKFLAGS
= ['/NODEFAULTLIB:msvcrt'])
314 # make source level debugging a little easier
315 if '/Z7' not in windows_debug_env
['CCFLAGS']:
316 if '/Zi' not in windows_debug_env
['CCFLAGS']:
317 windows_debug_env
.Append(CCFLAGS
=['/Z7'])
319 # ----------------------------------------------------------
321 unix_like_env
= base_env
.Clone()
322 unix_like_env
.Append(
328 '-fvisibility=hidden',
329 '-Wno-unused-variable',
332 CFLAGS
= ['-std=gnu99'],
333 LIBS
= ['pthread', 'ssl', 'crypto'],
336 # ----------------------------------------------------------
338 mac_env
= unix_like_env
.Clone(
339 tools
= ['target_platform_mac'],
340 # TODO: this should really be able to live in unix_like_env
341 # but can't due to what the target_platform_x module is
344 PLUGIN_SUFFIX
= '.bundle',
348 ['NACL_WINDOWS', '0'],
351 ['MAC_OS_X_VERSION_MIN_REQUIRED', 'MAC_OS_X_VERSION_10_4'],
353 NACL_PLATFORM
= 'osx',
354 CCFLAGS
= ['-mmacosx-version-min=10.4']
357 mac_debug_env
= mac_env
.Clone(
358 tools
= ['target_debug'],
359 BUILD_TYPE
= 'dbg-mac',
360 BUILD_TYPE_DESCRIPTION
= 'MacOS debug build',
362 mac_debug_env
.Append(BUILD_GROUPS
= ['default'])
363 environment_list
.append(mac_debug_env
)
365 mac_optimized_env
= mac_env
.Clone(
366 tools
= ['target_optimized'],
367 BUILD_TYPE
= 'opt-mac',
368 BUILD_TYPE_DESCRIPTION
= 'MacOS optimized build',
370 environment_list
.append(mac_optimized_env
)
372 # ----------------------------------------------------------
374 linux_env
= unix_like_env
.Clone(
375 tools
= ['target_platform_linux'],
376 # TODO: this should really be able to live in unix_like_env
377 # but can't due to what the target_platform_x module is
382 # -m32 and -L/usr/lib32 are needed to do 32-bit builds on 64-bit
383 # user-space machines; requires ia32-libs-dev to be installed; or,
384 # failing that, ia32-libs and symbolic links *manually* created for
385 # /usr/lib32/libssl.so and /usr/lib32/libcrypto.so to the current
386 # /usr/lib32/lib*.so.version (tested with ia32-libs 2.2ubuntu11; no
387 # ia32-libs-dev was available for testing).
388 # Additional symlinks of this sort are needed for gtk,
389 # see nonnacl_util/SConscript.
391 linux_env
.SetDefault(
392 # NOTE: look into http://www.scons.org/wiki/DoxygenBuilder
393 DOXYGEN
= ARGUMENTS
.get('DOXYGEN', '/usr/bin/doxygen'),
397 ASFLAGS
= [ '-m32', ],
398 CFLAGS
= [ '-m32', ],
399 CCFLAGS
= [ '-m32', ],
401 ['NACL_WINDOWS', '0'],
406 LINKFLAGS
= [ '-m32', '-L/usr/lib32', ],
407 NACL_PLATFORM
= 'linux',
411 linux_debug_env
= linux_env
.Clone(
412 tools
= ['target_debug'],
413 BUILD_TYPE
= 'dbg-linux',
414 BUILD_TYPE_DESCRIPTION
= 'Linux debug build',
416 linux_debug_env
.Append(BUILD_GROUPS
= ['default'])
417 environment_list
.append(linux_debug_env
)
419 linux_optimized_env
= linux_env
.Clone(
420 tools
= ['target_optimized'],
421 BUILD_TYPE
= 'opt-linux',
422 BUILD_TYPE_DESCRIPTION
= 'Linux optimized build',
424 environment_list
.append(linux_optimized_env
)
427 # ----------------------------------------------------------
428 # The nacl_env is used to build native_client modules
429 # using a special tool chain which produces platform
430 # independent binaries
431 # ----------------------------------------------------------
432 nacl_env
= pre_base_env
.Clone(
435 BUILD_TYPE_DESCRIPTION
= 'NaCl module build',
438 # TODO: This doesn't work at the moment due to a scons
439 # limitation. Commented out until scons is fixed.
440 # hook for app to specify extra libraries
441 #LIBS = "$EXTRA_LIBS",
443 CCFLAGS
= ['-O2', '-mfpmath=sse', '-msse', '-fomit-frame-pointer'],
445 CPPPATH
= ['$SOURCE_ROOT/googleclient'],
448 Banner('Building nexe binaries using sdk at [%s]' %
449 nacl_env
.subst('$NACL_SDK_ROOT'))
453 BUILD_SCONSCRIPTS
= [
454 #### ALPHABETICALLY SORTED ####
455 'intermodule_comm/SConscript.nacl',
458 'tests/app_lib/SConscript.nacl',
459 'tests/cloudfs/SConscript.nacl',
460 'tests/earth/SConscript.nacl',
461 'tests/fib/SConscript.nacl',
462 'tests/file/SConscript.nacl',
463 'tests/hello_world/SConscript.nacl',
464 'tests/imc_shm_mmap/SConscript.nacl',
465 'tests/life/SConscript.nacl',
466 'tests/mandel/SConscript.nacl',
467 'tests/mandel_nav/SConscript.nacl',
468 'tests/many/SConscript.nacl',
469 'tests/mmap/SConscript.nacl',
470 'tests/noop/SConscript.nacl',
471 'tests/npapi_bridge/SConscript.nacl',
472 'tests/npapi_hw/SConscript.nacl',
473 'tests/npapi_pi/SConscript.nacl',
474 'tests/nrd_xfer/SConscript.nacl',
475 'tests/null/SConscript.nacl',
476 'tests/srpc/SConscript.nacl',
477 'tests/srpc_hw/SConscript.nacl',
478 'tests/syscalls/SConscript.nacl',
479 'tests/threads/SConscript.nacl',
480 'tests/tone/SConscript.nacl',
481 'tests/voronoi/SConscript.nacl',
483 'tools/stubs/SConscript.nacl',
484 'tools/libnacl/SConscript.nacl',
485 'tools/libsrpc/SConscript.nacl',
486 'tools/nc_threads/SConscript.nacl',
487 'tools/libav/SConscript.nacl',
488 'tools/libunimpl/SConscript.nacl',
489 'tools/npapi_runtime/SConscript.nacl',
490 #### ALPHABETICALLY SORTED ####
494 # Uncomment this if you want the nacl stuff to be build by default.
495 #nacl_env.Append(BUILD_GROUPS = ['default'])
496 environment_list
.append(nacl_env
)
498 # ----------------------------------------------------------
500 # ----------------------------------------------------------
501 # ----------------------------------------------------------
503 # ----------------------------------------------------------
505 doc_env
= pre_base_env
.Clone(
507 BUILD_TYPE_DESCRIPTION
= 'Documentation build',
508 HOST_PLATFORMS
= '*',
510 doc_env
.FilterOut(BUILD_GROUPS
=['most'])
511 environment_list
.append(doc_env
)
513 BUILD_SCONSCRIPTS
= [
519 # ----------------------------------------------------------
521 # Blank out defaults.
524 BuildComponents(environment_list
)
526 # Change default to build everything, but not run tests.
527 Default(['all_programs', 'all_bundles', 'all_test_programs', 'all_libraries'])
529 # ----------------------------------------------------------
532 # Generate a solution, defer to the end.
533 solution_env
= base_env
.Clone(tools
= ['visual_studio_solution'])
534 solution
= solution_env
.Solution(
535 'nacl', environment_list
,
536 exclude_pattern
= '.*third_party.*',
537 extra_build_targets
= {
538 'Firefox': 'c:/Program Files/Mozilla FireFox/firefox.exe',
541 solution_env
.Alias('solution', solution
)