mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1319156 - part 1 - add features to RustLibrary objects and moz.build definitions; r=chmanchester
Ideally, people will just use the extra argument to RustLibrary to define features for their library.
This commit is contained in:
parent
8783deedb3
commit
d861eee0f6
@ -61,11 +61,15 @@ def Library(name):
|
||||
|
||||
|
||||
@template
|
||||
def RustLibrary(name):
|
||||
def RustLibrary(name, features=None):
|
||||
'''Template for Rust libraries.'''
|
||||
Library(name)
|
||||
|
||||
if not features:
|
||||
features = []
|
||||
|
||||
IS_RUST_LIBRARY = True
|
||||
RUST_LIBRARY_FEATURES = features
|
||||
|
||||
|
||||
@template
|
||||
|
@ -952,6 +952,13 @@ VARIABLES = {
|
||||
a Cargo.toml file that exists in this moz.build's directory.
|
||||
"""),
|
||||
|
||||
'RUST_LIBRARY_FEATURES': (List, list,
|
||||
"""Cargo features to activate for this library.
|
||||
|
||||
This variable should not be used directly; you should be using the
|
||||
RustLibrary template instead.
|
||||
"""),
|
||||
|
||||
'UNIFIED_SOURCES': (ContextDerivedTypedList(SourcePath, StrictOrderingOnAppendList), list,
|
||||
"""Source code files that can be compiled together.
|
||||
|
||||
|
@ -526,9 +526,11 @@ class RustLibrary(StaticLibrary):
|
||||
'crate_type',
|
||||
'dependencies',
|
||||
'deps_path',
|
||||
'features',
|
||||
)
|
||||
|
||||
def __init__(self, context, basename, cargo_file, crate_type, dependencies, **args):
|
||||
def __init__(self, context, basename, cargo_file, crate_type, dependencies,
|
||||
features, **args):
|
||||
StaticLibrary.__init__(self, context, basename, **args)
|
||||
self.cargo_file = cargo_file
|
||||
self.crate_type = crate_type
|
||||
@ -544,6 +546,7 @@ class RustLibrary(StaticLibrary):
|
||||
build_dir = cargo_target_directory(context)
|
||||
self.import_name = mozpath.join(build_dir, self.lib_name)
|
||||
self.deps_path = mozpath.join(build_dir, 'deps')
|
||||
self.features = features
|
||||
|
||||
|
||||
class SharedLibrary(Library):
|
||||
|
@ -513,8 +513,15 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
|
||||
dependencies = set(config.get('dependencies', {}).iterkeys())
|
||||
|
||||
features = context.get('RUST_LIBRARY_FEATURES', [])
|
||||
unique_features = set(features)
|
||||
if len(features) != len(unique_features):
|
||||
raise SandboxValidationError(
|
||||
'features for %s should not contain duplicates: %s' % (libname, features),
|
||||
context)
|
||||
|
||||
return RustLibrary(context, libname, cargo_file, crate_type,
|
||||
dependencies, **static_args)
|
||||
dependencies, features, **static_args)
|
||||
|
||||
def _handle_linkables(self, context, passthru, generated_files):
|
||||
linkables = []
|
||||
|
Loading…
Reference in New Issue
Block a user