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

Unified Diff: native_client_sdk/src/tools/create_nmf.py

Issue 890033003: Revert of [NaCl SDK] Remove create_nmf dependency on NACL_SDK_ROOT env var (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 | « no previous file | native_client_sdk/src/tools/tests/create_nmf_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/tools/create_nmf.py
diff --git a/native_client_sdk/src/tools/create_nmf.py b/native_client_sdk/src/tools/create_nmf.py
index dc7e552a615cfac4705d00180f69bfa658fa01e2..de72408c4df141bbcac49f8255d724aa5f18beae 100755
--- a/native_client_sdk/src/tools/create_nmf.py
+++ b/native_client_sdk/src/tools/create_nmf.py
@@ -466,16 +466,15 @@
def GetSDKRoot():
- """Returns the root directory of the NaCl SDK.
- """
- # This script should be installed in NACL_SDK_ROOT/tools. Assert that
- # the 'toolchain' folder exists within this directory in case, for
- # example, this script is moved to a different location.
- # During the Chrome build this script is sometimes run outside of
- # of an SDK but in these cases it should always be run with --objdump=
- # and --no-default-libpath which avoids the need to call this function.
- sdk_root = os.path.dirname(SCRIPT_DIR)
- assert(os.path.exists(os.path.join(sdk_root, 'toolchain')))
+ """Determine current NACL_SDK_ROOT, either via the environment variable
+ itself, or by attempting to derive it from the location of this script.
+ """
+ sdk_root = os.environ.get('NACL_SDK_ROOT')
+ if not sdk_root:
+ sdk_root = os.path.dirname(SCRIPT_DIR)
+ if not os.path.exists(os.path.join(sdk_root, 'toolchain')):
+ return None
+
return sdk_root
@@ -483,8 +482,12 @@
"""Derive path to objdump executable to use for determining shared
object dependencies.
"""
+ sdk_root = GetSDKRoot()
+ if not sdk_root:
+ return None
+
osname = getos.GetPlatform()
- toolchain = os.path.join(GetSDKRoot(), 'toolchain', '%s_x86_glibc' % osname)
+ toolchain = os.path.join(sdk_root, 'toolchain', '%s_x86_glibc' % osname)
objdump = os.path.join(toolchain, 'bin', 'x86_64-nacl-objdump')
if osname == 'win':
objdump += '.exe'
@@ -505,6 +508,10 @@
"""
assert(config in ('Debug', 'Release'))
sdk_root = GetSDKRoot()
+ if not sdk_root:
+ # TOOD(sbc): output a warning here? We would also need to suppress
+ # the warning when run from the chromium build.
+ return []
osname = getos.GetPlatform()
libpath = [
@@ -573,8 +580,8 @@
help='Rename FOO as BAR',
action='append', default=[], metavar='FOO,BAR')
parser.add_argument('-x', '--extra-files',
- help='Add extra key:file tuple to the "files"'
- ' section of the .nmf',
+ help=('Add extra key:file tuple to the "files"' +
+ ' section of the .nmf'),
action='append', default=[], metavar='FILE')
parser.add_argument('-O', '--pnacl-optlevel',
help='Set the optimization level to N in PNaCl manifests',
@@ -662,7 +669,7 @@
pnacl_debug_optlevel=pnacl_debug_optlevel,
nmf_root=nmf_root)
- if options.output is None:
+ if not options.output:
sys.stdout.write(nmf.GetJson())
else:
with open(options.output, 'w') as output:
« no previous file with comments | « no previous file | native_client_sdk/src/tools/tests/create_nmf_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698