Skip to content

Commit

Permalink
Bug 1307355 - Add an implicit dependency on --enable-compile-environm…
Browse files Browse the repository at this point in the history
…ent to pkg_check_modules. r=chmanchester

--HG--
extra : rebase_source : bd16320895f54d42c8207722a4a4c366d1332170
  • Loading branch information
glandium committed Oct 4, 2016
1 parent a12afd6 commit 09e520c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 25 deletions.
5 changes: 0 additions & 5 deletions build/moz.configure/init.configure
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 13 additions & 3 deletions build/moz.configure/pkg.configure
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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:
Expand All @@ -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')
Expand Down
5 changes: 5 additions & 0 deletions moz.configure
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
43 changes: 26 additions & 17 deletions python/mozbuild/mozbuild/test/configure/test_checks_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,13 +701,21 @@ def mock_pkg_config(_, args):
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
Expand All @@ -717,9 +725,8 @@ def mock_pkg_config(_, args):
'''))


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
Expand All @@ -734,9 +741,8 @@ def mock_pkg_config(_, args):
'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
Expand All @@ -751,9 +757,8 @@ def mock_pkg_config(_, args):
'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
Expand All @@ -774,9 +779,7 @@ def log_new_module_error(mod):
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
Expand All @@ -789,6 +792,13 @@ def log_new_module_error(mod):
'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', ''
Expand All @@ -798,9 +808,8 @@ def mock_old_pkg_config(_, args):
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
Expand Down

0 comments on commit 09e520c

Please sign in to comment.