import pynacl.platform
-# NOTE: Underlay for src/third_party_mod/gtest
-# TODO: try to eliminate this hack
-Dir('src/third_party_mod/gtest').addRepository(
- Dir('#/../testing/gtest'))
-
# turning garbage collection off reduces startup time by 10%
import gc
gc.disable()
'force_sel_ldr',
# force irt image used by tests
'force_irt',
+ # generate_ninja=FILE enables a Ninja backend for SCons. This writes a
+ # .ninja build file to FILE describing all of SCons' build targets.
+ 'generate_ninja',
# Path to a JSON file for machine-readable output.
'json_build_results_output_file',
# Replacement memcheck command for overriding the DEPS-in memcheck
# colon-separated list of pnacl bcld flags, e.g. "-lfoo:-Wl,-u,bar".
# Not using nacl_linkflags since that gets clobbered in some tests.
'pnacl_bcldflags',
- 'naclsdk_mode',
- 'pnaclsdk_mode',
'platform',
# Run tests under this tool (e.g. valgrind, tsan, strace, etc).
# If the tool has options, pass them after comma: 'tool,--opt1,--opt2'.
'bindir',
# Where a Breakpad build output directory is for optional Breakpad testing.
'breakpad_tools_dir',
- # Allows overriding the toolchain to use. The default toolchain will be
- # a combination of the other arguments. Example toolchains:
- # NaCl (newlib): nacl_PLATFORM_newlib
- # NaCl (glibc): nacl_PLATFORM_glibc
- # pnacl: pnacl_PLATFORM
- 'toolchain',
+ # Allows overriding of the nacl newlib toolchain directory.
+ 'nacl_newlib_dir',
+ # Allows override of the nacl glibc toolchain directory.
+ 'nacl_glibc_dir',
+ # Allows override of the pnacl newlib toolchain directory.
+ 'pnacl_newlib_dir',
# Allows overriding the version number in the toolchain's
# FEATURE_VERSION file. This is used for PNaCl ABI compatibility
# testing.
BitFromArgument(env, 'pnacl_unsandboxed', default=False,
desc='Translate pexe to an unsandboxed, host executable')
+ BitFromArgument(env, 'nonsfi_nacl', default=False,
+ desc='Use Non-SFI Mode instead of the original SFI Mode. This uses '
+ 'nonsfi_loader instead of sel_ldr, and it tells the PNaCl toolchain '
+ 'to translate pexes to Non-SFI nexes.')
+
BitFromArgument(env, 'browser_headless', default=False,
desc='Where possible, set up a dummy display to run the browser on '
'when running browser tests. On Linux, this runs the browser through '
'to run the specified test(s) without actually running them. This '
'argument is a counterpart to built_elsewhere.')
+ BitFromArgument(env, 'no_gdb_tests', default=False,
+ desc='Prevents GDB tests from running. If GDB is not available, you can '
+ 'test everything else by specifying this flag.')
+
BitFromArgument(env, 'validator_ragel', default=True,
desc='Use the R-DFA validator instead of the original validators.')
raise UserError("pnacl_generate_pexe and use_sandboxed_translator"
" don't make sense without bitcode")
- # Sandboxed translator only accepts stable bitcode. Hence we must disallow
- # nonstable bitcodes.
- if env.Bit('use_sandboxed_translator'):
- env.SetBits('skip_nonstable_bitcode')
-
def CheckArguments():
for key in ARGUMENTS:
if key not in ACCEPTABLE_ARGUMENTS:
)
+if 'generate_ninja' in ARGUMENTS:
+ import pynacl.scons_to_ninja
+ pynacl.scons_to_ninja.GenerateNinjaFile(
+ pre_base_env, dest_file=ARGUMENTS['generate_ninja'])
+
+
breakpad_tools_dir = ARGUMENTS.get('breakpad_tools_dir')
if breakpad_tools_dir is not None:
pre_base_env['BREAKPAD_TOOLS_DIR'] = pre_base_env.Dir(
pre_base_env.AddMethod(EnsureRequiredBuildWarnings)
# Expose MakeTempDir and MakeTempFile to scons scripts
+def MakeEmptyFile(env, **kwargs):
+ fd, path = test_lib.MakeTempFile(env, **kwargs)
+ os.close(fd)
+ return path
+
pre_base_env.AddMethod(test_lib.MakeTempDir)
-pre_base_env.AddMethod(test_lib.MakeTempFile)
+pre_base_env.AddMethod(MakeEmptyFile)
# Method to add target suffix to name.
def NaClTargetArchSuffix(env, name):
pre_base_env.AddMethod(GetPlatformBuildTargetDir)
-def GetToolchainName(env, target_arch=None, is_pnacl=None, lib_name=None):
- toolchain = ARGUMENTS.get('toolchain', None)
- if toolchain is None:
+def GetToolchainDir(env, platform_build_dir=None, toolchain_name=None,
+ target_arch=None, is_pnacl=None, lib_name=None):
+ if platform_build_dir is None:
+ platform_build_dir = env.GetPlatformBuildTargetDir()
+
+ if toolchain_name is None:
+ # Fill in default arguments based on environment.
if is_pnacl is None:
is_pnacl = env.Bit('bitcode')
- if lib_name is None:
- if is_pnacl or not env.Bit('nacl_glibc'):
- lib_name = 'newlib'
- else:
- lib_name = 'glibc'
+ if lib_name is None:
+ if is_pnacl or not env.Bit('nacl_glibc'):
+ lib_name = 'newlib'
+ else:
+ lib_name = 'glibc'
- build_arch = pynacl.platform.GetArch(GetBuildPlatform())
if target_arch is None:
target_arch = pynacl.platform.GetArch(GetTargetPlatform())
else:
target_env = 'nacl_%s' % target_arch
- toolchain = '%s_%s' % (target_env, lib_name)
-
- return toolchain
-
-pre_base_env.AddMethod(GetToolchainName)
+ # See if we have a custom toolchain directory set.
+ if is_pnacl:
+ toolchain_arg = 'pnacl_%s_dir' % lib_name
+ else:
+ toolchain_arg = 'nacl_%s_dir' % lib_name
+ custom_toolchain_dir = ARGUMENTS.get(toolchain_arg, None)
+ if custom_toolchain_dir:
+ return env.SConstructAbsPath(custom_toolchain_dir)
-def GetToolchainDir(env, platform_build_dir=None, toolchain_name=None):
- if platform_build_dir is None:
- platform_build_dir = env.GetPlatformBuildTargetDir()
- if toolchain_name is None:
- toolchain_name = env.GetToolchainName()
+ # Get the standard toolchain name since no directory custom was found.
+ if is_pnacl:
+ target_env = 'pnacl'
+ else:
+ target_env = 'nacl_%s' % target_arch
+ toolchain_name = '%s_%s' % (target_env, lib_name)
- toolchain_sub_dir = os.path.join(
- 'toolchain',
- platform_build_dir,
- toolchain_name
- )
+ # Get the absolute path for the platform build directory and toolchain.
+ toolchain_sub_dir = os.path.join('toolchain',
+ platform_build_dir,
+ toolchain_name)
return env.SConstructAbsPath(toolchain_sub_dir)
pre_base_env.AddMethod(GetToolchainDir)
pre_base_env.AddMethod(AddBootstrap)
+def GetNonSfiLoader(env):
+ if 'TRUSTED_ENV' not in env:
+ return None
+ return env['TRUSTED_ENV'].File(
+ '${STAGING_DIR}/${PROGPREFIX}nonsfi_loader${PROGSUFFIX}')
+
+pre_base_env.AddMethod(GetNonSfiLoader)
+
+
def GetIrtNexe(env, chrome_irt=False):
image = ARGUMENTS.get('force_irt')
if image:
assert len(node) == 1, node
return node[0]
+pre_base_env.AddMethod(GetFinalizedPexe)
+
# Translate the given pexe.
def GetTranslatedNexe(env, pexe):
return env.CommandTest(name, command, size, **extra)
if loader is None:
- loader = env.GetSelLdr()
+ if env.Bit('nonsfi_nacl'):
+ loader = env.GetNonSfiLoader()
+ else:
+ loader = env.GetSelLdr()
if loader is None:
print 'WARNING: no sel_ldr found. Skipping test %s' % name
return []
else:
loader_cmd = env.AddBootstrap(loader, [])
- command = loader_cmd + sel_ldr_flags + ['--'] + command
+ if env.Bit('nonsfi_nacl'):
+ # nonsfi_loader does not accept the same flags as sel_ldr yet, so
+ # we ignore sel_ldr_flags here.
+ command = [loader] + command
+ else:
+ command = loader_cmd + sel_ldr_flags + ['--'] + command
if env.Bit('host_linux'):
extra['using_nacl_signal_handler'] = True
# The SCons default (copied from print_cmd_line in Action.py)
sys.stdout.write(cmd + u'\n')
-pre_base_env.Append(PRINT_CMD_LINE_FUNC=CustomCommandPrinter)
+if 'generate_ninja' not in ARGUMENTS:
+ pre_base_env.Append(PRINT_CMD_LINE_FUNC=CustomCommandPrinter)
def GetAbsDirArg(env, argument, target):
# KEEP THIS SORTED PLEASE
'build/package_version/build.scons',
'pynacl/build.scons',
+ 'src/nonsfi/irt/build.scons',
+ 'src/nonsfi/loader/build.scons',
'src/shared/gio/build.scons',
'src/shared/imc/build.scons',
'src/shared/ldr/build.scons',
Options:
--------
-naclsdk_mode=<mode> where <mode>:
-
- 'local': use locally installed sdk kit
- 'download': use the download copy (default)
- 'custom:<path>': use kit at <path>
- 'manual': use settings from env vars NACL_SDK_xxx
-
-pnaclsdk_mode=<mode> where <mode:
- 'default': use the default (typically the downloaded copy)
- 'custom:<path>': use kit from <path>
-
--prebuilt Do not build things, just do install steps
--verbose Full command line logging before command execution
if not ndk or not sdk:
print 'Please define ANDROID_NDK_ROOT and ANDROID_SDK_ROOT'
sys.exit(-1)
- tc = '%s/toolchains/%s-%s/prebuilt/linux-x86_64/bin/' \
- % (ndk, ndk_tctarget, ndk_version)
+ ndk_platform_path_map = {
+ pynacl.platform.OS_WIN : 'win',
+ pynacl.platform.OS_MAC: 'darwin',
+ pynacl.platform.OS_LINUX : 'linux'
+ }
+ ndk_platform_path = ndk_platform_path_map[pynacl.platform.GetOS()]
+ tc = '%s/toolchains/%s-%s/prebuilt/%s-x86_64/bin/' % (
+ ndk, ndk_tctarget, ndk_version, ndk_platform_path)
tc_prefix = '%s/%s-' % (tc, ndk_target)
platform_prefix = '%s/platforms/android-14/arch-%s' % (ndk, arch)
stl_path = '%s/sources/cxx-stl/gnu-libstdc++/%s' % (ndk, ndk_version)
env.Replace(CC=tc_prefix + 'gcc',
CXX=tc_prefix + 'g++',
LD=tc_prefix + 'g++',
+ AR=tc_prefix + 'ar',
+ RANLIB=tc_prefix + 'ranlib',
EMULATOR=sdk + '/tools/emulator',
LIBPATH=['${LIB_DIR}',
'%s/libs/%s' % (stl_path, libarch),
env.Append(LIBS=['rt', 'dl', 'pthread'],
CCFLAGS=['-march=mips32r2'])
-
-def MakeLinuxEnv(platform=None):
+# Makes a generic Linux development environment.
+# Linux development environments are used in two different ways.
+# 1) To produce trusted tools (e.g., sel_ldr), called TRUSTED_ENV
+# 2) To produce build tools (e.g., tls_edit), called BUILD_ENV
+def MakeGenericLinuxEnv(platform=None):
linux_env = MakeUnixLikeEnv(platform).Clone(
BUILD_TYPE = '${OPTIMIZATION_LEVEL}-linux',
BUILD_TYPE_DESCRIPTION = 'Linux ${OPTIMIZATION_LEVEL} build',
# code-generation flags affect the predefines we might test there.
linux_env.Replace(ASFLAGS=['${CCFLAGS}'])
+ return linux_env
+
+# Specializes a generic Linux development environment to be a trusted
+# environment.
+def MakeTrustedLinuxEnv(platform=None):
+ linux_env = MakeGenericLinuxEnv(platform)
if linux_env.Bit('android'):
SetUpAndroidEnv(linux_env)
-
return linux_env
(linux_debug_env, linux_optimized_env) = \
- GenerateOptimizationLevels(MakeLinuxEnv())
+ GenerateOptimizationLevels(MakeTrustedLinuxEnv())
# Do this before the site_scons/site_tools/naclsdk.py stuff to pass it along.
pre_base_env.Append(
nacl_env.AddMethod(UnderWindowsCoverage)
-def AllowNonStableBitcode(env):
+def AllowNonStableBitcode(env, allow_sb_translator=False):
""" This modifies the environment to allow features that aren't part
of PNaCl's stable ABI. If tests using these features should be
skipped entirely, this returns False. Otherwise, on success, it
returns True.
"""
- if env.Bit('bitcode'):
- env.SetBits('nonstable_bitcode')
- return not env.Bit('skip_nonstable_bitcode')
+ if env.Bit('bitcode') and env.Bit('skip_nonstable_bitcode'):
+ return False
+ # The PNaCl sandboxed translator (for the most part) only accepts stable
+ # bitcode, so in most cases we skip building non-stable tests.
+ # However, there are some limited cases like debug information which
+ # we support but do not guarantee stability. Tests targeting such cases
+ # can opt-in to testing w/ allow_sb_translator=True.
+ if env.Bit('use_sandboxed_translator') and not allow_sb_translator:
+ return False
+ # Change environment to skip finalization step.
+ env.SetBits('nonstable_bitcode')
+ return True
nacl_env.AddMethod(AllowNonStableBitcode)
('use_sandboxed_translator', 'sbtc'),
('nacl_glibc', 'glibc'),
('pnacl_generate_pexe', 'pexe'),
+ ('nonsfi_nacl', 'nonsfi'),
]
for variant_bit, variant_suffix in target_variant_map:
if nacl_env.Bit(variant_bit):
'src/trusted/validator/nacl.scons',
'src/trusted/weak_ref/nacl.scons',
'src/untrusted/crash_dump/nacl.scons',
+ 'src/untrusted/irt/nacl_headers.scons',
'src/untrusted/minidump_generator/nacl.scons',
'src/untrusted/nacl/nacl.scons',
'src/untrusted/valgrind/nacl.scons',
'tests/glibc_socket_wrappers/nacl.scons',
'tests/hello_world/nacl.scons',
'tests/imc_shm_mmap/nacl.scons',
+ 'tests/includability/nacl.scons',
'tests/infoleak/nacl.scons',
'tests/libc/nacl.scons',
'tests/libc_free_hello_world/nacl.scons',
'tests/longjmp/nacl.scons',
'tests/loop/nacl.scons',
'tests/mandel/nacl.scons',
- 'tests/manifest_file/nacl.scons',
'tests/math/nacl.scons',
'tests/memcheck_test/nacl.scons',
'tests/mmap/nacl.scons',
'tests/process_create/nacl.scons',
'tests/redir/nacl.scons',
'tests/rodata_not_writable/nacl.scons',
+ 'tests/run_py/nacl.scons',
'tests/sel_ldr/nacl.scons',
'tests/sel_ldr_seccomp/nacl.scons',
'tests/sel_main_chrome/nacl.scons',
'tests/chrome_extension/nacl.scons',
'tests/custom_desc/nacl.scons',
'tests/faulted_thread_queue/nacl.scons',
+ 'tests/gold_plugin/nacl.scons',
'tests/imc_sockets/nacl.scons',
'tests/minnacl/nacl.scons',
'tests/multiple_sandboxes/nacl.scons',
platform_func_map = {
'win32' : MakeWindowsEnv,
'cygwin': MakeWindowsEnv,
- 'linux' : MakeLinuxEnv,
- 'linux2': MakeLinuxEnv,
+ 'linux' : MakeGenericLinuxEnv,
+ 'linux2': MakeGenericLinuxEnv,
'darwin': MakeMacEnv,
}
if sys.platform not in platform_func_map: