Bug 1573566 - Don't make HostRustLibrary indirectly inherit from StaticLibrary. r=froydnj

So that isinstance(foo, StaticLibrary) doesn't end up being true for
HostRustLibrary. Instead, it now inherits from HostLibrary.

Differential Revision: https://phabricator.services.mozilla.com/D42248

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Hommey 2019-08-16 14:35:36 +00:00
Родитель ac7a210250
Коммит e8b5c21263
3 изменённых файлов: 31 добавлений и 12 удалений

Просмотреть файл

@ -32,6 +32,7 @@ from mozbuild.frontend.data import (
GeneratedSources,
GnProjectData,
HostLibrary,
HostRustLibrary,
HostGeneratedSources,
IPDLCollection,
LocalizedPreprocessedFiles,
@ -276,7 +277,7 @@ class CommonBackend(BuildBackend):
system_libs = not isinstance(input_bin, (HostLibrary, StaticLibrary))
for lib in input_bin.linked_libraries:
if isinstance(lib, RustLibrary):
if isinstance(lib, (HostRustLibrary, RustLibrary)):
continue
elif isinstance(lib, (HostLibrary, StaticLibrary)):
expand(lib, True, system_libs)

Просмотреть файл

@ -46,6 +46,7 @@ from ..frontend.data import (
HostGeneratedSources,
HostLibrary,
HostProgram,
HostRustLibrary,
HostRustProgram,
HostSimpleProgram,
HostSources,
@ -678,7 +679,7 @@ class RecursiveMakeBackend(CommonBackend):
elif isinstance(obj, InstallationTarget):
self._process_installation_target(obj, backend_file)
elif isinstance(obj, RustLibrary):
elif isinstance(obj, (RustLibrary, HostRustLibrary)):
self.backend_input_files.add(obj.cargo_file)
self._process_rust_library(obj, backend_file)
# No need to call _process_linked_libraries, because Rust

Просмотреть файл

@ -670,9 +670,8 @@ class StaticLibrary(Library):
self.no_expand_lib = no_expand_lib
class RustLibrary(StaticLibrary):
"""Context derived container object for a static library"""
__slots__ = (
class BaseRustLibrary(object):
slots = (
'cargo_file',
'crate_type',
'dependencies',
@ -681,13 +680,9 @@ class RustLibrary(StaticLibrary):
'target_dir',
'output_category',
)
TARGET_SUBST_VAR = 'RUST_TARGET'
FEATURES_VAR = 'RUST_LIBRARY_FEATURES'
LIB_FILE_VAR = 'RUST_LIBRARY_FILE'
def __init__(self, context, basename, cargo_file, crate_type, dependencies,
features, target_dir, **args):
StaticLibrary.__init__(self, context, basename, **args)
def init(self, context, basename, cargo_file, crate_type, dependencies,
features, target_dir):
self.cargo_file = cargo_file
self.crate_type = crate_type
# We need to adjust our naming here because cargo replaces '-' in
@ -715,6 +710,21 @@ class RustLibrary(StaticLibrary):
self.deps_path = mozpath.join(build_dir, 'deps')
class RustLibrary(StaticLibrary, BaseRustLibrary):
"""Context derived container object for a rust static library"""
KIND = 'target'
TARGET_SUBST_VAR = 'RUST_TARGET'
FEATURES_VAR = 'RUST_LIBRARY_FEATURES'
LIB_FILE_VAR = 'RUST_LIBRARY_FILE'
__slots__ = BaseRustLibrary.slots
def __init__(self, context, basename, cargo_file, crate_type, dependencies,
features, target_dir, link_into=None):
StaticLibrary.__init__(self, context, basename, link_into=link_into)
BaseRustLibrary.init(self, context, basename, cargo_file,
crate_type, dependencies, features, target_dir)
class SharedLibrary(Library):
"""Context derived container object for a shared library"""
__slots__ = (
@ -830,12 +840,19 @@ class HostLibrary(HostMixin, BaseLibrary):
KIND = 'host'
class HostRustLibrary(HostMixin, RustLibrary):
class HostRustLibrary(HostLibrary, BaseRustLibrary):
"""Context derived container object for a host rust library"""
KIND = 'host'
TARGET_SUBST_VAR = 'RUST_HOST_TARGET'
FEATURES_VAR = 'HOST_RUST_LIBRARY_FEATURES'
LIB_FILE_VAR = 'HOST_RUST_LIBRARY_FILE'
__slots__ = BaseRustLibrary.slots
def __init__(self, context, basename, cargo_file, crate_type, dependencies,
features, target_dir):
HostLibrary.__init__(self, context, basename)
BaseRustLibrary.init(self, context, basename, cargo_file,
crate_type, dependencies, features, target_dir)
class TestManifest(ContextDerived):