Commit 243315bb authored by rouslan's avatar rouslan Committed by Commit bot

Revert of [NaCl SDK] Remove create_nmf dependency on NACL_SDK_ROOT env var...

Revert of [NaCl SDK] Remove create_nmf dependency on NACL_SDK_ROOT env var (patchset #5 id:80001 of https://codereview.chromium.org/737653003/)

Reason for revert:
Broke compile on Google Chrome ChromeOS bot.

[8069/19495] CXX obj/components/policy/core/common/cloud/policy_component_common.external_policy_data_updater.o
FAILED: cd ../../third_party/liblouis; python ../../native_client_sdk/src/tools/create_nmf.py ../../out/Release/chromevox_test_data/braille/liblouis_nacl_x86_64.nexe "--output=../../out/Release/chromevox_test_data/braille/liblouis_nacl.nmf"
Traceback (most recent call last):
  File "../../native_client_sdk/src/tools/create_nmf.py", line 680, in <module>
    rtn = main(sys.argv[1:])
  File "../../native_client_sdk/src/tools/create_nmf.py", line 633, in main
    options.lib_path += GetDefaultLibPath(config)
  File "../../native_client_sdk/src/tools/create_nmf.py", line 507, in GetDefaultLibPath
    sdk_root = GetSDKRoot()
  File "../../native_client_sdk/src/tools/create_nmf.py", line 478, in GetSDKRoot
    assert(os.path.exists(os.path.join(sdk_root, 'toolchain')))
AssertionError
ninja: build stopped: subcommand failed.

http://build.chromium.org/p/chromium.chrome/builders/Google%20Chrome%20ChromeOS/builds/76569

Original issue's description:
> [NaCl SDK] Remove create_nmf dependency on NACL_SDK_ROOT env var
>
> create_nmf should determine the root of the SDK relative
> to its own location.
>
> The exception to this is when its run as part of the
> chrome build, when it is not yet installed.  In this
> case we pass --no-default-libpath and --objdump to
> create_nmf to remove any use of the SDK root.
>
> Committed: https://crrev.com/088561ac99314a79866a39f79bb32bd5e1196217
> Cr-Commit-Position: refs/heads/master@{#313957}

TBR=binji@chromium.org,dmichael@chromium.org,sbc@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/890033003

Cr-Commit-Position: refs/heads/master@{#313963}
parent c3ab543b
...@@ -466,16 +466,15 @@ def ParseExtraFiles(encoded_list, err): ...@@ -466,16 +466,15 @@ def ParseExtraFiles(encoded_list, err):
def GetSDKRoot(): def GetSDKRoot():
"""Returns the root directory of the NaCl SDK. """Determine current NACL_SDK_ROOT, either via the environment variable
itself, or by attempting to derive it from the location of this script.
""" """
# This script should be installed in NACL_SDK_ROOT/tools. Assert that sdk_root = os.environ.get('NACL_SDK_ROOT')
# the 'toolchain' folder exists within this directory in case, for if not sdk_root:
# example, this script is moved to a different location. sdk_root = os.path.dirname(SCRIPT_DIR)
# During the Chrome build this script is sometimes run outside of if not os.path.exists(os.path.join(sdk_root, 'toolchain')):
# of an SDK but in these cases it should always be run with --objdump= return None
# 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')))
return sdk_root return sdk_root
...@@ -483,8 +482,12 @@ def FindObjdumpExecutable(): ...@@ -483,8 +482,12 @@ def FindObjdumpExecutable():
"""Derive path to objdump executable to use for determining shared """Derive path to objdump executable to use for determining shared
object dependencies. object dependencies.
""" """
sdk_root = GetSDKRoot()
if not sdk_root:
return None
osname = getos.GetPlatform() 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') objdump = os.path.join(toolchain, 'bin', 'x86_64-nacl-objdump')
if osname == 'win': if osname == 'win':
objdump += '.exe' objdump += '.exe'
...@@ -505,6 +508,10 @@ def GetDefaultLibPath(config): ...@@ -505,6 +508,10 @@ def GetDefaultLibPath(config):
""" """
assert(config in ('Debug', 'Release')) assert(config in ('Debug', 'Release'))
sdk_root = GetSDKRoot() 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() osname = getos.GetPlatform()
libpath = [ libpath = [
...@@ -573,8 +580,8 @@ def main(args): ...@@ -573,8 +580,8 @@ def main(args):
help='Rename FOO as BAR', help='Rename FOO as BAR',
action='append', default=[], metavar='FOO,BAR') action='append', default=[], metavar='FOO,BAR')
parser.add_argument('-x', '--extra-files', parser.add_argument('-x', '--extra-files',
help='Add extra key:file tuple to the "files"' help=('Add extra key:file tuple to the "files"' +
' section of the .nmf', ' section of the .nmf'),
action='append', default=[], metavar='FILE') action='append', default=[], metavar='FILE')
parser.add_argument('-O', '--pnacl-optlevel', parser.add_argument('-O', '--pnacl-optlevel',
help='Set the optimization level to N in PNaCl manifests', help='Set the optimization level to N in PNaCl manifests',
...@@ -662,7 +669,7 @@ def main(args): ...@@ -662,7 +669,7 @@ def main(args):
pnacl_debug_optlevel=pnacl_debug_optlevel, pnacl_debug_optlevel=pnacl_debug_optlevel,
nmf_root=nmf_root) nmf_root=nmf_root)
if options.output is None: if not options.output:
sys.stdout.write(nmf.GetJson()) sys.stdout.write(nmf.GetJson())
else: else:
with open(options.output, 'w') as output: with open(options.output, 'w') as output:
......
...@@ -14,19 +14,17 @@ import unittest ...@@ -14,19 +14,17 @@ import unittest
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
TOOLS_DIR = os.path.dirname(SCRIPT_DIR) TOOLS_DIR = os.path.dirname(SCRIPT_DIR)
DATA_DIR = os.path.join(TOOLS_DIR, 'lib', 'tests', 'data') DATA_DIR = os.path.join(TOOLS_DIR, 'lib', 'tests', 'data')
BUILD_TOOLS_DIR = os.path.join(os.path.dirname(TOOLS_DIR), 'build_tools')
CHROME_SRC = os.path.dirname(os.path.dirname(os.path.dirname(TOOLS_DIR))) CHROME_SRC = os.path.dirname(os.path.dirname(os.path.dirname(TOOLS_DIR)))
MOCK_DIR = os.path.join(CHROME_SRC, 'third_party', 'pymock') MOCK_DIR = os.path.join(CHROME_SRC, 'third_party', 'pymock')
# For the mock library # For the mock library
sys.path.append(MOCK_DIR) sys.path.append(MOCK_DIR)
sys.path.append(TOOLS_DIR) sys.path.append(TOOLS_DIR)
sys.path.append(BUILD_TOOLS_DIR)
import build_paths import build_paths
import create_nmf import create_nmf
import getos import getos
from mock import patch, Mock import mock
TOOLCHAIN_OUT = os.path.join(build_paths.OUT_DIR, 'sdk_tests', 'toolchain') TOOLCHAIN_OUT = os.path.join(build_paths.OUT_DIR, 'sdk_tests', 'toolchain')
NACL_X86_GLIBC_TOOLCHAIN = os.path.join(TOOLCHAIN_OUT, NACL_X86_GLIBC_TOOLCHAIN = os.path.join(TOOLCHAIN_OUT,
...@@ -63,18 +61,24 @@ class TestPosixRelPath(unittest.TestCase): ...@@ -63,18 +61,24 @@ class TestPosixRelPath(unittest.TestCase):
class TestDefaultLibpath(unittest.TestCase): class TestDefaultLibpath(unittest.TestCase):
def setUp(self): def testWithoutNaClSDKRoot(self):
patcher = patch('create_nmf.GetSDKRoot', Mock(return_value='/dummy/path')) """GetDefaultLibPath wihtout NACL_SDK_ROOT set
patcher.start()
self.addCleanup(patcher.stop) In the absence of NACL_SDK_ROOT GetDefaultLibPath should
return the empty list."""
def testUsesSDKRoot(self): with mock.patch.dict('os.environ', clear=True):
paths = create_nmf.GetDefaultLibPath('Debug') paths = create_nmf.GetDefaultLibPath('Debug')
self.assertEqual(paths, [])
def testHonorNaClSDKRoot(self):
with mock.patch.dict('os.environ', {'NACL_SDK_ROOT': '/dummy/path'}):
paths = create_nmf.GetDefaultLibPath('Debug')
for path in paths: for path in paths:
self.assertTrue(path.startswith('/dummy/path')) self.assertTrue(path.startswith('/dummy/path'))
def testIncludesNaClPorts(self): def testIncludesNaClPorts(self):
paths = create_nmf.GetDefaultLibPath('Debug') with mock.patch.dict('os.environ', {'NACL_SDK_ROOT': '/dummy/path'}):
paths = create_nmf.GetDefaultLibPath('Debug')
self.assertTrue(any(os.path.join('ports', 'lib') in p for p in paths), self.assertTrue(any(os.path.join('ports', 'lib') in p for p in paths),
"naclports libpath missing: %s" % str(paths)) "naclports libpath missing: %s" % str(paths))
......
...@@ -139,10 +139,6 @@ ...@@ -139,10 +139,6 @@
'--strip-all', '--strip-all',
], ],
'create_nmf': '<(DEPTH)/native_client_sdk/src/tools/create_nmf.py', 'create_nmf': '<(DEPTH)/native_client_sdk/src/tools/create_nmf.py',
'create_nmf_flags': [
'--no-default-libpath',
'--objdump=>(nacl_glibc_tc_root)/bin/x86_64-nacl-objdump',
],
'create_nonsfi_test_nmf': 'tests/create_nonsfi_test_nmf.py', 'create_nonsfi_test_nmf': 'tests/create_nonsfi_test_nmf.py',
}, },
'conditions': [ 'conditions': [
...@@ -153,6 +149,7 @@ ...@@ -153,6 +149,7 @@
# doesn't work on Windows. # doesn't work on Windows.
'libdir_glibc64': '>(nacl_glibc_tc_root)/x86_64-nacl/lib', 'libdir_glibc64': '>(nacl_glibc_tc_root)/x86_64-nacl/lib',
'libdir_glibc32': '>(nacl_glibc_tc_root)/x86_64-nacl/lib32', 'libdir_glibc32': '>(nacl_glibc_tc_root)/x86_64-nacl/lib32',
'nacl_objdump': '>(nacl_glibc_tc_root)/bin/x86_64-nacl-objdump',
'nmf_glibc%': '<(PRODUCT_DIR)/>(nexe_target)_glibc.nmf', 'nmf_glibc%': '<(PRODUCT_DIR)/>(nexe_target)_glibc.nmf',
}, },
'actions': [ 'actions': [
...@@ -168,7 +165,7 @@ ...@@ -168,7 +165,7 @@
'action': [ 'action': [
'python', 'python',
'>@(_inputs)', '>@(_inputs)',
'>@(create_nmf_flags)', '--objdump=>(nacl_objdump)',
'--output=>(nmf_glibc)', '--output=>(nmf_glibc)',
'--stage-dependencies=<(PRODUCT_DIR)', '--stage-dependencies=<(PRODUCT_DIR)',
], ],
...@@ -221,7 +218,6 @@ ...@@ -221,7 +218,6 @@
'action': [ 'action': [
'python', 'python',
'>@(_inputs)', '>@(_inputs)',
'>@(create_nmf_flags)',
'--output=>(nmf_pnacl)', '--output=>(nmf_pnacl)',
], ],
'conditions': [ 'conditions': [
...@@ -310,7 +306,6 @@ ...@@ -310,7 +306,6 @@
'action': [ 'action': [
'python', 'python',
'>@(_inputs)', '>@(_inputs)',
'>@(create_nmf_flags)',
'--output=>(nmf_pnacl)', '--output=>(nmf_pnacl)',
], ],
}, },
...@@ -334,7 +329,6 @@ ...@@ -334,7 +329,6 @@
'action': [ 'action': [
'python', 'python',
'>@(_inputs)', '>@(_inputs)',
'>@(create_nmf_flags)',
'--output=>(nmf_pnacl)', '--output=>(nmf_pnacl)',
], ],
}, },
......
...@@ -110,10 +110,6 @@ ...@@ -110,10 +110,6 @@
'create_nmf': '<(DEPTH)/native_client_sdk/src/tools/create_nmf.py', 'create_nmf': '<(DEPTH)/native_client_sdk/src/tools/create_nmf.py',
'create_nmf_args_portable%': [], 'create_nmf_args_portable%': [],
'create_nonsfi_test_nmf': '<(DEPTH)/ppapi/tests/create_nonsfi_test_nmf.py', 'create_nonsfi_test_nmf': '<(DEPTH)/ppapi/tests/create_nonsfi_test_nmf.py',
'create_nmf_args': [
'--no-default-libpath',
'--objdump=>(nacl_glibc_tc_root)/bin/x86_64-nacl-objdump',
],
}, },
'target_conditions': [ 'target_conditions': [
['generate_nmf==1 and build_newlib==1', { ['generate_nmf==1 and build_newlib==1', {
...@@ -125,7 +121,6 @@ ...@@ -125,7 +121,6 @@
'action': [ 'action': [
'python', 'python',
'>(create_nmf)', '>(create_nmf)',
'>@(create_nmf_args)',
'--output=>(nmf_newlib)', '--output=>(nmf_newlib)',
'>@(create_nmf_args_portable)', '>@(create_nmf_args_portable)',
], ],
...@@ -156,6 +151,7 @@ ...@@ -156,6 +151,7 @@
# doesn't work on Windows. # doesn't work on Windows.
'libdir_glibc64': '>(nacl_glibc_tc_root)/x86_64-nacl/lib', 'libdir_glibc64': '>(nacl_glibc_tc_root)/x86_64-nacl/lib',
'libdir_glibc32': '>(nacl_glibc_tc_root)/x86_64-nacl/lib32', 'libdir_glibc32': '>(nacl_glibc_tc_root)/x86_64-nacl/lib32',
'nacl_objdump': '>(nacl_glibc_tc_root)/bin/x86_64-nacl-objdump',
}, },
'actions': [ 'actions': [
{ {
...@@ -168,7 +164,7 @@ ...@@ -168,7 +164,7 @@
'action': [ 'action': [
'python', 'python',
'>@(_inputs)', '>@(_inputs)',
'>@(create_nmf_args)', '--objdump=>(nacl_objdump)',
'--output=>(nmf_glibc)', '--output=>(nmf_glibc)',
'--path-prefix=>(nexe_target)_libs', '--path-prefix=>(nexe_target)_libs',
'--stage-dependencies=<(nacl_glibc_out_dir)', '--stage-dependencies=<(nacl_glibc_out_dir)',
...@@ -205,7 +201,6 @@ ...@@ -205,7 +201,6 @@
'action': [ 'action': [
'python', 'python',
'>(create_nmf)', '>(create_nmf)',
'>@(create_nmf_args)',
'--output=>(nmf_pnacl_newlib)', '--output=>(nmf_pnacl_newlib)',
'>(out_pnacl_newlib)', '>(out_pnacl_newlib)',
'>@(create_nmf_args_portable)', '>@(create_nmf_args_portable)',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment