Bug 1302704 - part 6 - enforce identical profiles for gkrust and gkrust-gtest; r=chmanchester

Cargo hashes various compilation settings into the dependency graph for
dependent libraries.  So if the compilation settings for gkrust and
gkrust-gtest are different, their dependencies will likewise be
different.  The setup we've created in the previous patches depends on
the compilation settings being identical, so we should enforce that at
the moz.build level.
This commit is contained in:
Nathan Froyd
2017-02-23 10:35:06 -05:00
parent 77f7b6de8b
commit 1a557cbccb
6 changed files with 36 additions and 8 deletions

View File

@@ -465,6 +465,34 @@ class TreeMetadataEmitter(LoggingMixin):
' in [profile.%s] section') % (libname, profile_name),
context)
# gkrust and gkrust-gtest must have the exact same profile settings
# for our almost-workspaces configuration to work properly.
if libname in ('gkrust', 'gkrust-gtest'):
if profile_name == 'dev':
expected_profile = {
'opt-level': 1,
'debug': True,
'rpath': False,
'lto': False,
'debug-assertions': True,
'codegen-units': 1,
'panic': 'abort',
}
else:
expected_profile = {
'opt-level': 2,
'debug': True,
'rpath': False,
'lto': True,
'debug-assertions': False,
'panic': 'abort',
}
if profile != expected_profile:
raise SandboxValidationError(
'Cargo profile.%s for %s is incorrect' % (profile_name, libname),
context)
cargo_target_dir = context.get('RUST_LIBRARY_TARGET_DIR', '.')
dependencies = set(config.get('dependencies', {}).iterkeys())

View File

@@ -1,5 +1,5 @@
[package]
name = "gkrust"
name = "feature-library"
version = "0.1.0"
authors = [
"Nobody <nobody@mozilla.org>",

View File

@@ -16,4 +16,4 @@ def RustLibrary(name, features):
RUST_LIBRARY_FEATURES = features
RustLibrary('gkrust', ['musthave', 'cantlivewithout'])
RustLibrary('feature-library', ['musthave', 'cantlivewithout'])

View File

@@ -1,5 +1,5 @@
[package]
name = "gkrust"
name = "test-library"
version = "0.1.0"
authors = [
"Nobody <nobody@mozilla.org>",

View File

@@ -15,4 +15,4 @@ def RustLibrary(name):
IS_RUST_LIBRARY = True
RustLibrary('gkrust')
RustLibrary('test-library')

View File

@@ -762,7 +762,7 @@ class TestRecursiveMakeBackend(BackendTester):
lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]
expected = [
'RUST_LIBRARY_FILE := x86_64-unknown-linux-gnu/release/libgkrust.a',
'RUST_LIBRARY_FILE := ./x86_64-unknown-linux-gnu/release/libtest_library.a',
'CARGO_FILE := $(srcdir)/Cargo.toml',
'CARGO_TARGET_DIR := %s' % env.topobjdir,
]
@@ -777,7 +777,7 @@ class TestRecursiveMakeBackend(BackendTester):
lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]
expected = [
'HOST_RUST_LIBRARY_FILE := x86_64-unknown-linux-gnu/release/libhostrusttool.a',
'HOST_RUST_LIBRARY_FILE := ./x86_64-unknown-linux-gnu/release/libhostrusttool.a',
'CARGO_FILE := $(srcdir)/Cargo.toml',
'CARGO_TARGET_DIR := %s' % env.topobjdir,
]
@@ -792,7 +792,7 @@ class TestRecursiveMakeBackend(BackendTester):
lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]
expected = [
'HOST_RUST_LIBRARY_FILE := x86_64-unknown-linux-gnu/release/libhostrusttool.a',
'HOST_RUST_LIBRARY_FILE := ./x86_64-unknown-linux-gnu/release/libhostrusttool.a',
'CARGO_FILE := $(srcdir)/Cargo.toml',
'CARGO_TARGET_DIR := %s' % env.topobjdir,
'HOST_RUST_LIBRARY_FEATURES := musthave cantlivewithout',
@@ -808,7 +808,7 @@ class TestRecursiveMakeBackend(BackendTester):
lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]
expected = [
'RUST_LIBRARY_FILE := x86_64-unknown-linux-gnu/release/libgkrust.a',
'RUST_LIBRARY_FILE := ./x86_64-unknown-linux-gnu/release/libfeature_library.a',
'CARGO_FILE := $(srcdir)/Cargo.toml',
'CARGO_TARGET_DIR := %s' % env.topobjdir,
'RUST_LIBRARY_FEATURES := musthave cantlivewithout',