Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(732)

Unified Diff: site_scons/site_tools/naclsdk.py

Issue 245733002: Added arguments to NaCl scons to allow custom toolchain directories. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Use abspath of environment instead of cwd since cwd can change per test Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pnacl/build.sh ('k') | tests/gdb/nacl.scons » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: site_scons/site_tools/naclsdk.py
diff --git a/site_scons/site_tools/naclsdk.py b/site_scons/site_tools/naclsdk.py
index 1bef2b8430d797aeec1106a7e8c3084aa52c0480..66fc09ad22d3a0d3143ba4893538709d830c5595 100755
--- a/site_scons/site_tools/naclsdk.py
+++ b/site_scons/site_tools/naclsdk.py
@@ -58,51 +58,6 @@ def _StubOutEnvToolsForBuiltElsewhere(env):
STRIP='true')
-def _GetNaClSdkRoot(env, sdk_mode, psdk_mode):
- """Return the path to the sdk.
-
- Args:
- env: The SCons environment in question.
- sdk_mode: A string indicating which location to select the tools from.
- Returns:
- The path to the sdk.
- """
-
- # Allow pnacl to override its path separately. See comments for why
- # psdk_mode is separate from sdk_mode.
- if env.Bit('bitcode') and psdk_mode.startswith('custom:'):
- return os.path.abspath(psdk_mode[len('custom:'):])
-
- if sdk_mode == 'local':
- if env['PLATFORM'] in ['win32', 'cygwin']:
- # Try to use cygpath under the assumption we are running thru cygwin.
- # If this is not the case, then 'local' doesn't really make any sense,
- # so then we should complain.
- try:
- path = subprocess.Popen(
- ['cygpath', '-m', '/usr/local/nacl-sdk'],
- shell=True,
- stdout=subprocess.PIPE).communicate()[0].replace('\n', '')
- except WindowsError:
- raise NotImplementedError(
- 'Not able to decide where /usr/local/nacl-sdk is on this platform,'
- 'use naclsdk_mode=custom:...')
- return path
- else:
- return '/usr/local/nacl-sdk'
-
- elif sdk_mode == 'download':
- return env.GetToolchainDir()
- elif sdk_mode.startswith('custom:'):
- return os.path.abspath(sdk_mode[len('custom:'):])
-
- elif sdk_mode == 'manual':
- return None
-
- else:
- raise Exception('Unknown sdk mode: %r' % sdk_mode)
-
-
def _SetEnvForNativeSdk(env, sdk_path):
"""Initialize environment according to target architecture."""
@@ -340,22 +295,6 @@ def _SetEnvForPnacl(env, root):
env.Replace(PNACLFINALIZE='true')
-def _SetEnvForSdkManually(env):
- def GetEnvOrDummy(v):
- return os.getenv('NACL_SDK_' + v, 'MISSING_SDK_' + v)
-
- env.Replace(# Replace header and lib paths.
- NACL_SDK_INCLUDE=GetEnvOrDummy('INCLUDE'),
- NACL_SDK_LIB=GetEnvOrDummy('LIB'),
- # Replace the normal unix tools with the NaCl ones.
- CC=GetEnvOrDummy('CC'),
- CXX=GetEnvOrDummy('CXX'),
- AR=GetEnvOrDummy('AR'),
- # NOTE: use g++ for linking so we can handle c AND c++
- LINK=GetEnvOrDummy('LINK'),
- RANLIB=GetEnvOrDummy('RANLIB'),
- )
-
def PNaClForceNative(env):
assert(env.Bit('bitcode'))
if env.Bit('pnacl_generate_pexe'):
@@ -651,17 +590,6 @@ def generate(env):
env.AddMethod(PNaClForceNative)
env.AddMethod(PNaClGetNNaClEnv)
- # Get configuration option for getting the naclsdk. Default is download.
- # We have a separate flag for pnacl "psdk_mode" since even with PNaCl,
- # the native nacl-gcc toolchain is used to build some parts like
- # the irt-core.
- sdk_mode = SCons.Script.ARGUMENTS.get('naclsdk_mode', 'download')
- psdk_mode = SCons.Script.ARGUMENTS.get('pnaclsdk_mode', 'default')
- if psdk_mode != 'default' and not psdk_mode.startswith('custom:'):
- raise Exception(
- 'pnaclsdk_mode only supports "default" or "custom:path", not %s' %
- psdk_mode)
-
# Invoke the various unix tools that the NativeClient SDK resembles.
env.Tool('g++')
env.Tool('gcc')
@@ -730,31 +658,27 @@ def generate(env):
env[com] = "${TEMPFILE('%s')}" % env[com]
# Get root of the SDK.
- root = _GetNaClSdkRoot(env, sdk_mode, psdk_mode)
-
- # Determine where to get the SDK from.
- if sdk_mode == 'manual':
- _SetEnvForSdkManually(env)
+ root = env.GetToolchainDir()
+
+ # if bitcode=1 use pnacl toolchain
+ if env.Bit('bitcode'):
+ _SetEnvForPnacl(env, root)
+
+ # Get GDB from the nacl-gcc toolchain even when using PNaCl.
+ # TODO(mseaborn): We really want the nacl-gdb binary to be in a
+ # separate tarball from the nacl-gcc toolchain, then this step
+ # will not be necessary.
+ # See http://code.google.com/p/nativeclient/issues/detail?id=2773
+ if env.Bit('target_x86'):
+ temp_env = env.Clone()
+ temp_env.ClearBits('bitcode')
+ temp_root = temp_env.GetToolchainDir()
+ _SetEnvForNativeSdk(temp_env, temp_root)
+ env.Replace(GDB=temp_env['GDB'])
+ elif env.Bit('built_elsewhere'):
+ _StubOutEnvToolsForBuiltElsewhere(env)
else:
- # if bitcode=1 use pnacl toolchain
- if env.Bit('bitcode'):
- _SetEnvForPnacl(env, root)
-
- # Get GDB from the nacl-gcc toolchain even when using PNaCl.
- # TODO(mseaborn): We really want the nacl-gdb binary to be in a
- # separate tarball from the nacl-gcc toolchain, then this step
- # will not be necessary.
- # See http://code.google.com/p/nativeclient/issues/detail?id=2773
- if env.Bit('target_x86'):
- temp_env = env.Clone()
- temp_env.ClearBits('bitcode')
- temp_root = _GetNaClSdkRoot(temp_env, sdk_mode, psdk_mode)
- _SetEnvForNativeSdk(temp_env, temp_root)
- env.Replace(GDB=temp_env['GDB'])
- elif env.Bit('built_elsewhere'):
- _StubOutEnvToolsForBuiltElsewhere(env)
- else:
- _SetEnvForNativeSdk(env, root)
+ _SetEnvForNativeSdk(env, root)
env.Prepend(LIBPATH='${NACL_SDK_LIB}')
« no previous file with comments | « pnacl/build.sh ('k') | tests/gdb/nacl.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698