Skip to content
Snippets Groups Projects
Commit 09e520c6 authored by Mike Hommey's avatar Mike Hommey
Browse files

Bug 1307355 - Add an implicit dependency on --enable-compile-environment to...

Bug 1307355 - Add an implicit dependency on --enable-compile-environment to pkg_check_modules. r=chmanchester

--HG--
extra : rebase_source : bd16320895f54d42c8207722a4a4c366d1332170
parent a12afd68
No related branches found
No related tags found
No related merge requests found
......@@ -803,11 +803,6 @@ def js_option(*args, **kwargs):
add_old_configure_arg(js_option)
include('pkg.configure')
# Make this assignment here rather than in pkg.configure to avoid
# requiring this file in unit tests.
add_old_configure_assignment('PKG_CONFIG', pkg_config)
# Bug 1278542: This function is a workaround to resolve
# |android_ndk_include|'s dependency on 'gonkdir.' The
# actual implementation is located in b2g/moz.configure.
......
......@@ -4,7 +4,12 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
pkg_config = check_prog('PKG_CONFIG', ('pkg-config',), allow_missing=True)
@depends('--enable-compile-environment')
def pkg_config(compile_env):
if compile_env:
return ('pkg-config',)
pkg_config = check_prog('PKG_CONFIG', pkg_config, allow_missing=True)
@depends_if(pkg_config)
@checking('for pkg-config version')
......@@ -31,7 +36,12 @@ def pkg_check_modules(var, package_desc, when=always,
package_desc = ' '.join(package_desc)
package_desc = dependable(package_desc)
@depends_when(pkg_config, pkg_config_version, when=when)
@depends(when, '--enable-compile-environment')
def when_and_compile_environment(when, compile_environment):
return when and compile_environment
@depends_when(pkg_config, pkg_config_version,
when=when_and_compile_environment)
def check_pkg_config(pkg_config, version):
min_version = '0.9.0'
if pkg_config is None:
......@@ -42,7 +52,7 @@ def pkg_check_modules(var, package_desc, when=always,
die("*** Your version of pkg-config is too old. You need version %s or newer.",
min_version)
@depends_when(pkg_config, package_desc, when=when)
@depends_when(pkg_config, package_desc, when=when_and_compile_environment)
@imports('subprocess')
@imports('sys')
@imports(_from='mozbuild.configure.util', _import='LineIO')
......
......@@ -93,6 +93,11 @@ js_option('--enable-debug',
add_old_configure_assignment('MOZ_DEBUG',
depends('--enable-debug')(lambda v: bool(v)))
include('build/moz.configure/pkg.configure')
# Make this assignment here rather than in pkg.configure to avoid
# requiring this file in unit tests.
add_old_configure_assignment('PKG_CONFIG', pkg_config)
include_when('build/moz.configure/toolchain.configure',
when='--enable-compile-environment')
include_when('build/moz.configure/memory.configure',
......
......@@ -701,13 +701,21 @@ class TestChecksConfigure(unittest.TestCase):
return 0, mock_pkg_config_version, ''
self.fail("Unexpected arguments to mock_pkg_config: %s" % args)
def get_result(cmd, args=[], extra_paths=None):
return self.get_result(textwrap.dedent('''\
option('--disable-compile-environment', help='compile env')
include('%(topsrcdir)s/build/moz.configure/util.configure')
include('%(topsrcdir)s/build/moz.configure/checks.configure')
include('%(topsrcdir)s/build/moz.configure/pkg.configure')
''' % {'topsrcdir': topsrcdir}) + cmd, args=args, extra_paths=extra_paths,
includes=())
extra_paths = {
mock_pkg_config_path: mock_pkg_config,
}
includes = ('util.configure', 'checks.configure', 'pkg.configure')
config, output, status = self.get_result("pkg_check_modules('MOZ_VALID', 'valid')",
includes=includes)
config, output, status = get_result("pkg_check_modules('MOZ_VALID', 'valid')")
self.assertEqual(status, 1)
self.assertEqual(output, textwrap.dedent('''\
checking for pkg_config... not found
......@@ -717,9 +725,8 @@ class TestChecksConfigure(unittest.TestCase):
'''))
config, output, status = self.get_result("pkg_check_modules('MOZ_VALID', 'valid')",
extra_paths=extra_paths,
includes=includes)
config, output, status = get_result("pkg_check_modules('MOZ_VALID', 'valid')",
extra_paths=extra_paths)
self.assertEqual(status, 0)
self.assertEqual(output, textwrap.dedent('''\
checking for pkg_config... %s
......@@ -734,9 +741,8 @@ class TestChecksConfigure(unittest.TestCase):
'MOZ_VALID_LIBS': ('-lvalid',),
})
config, output, status = self.get_result("pkg_check_modules('MOZ_UKNOWN', 'unknown')",
extra_paths=extra_paths,
includes=includes)
config, output, status = get_result("pkg_check_modules('MOZ_UKNOWN', 'unknown')",
extra_paths=extra_paths)
self.assertEqual(status, 1)
self.assertEqual(output, textwrap.dedent('''\
checking for pkg_config... %s
......@@ -751,9 +757,8 @@ class TestChecksConfigure(unittest.TestCase):
'PKG_CONFIG': mock_pkg_config_path,
})
config, output, status = self.get_result("pkg_check_modules('MOZ_NEW', 'new > 1.1')",
extra_paths=extra_paths,
includes=includes)
config, output, status = get_result("pkg_check_modules('MOZ_NEW', 'new > 1.1')",
extra_paths=extra_paths)
self.assertEqual(status, 1)
self.assertEqual(output, textwrap.dedent('''\
checking for pkg_config... %s
......@@ -774,9 +779,7 @@ class TestChecksConfigure(unittest.TestCase):
log.info('Module not found.')
''')
config, output, status = self.get_result(cmd,
extra_paths=extra_paths,
includes=includes)
config, output, status = get_result(cmd, extra_paths=extra_paths)
self.assertEqual(status, 0)
self.assertEqual(output, textwrap.dedent('''\
checking for pkg_config... %s
......@@ -789,6 +792,13 @@ class TestChecksConfigure(unittest.TestCase):
'PKG_CONFIG': mock_pkg_config_path,
})
config, output, status = get_result(cmd,
args=['--disable-compile-environment'],
extra_paths=extra_paths)
self.assertEqual(status, 0)
self.assertEqual(output, 'Module not found.\n')
self.assertEqual(config, {})
def mock_old_pkg_config(_, args):
if args[0] == '--version':
return 0, '0.8.10', ''
......@@ -798,9 +808,8 @@ class TestChecksConfigure(unittest.TestCase):
mock_pkg_config_path: mock_old_pkg_config,
}
config, output, status = self.get_result("pkg_check_modules('MOZ_VALID', 'valid')",
extra_paths=extra_paths,
includes=includes)
config, output, status = get_result("pkg_check_modules('MOZ_VALID', 'valid')",
extra_paths=extra_paths)
self.assertEqual(status, 1)
self.assertEqual(output, textwrap.dedent('''\
checking for pkg_config... %s
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment