mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Bug 1036894
part 5 - Hook the USE_LIBS and HOST_USE_LIBS moz.build variables to library linkage. r=gps
This commit is contained in:
parent
8da7425be2
commit
b1fdb17493
@ -45,7 +45,9 @@ from ..frontend.data import (
|
||||
Resources,
|
||||
SandboxDerived,
|
||||
SandboxWrapped,
|
||||
SharedLibrary,
|
||||
SimpleProgram,
|
||||
StaticLibrary,
|
||||
TestManifest,
|
||||
VariablePassthru,
|
||||
XPIDLFile,
|
||||
@ -100,6 +102,10 @@ class BackendMakeFile(object):
|
||||
def write(self, buf):
|
||||
self.fh.write(buf)
|
||||
|
||||
def write_once(self, buf):
|
||||
if '\n' + buf not in self.fh.getvalue():
|
||||
self.write(buf)
|
||||
|
||||
# For compatibility with makeutil.Makefile
|
||||
def add_statement(self, stmt):
|
||||
self.write('%s\n' % stmt)
|
||||
@ -423,15 +429,19 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
|
||||
elif isinstance(obj, Program):
|
||||
self._process_program(obj.program, backend_file)
|
||||
self._process_linked_libraries(obj, backend_file)
|
||||
|
||||
elif isinstance(obj, HostProgram):
|
||||
self._process_host_program(obj.program, backend_file)
|
||||
self._process_linked_libraries(obj, backend_file)
|
||||
|
||||
elif isinstance(obj, SimpleProgram):
|
||||
self._process_simple_program(obj.program, backend_file)
|
||||
self._process_linked_libraries(obj, backend_file)
|
||||
|
||||
elif isinstance(obj, HostSimpleProgram):
|
||||
self._process_host_simple_program(obj.program, backend_file)
|
||||
self._process_linked_libraries(obj, backend_file)
|
||||
|
||||
elif isinstance(obj, LocalInclude):
|
||||
self._process_local_include(obj.path, backend_file)
|
||||
@ -461,11 +471,17 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
else:
|
||||
return
|
||||
|
||||
elif isinstance(obj, Library):
|
||||
self._process_library(obj, backend_file)
|
||||
elif isinstance(obj, SharedLibrary):
|
||||
self._process_shared_library(obj, backend_file)
|
||||
self._process_linked_libraries(obj, backend_file)
|
||||
|
||||
elif isinstance(obj, StaticLibrary):
|
||||
self._process_static_library(obj, backend_file)
|
||||
self._process_linked_libraries(obj, backend_file)
|
||||
|
||||
elif isinstance(obj, HostLibrary):
|
||||
self._process_host_library(obj, backend_file)
|
||||
self._process_linked_libraries(obj, backend_file)
|
||||
|
||||
else:
|
||||
return
|
||||
@ -1103,37 +1119,59 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
rule.add_commands(['$(call py_action,process_install_manifest,%s)' % ' '.join(args)])
|
||||
fragment.dump(backend_file.fh, removal_guard=False)
|
||||
|
||||
def _process_library(self, libdef, backend_file):
|
||||
backend_file.write('LIBRARY_NAME := %s\n' % libdef.basename)
|
||||
if libdef.kind in (libdef.STATIC, libdef.STATIC + libdef.SHARED):
|
||||
backend_file.write('FORCE_STATIC_LIB := 1\n')
|
||||
backend_file.write('REAL_LIBRARY := %s\n' % libdef.static_name)
|
||||
if libdef.kind != libdef.STATIC:
|
||||
backend_file.write('FORCE_SHARED_LIB := 1\n')
|
||||
backend_file.write('IMPORT_LIBRARY := %s\n' % libdef.import_name)
|
||||
backend_file.write('SHARED_LIBRARY := %s\n' % libdef.shared_name)
|
||||
if libdef.kind == libdef.COMPONENT:
|
||||
def _process_shared_library(self, libdef, backend_file):
|
||||
backend_file.write_once('LIBRARY_NAME := %s\n' % libdef.basename)
|
||||
backend_file.write('FORCE_SHARED_LIB := 1\n')
|
||||
backend_file.write('IMPORT_LIBRARY := %s\n' % libdef.import_name)
|
||||
backend_file.write('SHARED_LIBRARY := %s\n' % libdef.lib_name)
|
||||
if libdef.variant == libdef.COMPONENT:
|
||||
backend_file.write('IS_COMPONENT := 1\n')
|
||||
if libdef.soname:
|
||||
backend_file.write('DSO_SONAME := %s\n' % libdef.soname)
|
||||
if libdef.is_sdk:
|
||||
backend_file.write('SDK_LIBRARY := %s\n' % libdef.import_name)
|
||||
|
||||
thisobjdir = libdef.objdir
|
||||
topobjdir = mozpath.normsep(libdef.topobjdir)
|
||||
for obj in libdef.linked_libraries:
|
||||
# If this is an external objdir (i.e., comm-central), use the other
|
||||
# directory instead of $(DEPTH).
|
||||
if obj.objdir.startswith(topobjdir + '/'):
|
||||
relpath = '$(DEPTH)/%s' % mozpath.relpath(obj.objdir, topobjdir)
|
||||
else:
|
||||
relpath = mozpath.relpath(obj.objdir, thisobjdir)
|
||||
backend_file.write('SHARED_LIBRARY_LIBS += %s/%s\n'
|
||||
% (relpath, obj.static_name))
|
||||
def _process_static_library(self, libdef, backend_file):
|
||||
backend_file.write_once('LIBRARY_NAME := %s\n' % libdef.basename)
|
||||
backend_file.write('FORCE_STATIC_LIB := 1\n')
|
||||
backend_file.write('REAL_LIBRARY := %s\n' % libdef.lib_name)
|
||||
if libdef.is_sdk:
|
||||
backend_file.write('SDK_LIBRARY := %s\n' % libdef.import_name)
|
||||
|
||||
def _process_host_library(self, libdef, backend_file):
|
||||
backend_file.write('HOST_LIBRARY_NAME = %s\n' % libdef.basename)
|
||||
|
||||
def _process_linked_libraries(self, obj, backend_file):
|
||||
topobjdir = mozpath.normsep(obj.topobjdir)
|
||||
for lib in obj.linked_libraries:
|
||||
# If this is an external objdir (i.e., comm-central), use the other
|
||||
# directory instead of $(DEPTH).
|
||||
if lib.objdir.startswith(topobjdir + '/'):
|
||||
relpath = '$(DEPTH)/%s' % mozpath.relpath(lib.objdir, topobjdir)
|
||||
else:
|
||||
relpath = mozpath.relpath(lib.objdir, obj.objdir)
|
||||
if isinstance(obj, Library):
|
||||
if isinstance(lib, StaticLibrary):
|
||||
backend_file.write_once('SHARED_LIBRARY_LIBS += %s/%s\n'
|
||||
% (relpath, lib.lib_name))
|
||||
else:
|
||||
assert isinstance(obj, SharedLibrary)
|
||||
assert lib.variant != lib.COMPONENT
|
||||
backend_file.write_once('EXTRA_DSO_LDOPTS += %s/%s\n'
|
||||
% (relpath, lib.import_name))
|
||||
elif isinstance(obj, (Program, SimpleProgram)):
|
||||
if isinstance(lib, StaticLibrary):
|
||||
backend_file.write_once('LIBS += %s/%s\n'
|
||||
% (relpath, lib.lib_name))
|
||||
else:
|
||||
assert lib.variant != lib.COMPONENT
|
||||
backend_file.write_once('LIBS += %s/%s\n'
|
||||
% (relpath, lib.import_name))
|
||||
elif isinstance(obj, (HostLibrary, HostProgram, HostSimpleProgram)):
|
||||
assert isinstance(lib, HostLibrary)
|
||||
backend_file.write_once('HOST_LIBS += %s/%s\n'
|
||||
% (relpath, lib.lib_name))
|
||||
|
||||
def _write_manifests(self, dest, manifests):
|
||||
man_dir = mozpath.join(self.environment.topobjdir, '_build_manifests',
|
||||
dest)
|
||||
|
@ -83,6 +83,10 @@ class SandboxDerived(TreeMetadata):
|
||||
|
||||
self.config = sandbox.config
|
||||
|
||||
@property
|
||||
def relobjdir(self):
|
||||
return mozpath.relpath(self.objdir, self.topobjdir)
|
||||
|
||||
|
||||
class DirectoryTraversal(SandboxDerived):
|
||||
"""Describes how directory traversal for building should work.
|
||||
@ -338,7 +342,7 @@ class Linkable(SandboxDerived):
|
||||
|
||||
def link_library(self, obj):
|
||||
assert isinstance(obj, BaseLibrary)
|
||||
if obj.kind == obj.COMPONENT:
|
||||
if isinstance(obj, SharedLibrary) and obj.variant == obj.COMPONENT:
|
||||
raise LinkageWrongKindError(
|
||||
'Linkable.link_library() does not take components.')
|
||||
if obj.KIND != self.KIND:
|
||||
@ -395,67 +399,22 @@ class BaseLibrary(Linkable):
|
||||
"""Generic sandbox container object for libraries."""
|
||||
__slots__ = (
|
||||
'basename',
|
||||
'lib_name',
|
||||
'import_name',
|
||||
'is_sdk',
|
||||
'link_into',
|
||||
'shared_name',
|
||||
'static_name',
|
||||
'soname',
|
||||
'refcount',
|
||||
)
|
||||
|
||||
STATIC = 1
|
||||
SHARED = 2
|
||||
# STATIC + SHARED = 3
|
||||
FRAMEWORK = 4
|
||||
COMPONENT = 5
|
||||
MAX_TYPE = 6
|
||||
|
||||
def __init__(self, sandbox, basename, kind=None, soname=None,
|
||||
static_name=None, shared_name=None, is_sdk=False,
|
||||
link_into=None):
|
||||
assert(kind in range(1, self.MAX_TYPE))
|
||||
def __init__(self, sandbox, basename):
|
||||
Linkable.__init__(self, sandbox)
|
||||
|
||||
self.basename = basename
|
||||
self.kind = kind
|
||||
self.static_name = self.shared_name = None
|
||||
if kind in (self.STATIC, self.STATIC + self.SHARED):
|
||||
self.static_name = static_name or self.basename
|
||||
if self.static_name:
|
||||
self.static_name = '%s%s%s' % (
|
||||
self.basename = self.lib_name = basename
|
||||
if self.lib_name:
|
||||
self.lib_name = '%s%s%s' % (
|
||||
sandbox.config.lib_prefix,
|
||||
self.static_name,
|
||||
self.lib_name,
|
||||
sandbox.config.lib_suffix
|
||||
)
|
||||
self.import_name = self.static_name
|
||||
if kind != self.STATIC:
|
||||
self.shared_name = shared_name or self.basename
|
||||
if self.shared_name:
|
||||
if kind == self.FRAMEWORK:
|
||||
self.shared_name = shared_name
|
||||
self.import_name = shared_name
|
||||
else:
|
||||
self.import_name = '%s%s%s' % (
|
||||
sandbox.config.import_prefix,
|
||||
self.shared_name,
|
||||
sandbox.config.import_suffix,
|
||||
)
|
||||
self.shared_name = '%s%s%s' % (
|
||||
sandbox.config.dll_prefix,
|
||||
self.shared_name,
|
||||
sandbox.config.dll_suffix,
|
||||
)
|
||||
if soname:
|
||||
self.soname = '%s%s%s' % (
|
||||
sandbox.config.dll_prefix,
|
||||
soname,
|
||||
sandbox.config.dll_suffix,
|
||||
)
|
||||
else:
|
||||
self.soname = self.shared_name
|
||||
self.is_sdk = is_sdk
|
||||
self.link_into = link_into
|
||||
self.import_name = self.lib_name
|
||||
|
||||
self.refcount = 0
|
||||
|
||||
@ -463,16 +422,74 @@ class BaseLibrary(Linkable):
|
||||
class Library(BaseLibrary):
|
||||
"""Sandbox container object for a library"""
|
||||
KIND = 'target'
|
||||
__slots__ = (
|
||||
'is_sdk',
|
||||
)
|
||||
|
||||
def __init__(self, sandbox, basename, real_name=None, is_sdk=False):
|
||||
BaseLibrary.__init__(self, sandbox, real_name or basename)
|
||||
self.basename = basename
|
||||
self.is_sdk = is_sdk
|
||||
|
||||
|
||||
class StaticLibrary(Library):
|
||||
"""Sandbox container object for a static library"""
|
||||
__slots__ = (
|
||||
'link_into',
|
||||
)
|
||||
|
||||
def __init__(self, sandbox, basename, real_name=None, is_sdk=False,
|
||||
link_into=None):
|
||||
Library.__init__(self, sandbox, basename, real_name, is_sdk)
|
||||
self.link_into = link_into
|
||||
|
||||
|
||||
class SharedLibrary(Library):
|
||||
"""Sandbox container object for a shared library"""
|
||||
__slots__ = (
|
||||
'soname',
|
||||
'variant',
|
||||
)
|
||||
|
||||
FRAMEWORK = 1
|
||||
COMPONENT = 2
|
||||
MAX_VARIANT = 3
|
||||
|
||||
def __init__(self, sandbox, basename, real_name=None, is_sdk=False,
|
||||
soname=None, variant=None):
|
||||
assert(variant in range(1, self.MAX_VARIANT) or variant is None)
|
||||
Library.__init__(self, sandbox, basename, real_name, is_sdk)
|
||||
self.variant = variant
|
||||
self.lib_name = real_name or basename
|
||||
assert self.lib_name
|
||||
|
||||
if variant == self.FRAMEWORK:
|
||||
self.import_name = self.lib_name
|
||||
else:
|
||||
self.import_name = '%s%s%s' % (
|
||||
sandbox.config.import_prefix,
|
||||
self.lib_name,
|
||||
sandbox.config.import_suffix,
|
||||
)
|
||||
self.lib_name = '%s%s%s' % (
|
||||
sandbox.config.dll_prefix,
|
||||
self.lib_name,
|
||||
sandbox.config.dll_suffix,
|
||||
)
|
||||
if soname:
|
||||
self.soname = '%s%s%s' % (
|
||||
sandbox.config.dll_prefix,
|
||||
soname,
|
||||
sandbox.config.dll_suffix,
|
||||
)
|
||||
else:
|
||||
self.soname = self.lib_name
|
||||
|
||||
|
||||
class HostLibrary(BaseLibrary):
|
||||
"""Sandbox container object for a host library"""
|
||||
KIND = 'host'
|
||||
|
||||
def __init__(self, sandbox, basename):
|
||||
BaseLibrary.__init__(self, sandbox, basename,
|
||||
kind=self.STATIC)
|
||||
|
||||
|
||||
class TestManifest(SandboxDerived):
|
||||
"""Represents a manifest file containing information about tests."""
|
||||
|
@ -38,6 +38,7 @@ from .data import (
|
||||
JARManifest,
|
||||
JavaScriptModules,
|
||||
Library,
|
||||
Linkable,
|
||||
LinkageWrongKindError,
|
||||
LocalInclude,
|
||||
PerSourceFlag,
|
||||
@ -47,7 +48,9 @@ from .data import (
|
||||
ReaderSummary,
|
||||
Resources,
|
||||
SandboxWrapped,
|
||||
SharedLibrary,
|
||||
SimpleProgram,
|
||||
StaticLibrary,
|
||||
TestWebIDLFile,
|
||||
TestManifest,
|
||||
VariablePassthru,
|
||||
@ -89,6 +92,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
|
||||
self._libs = OrderedDefaultDict(list)
|
||||
self._binaries = OrderedDict()
|
||||
self._linkage = []
|
||||
|
||||
def emit(self, output):
|
||||
"""Convert the BuildReader output into data structures.
|
||||
@ -135,8 +139,11 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
yield ReaderSummary(file_count, sandbox_execution_time, emitter_time)
|
||||
|
||||
def _emit_libs_derived(self, sandboxes):
|
||||
for sandbox, obj, variable in self._linkage:
|
||||
self._link_libraries(sandbox, obj, variable)
|
||||
|
||||
for lib in (l for libs in self._libs.values() for l in libs):
|
||||
if not lib.link_into:
|
||||
if not isinstance(lib, StaticLibrary) or not lib.link_into:
|
||||
continue
|
||||
if lib.link_into not in self._libs:
|
||||
raise Exception('FINAL_LIBRARY in %s (%s) does not match any '
|
||||
@ -147,19 +154,12 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
'LIBRARY_NAME defined in multiple places (%s)' %
|
||||
(lib.objdir, lib.link_into,
|
||||
', '.join(l.objdir for l in candidates)))
|
||||
# emit_from_sandbox ensures libraries with a FINAL_LIBRARY are
|
||||
# static.
|
||||
assert lib.KIND == 'target' and lib.kind == lib.STATIC
|
||||
candidates[0].link_library(lib)
|
||||
|
||||
# The refcount can't go above 1 right now. It might in the future,
|
||||
# but that will have to be specifically handled. At which point the
|
||||
# refcount might have to be a list of referencees, for better error
|
||||
# reporting.
|
||||
assert lib.refcount <= 1
|
||||
|
||||
def recurse_libs(lib):
|
||||
for obj in lib.linked_libraries:
|
||||
if not isinstance(obj, StaticLibrary) or not obj.link_into:
|
||||
continue
|
||||
yield obj.objdir
|
||||
for q in recurse_libs(obj):
|
||||
yield q
|
||||
@ -168,16 +168,108 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
# For all root libraries (i.e. libraries that don't have a
|
||||
# FINAL_LIBRARY), record, for each static library it links
|
||||
# (recursively), that its FINAL_LIBRARY is that root library.
|
||||
if not lib.refcount:
|
||||
for p in recurse_libs(lib):
|
||||
passthru = VariablePassthru(sandboxes[p])
|
||||
passthru.variables['FINAL_LIBRARY'] = lib.basename
|
||||
yield passthru
|
||||
if isinstance(lib, Library):
|
||||
if isinstance(lib, SharedLibrary) or not lib.link_into:
|
||||
for p in recurse_libs(lib):
|
||||
passthru = VariablePassthru(sandboxes[p])
|
||||
passthru.variables['FINAL_LIBRARY'] = lib.basename
|
||||
yield passthru
|
||||
yield lib
|
||||
|
||||
for obj in self._binaries.values():
|
||||
yield obj
|
||||
|
||||
LIBRARY_NAME_VAR = {
|
||||
'host': 'HOST_LIBRARY_NAME',
|
||||
'target': 'LIBRARY_NAME',
|
||||
}
|
||||
|
||||
def _link_libraries(self, sandbox, obj, variable):
|
||||
"""Add linkage declarations to a given object."""
|
||||
assert isinstance(obj, Linkable)
|
||||
for path in sandbox.get(variable, []):
|
||||
force_static = path.startswith('static:') and obj.KIND == 'target'
|
||||
if force_static:
|
||||
path = path[7:]
|
||||
name = mozpath.basename(path)
|
||||
dir = mozpath.dirname(path)
|
||||
candidates = [l for l in self._libs[name] if l.KIND == obj.KIND]
|
||||
if dir:
|
||||
if dir.startswith('/'):
|
||||
dir = mozpath.normpath(
|
||||
mozpath.join(obj.topobjdir, dir[1:]))
|
||||
else:
|
||||
dir = mozpath.normpath(
|
||||
mozpath.join(obj.objdir, dir))
|
||||
dir = mozpath.relpath(dir, obj.topobjdir)
|
||||
candidates = [l for l in candidates if l.relobjdir == dir]
|
||||
if not candidates:
|
||||
raise SandboxValidationError(
|
||||
'%s contains "%s", but there is no "%s" %s in %s.'
|
||||
% (variable, path, name,
|
||||
self.LIBRARY_NAME_VAR[obj.KIND], dir), sandbox)
|
||||
|
||||
if len(candidates) > 1:
|
||||
# If there's more than one remaining candidate, it could be
|
||||
# that there are instances for the same library, in static and
|
||||
# shared form.
|
||||
libs = {}
|
||||
for l in candidates:
|
||||
key = mozpath.join(l.relobjdir, l.basename)
|
||||
if force_static:
|
||||
if isinstance(l, StaticLibrary):
|
||||
libs[key] = l
|
||||
else:
|
||||
if key in libs and isinstance(l, SharedLibrary):
|
||||
libs[key] = l
|
||||
if key not in libs:
|
||||
libs[key] = l
|
||||
candidates = libs.values()
|
||||
if force_static and not candidates:
|
||||
if dir:
|
||||
raise SandboxValidationError(
|
||||
'%s contains "static:%s", but there is no static '
|
||||
'"%s" %s in %s.' % (variable, path, name,
|
||||
self.LIBRARY_NAME_VAR[obj.KIND], dir), sandbox)
|
||||
raise SandboxValidationError(
|
||||
'%s contains "static:%s", but there is no static "%s" '
|
||||
'%s in the tree' % (variable, name, name,
|
||||
self.LIBRARY_NAME_VAR[obj.KIND]), sandbox)
|
||||
|
||||
if not candidates:
|
||||
raise SandboxValidationError(
|
||||
'%s contains "%s", which does not match any %s in the tree.'
|
||||
% (variable, path, self.LIBRARY_NAME_VAR[obj.KIND]),
|
||||
sandbox)
|
||||
|
||||
elif len(candidates) > 1:
|
||||
paths = (mozpath.join(l.relativedir, 'moz.build')
|
||||
for l in candidates)
|
||||
raise SandboxValidationError(
|
||||
'%s contains "%s", which matches a %s defined in multiple '
|
||||
'places:\n %s' % (variable, path,
|
||||
self.LIBRARY_NAME_VAR[obj.KIND],
|
||||
'\n '.join(paths)), sandbox)
|
||||
|
||||
elif force_static and not isinstance(candidates[0], StaticLibrary):
|
||||
raise SandboxValidationError(
|
||||
'%s contains "static:%s", but there is only a shared "%s" '
|
||||
'in %s. You may want to add FORCE_STATIC_LIB=True in '
|
||||
'%s/moz.build, or remove "static:".' % (variable, path,
|
||||
name, candidates[0].relobjdir, candidates[0].relobjdir),
|
||||
sandbox)
|
||||
|
||||
elif isinstance(obj, StaticLibrary) and isinstance(candidates[0],
|
||||
SharedLibrary):
|
||||
raise SandboxValidationError(
|
||||
'%s contains "%s", but there is only a shared "%s" '
|
||||
'in %s, and "%s" is built static. You may want to '
|
||||
'add FORCE_STATIC_LIB=True in %s/moz.build, or remove '
|
||||
'"%s" from USE_LIBS.' % (variable, path, name,
|
||||
candidates[0].relobjdir, obj.basename,
|
||||
candidates[0].relobjdir, path), sandbox)
|
||||
obj.link_library(candidates[0])
|
||||
|
||||
def emit_from_sandbox(self, sandbox):
|
||||
"""Convert a MozbuildSandbox to tree metadata objects.
|
||||
|
||||
@ -247,7 +339,6 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
'GENERATED_FILES',
|
||||
'IS_GYP_DIR',
|
||||
'JS_MODULES_PATH',
|
||||
'LIBS',
|
||||
'MSVC_ENABLE_PGO',
|
||||
'NO_DIST_INSTALL',
|
||||
'OS_LIBS',
|
||||
@ -353,6 +444,8 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
'because it is already used in %s' % (program, kind,
|
||||
self._binaries[program].relativedir), sandbox)
|
||||
self._binaries[program] = cls(sandbox, program)
|
||||
self._linkage.append((sandbox, self._binaries[program],
|
||||
kind.replace('PROGRAM', 'USE_LIBS')))
|
||||
|
||||
for kind, cls in [
|
||||
('SIMPLE_PROGRAMS', SimpleProgram),
|
||||
@ -364,6 +457,8 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
'because it is already used in %s' % (program, kind,
|
||||
self._binaries[program].relativedir), sandbox)
|
||||
self._binaries[program] = cls(sandbox, program)
|
||||
self._linkage.append((sandbox, self._binaries[program],
|
||||
kind.replace('SIMPLE_PROGRAM', 'USE_LIBS')))
|
||||
|
||||
test_js_modules = sandbox.get('TESTING_JS_MODULES')
|
||||
if test_js_modules:
|
||||
@ -396,7 +491,9 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
if host_libname == libname:
|
||||
raise SandboxValidationError('LIBRARY_NAME and '
|
||||
'HOST_LIBRARY_NAME must have a different value', sandbox)
|
||||
self._libs[host_libname].append(HostLibrary(sandbox, host_libname))
|
||||
lib = HostLibrary(sandbox, host_libname)
|
||||
self._libs[host_libname].append(lib)
|
||||
self._linkage.append((sandbox, lib, 'HOST_USE_LIBS'))
|
||||
|
||||
final_lib = sandbox.get('FINAL_LIBRARY')
|
||||
if not libname and final_lib:
|
||||
@ -414,9 +511,8 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
|
||||
soname = sandbox.get('SONAME')
|
||||
|
||||
args = {
|
||||
'kind': 0,
|
||||
}
|
||||
shared_args = {}
|
||||
static_args = {}
|
||||
|
||||
if final_lib:
|
||||
if isinstance(sandbox, MozbuildSandbox):
|
||||
@ -436,7 +532,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
raise SandboxValidationError(
|
||||
'FINAL_LIBRARY conflicts with IS_COMPONENT. '
|
||||
'Please remove one.', sandbox)
|
||||
args['link_into'] = final_lib
|
||||
static_args['link_into'] = final_lib
|
||||
static_lib = True
|
||||
|
||||
if libname:
|
||||
@ -454,7 +550,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
'IS_COMPONENT conflicts with FORCE_STATIC_LIB. '
|
||||
'Please remove one.', sandbox)
|
||||
shared_lib = True
|
||||
args['kind'] = Library.COMPONENT
|
||||
shared_args['variant'] = SharedLibrary.COMPONENT
|
||||
|
||||
if is_framework:
|
||||
if shared_lib:
|
||||
@ -470,39 +566,73 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
'IS_FRAMEWORK conflicts with SONAME. '
|
||||
'Please remove one.', sandbox)
|
||||
shared_lib = True
|
||||
args['kind'] = Library.FRAMEWORK
|
||||
shared_args['variant'] = SharedLibrary.FRAMEWORK
|
||||
|
||||
if static_name:
|
||||
if not static_lib:
|
||||
raise SandboxValidationError(
|
||||
'STATIC_LIBRARY_NAME requires FORCE_STATIC_LIB', sandbox)
|
||||
args['static_name'] = static_name
|
||||
static_args['real_name'] = static_name
|
||||
|
||||
if shared_name:
|
||||
if not shared_lib:
|
||||
raise SandboxValidationError(
|
||||
'SHARED_LIBRARY_NAME requires FORCE_SHARED_LIB', sandbox)
|
||||
args['shared_name'] = shared_name
|
||||
shared_args['real_name'] = shared_name
|
||||
|
||||
if soname:
|
||||
if not shared_lib:
|
||||
raise SandboxValidationError(
|
||||
'SONAME requires FORCE_SHARED_LIB', sandbox)
|
||||
args['soname'] = soname
|
||||
shared_args['soname'] = soname
|
||||
|
||||
if not static_lib and not shared_lib:
|
||||
static_lib = True
|
||||
if not args['kind']:
|
||||
if static_lib:
|
||||
args['kind'] += Library.STATIC
|
||||
if shared_lib:
|
||||
args['kind'] += Library.SHARED
|
||||
|
||||
# If both a shared and a static library are created, only the
|
||||
# shared library is meant to be a SDK library.
|
||||
if sandbox.get('SDK_LIBRARY'):
|
||||
args['is_sdk'] = True
|
||||
if shared_lib:
|
||||
shared_args['is_sdk'] = True
|
||||
elif static_lib:
|
||||
static_args['is_sdk'] = True
|
||||
|
||||
self._libs[libname].append(Library(sandbox, libname, **args))
|
||||
if shared_lib and static_lib:
|
||||
if not static_name and not shared_name:
|
||||
raise SandboxValidationError(
|
||||
'Both FORCE_STATIC_LIB and FORCE_SHARED_LIB are True, '
|
||||
'but neither STATIC_LIBRARY_NAME or '
|
||||
'SHARED_LIBRARY_NAME is set. At least one is required.',
|
||||
sandbox)
|
||||
if static_name and not shared_name and static_name == libname:
|
||||
raise SandboxValidationError(
|
||||
'Both FORCE_STATIC_LIB and FORCE_SHARED_LIB are True, '
|
||||
'but STATIC_LIBRARY_NAME is the same as LIBRARY_NAME, '
|
||||
'and SHARED_LIBRARY_NAME is unset. Please either '
|
||||
'change STATIC_LIBRARY_NAME or LIBRARY_NAME, or set '
|
||||
'SHARED_LIBRARY_NAME.', sandbox)
|
||||
if shared_name and not static_name and shared_name == libname:
|
||||
raise SandboxValidationError(
|
||||
'Both FORCE_STATIC_LIB and FORCE_SHARED_LIB are True, '
|
||||
'but SHARED_LIBRARY_NAME is the same as LIBRARY_NAME, '
|
||||
'and STATIC_LIBRARY_NAME is unset. Please either '
|
||||
'change SHARED_LIBRARY_NAME or LIBRARY_NAME, or set '
|
||||
'STATIC_LIBRARY_NAME.', sandbox)
|
||||
if shared_name and static_name and shared_name == static_name:
|
||||
raise SandboxValidationError(
|
||||
'Both FORCE_STATIC_LIB and FORCE_SHARED_LIB are True, '
|
||||
'but SHARED_LIBRARY_NAME is the same as '
|
||||
'STATIC_LIBRARY_NAME. Please change one of them.',
|
||||
sandbox)
|
||||
|
||||
if shared_lib:
|
||||
lib = SharedLibrary(sandbox, libname, **shared_args)
|
||||
self._libs[libname].append(lib)
|
||||
self._linkage.append((sandbox, lib, 'USE_LIBS'))
|
||||
if static_lib:
|
||||
lib = StaticLibrary(sandbox, libname, **static_args)
|
||||
self._libs[libname].append(lib)
|
||||
self._linkage.append((sandbox, lib, 'USE_LIBS'))
|
||||
|
||||
# While there are multiple test manifests, the behavior is very similar
|
||||
# across them. We enforce this by having common handling of all
|
||||
|
@ -340,10 +340,12 @@ VARIABLES = {
|
||||
Implies FORCE_STATIC_LIB.
|
||||
""", None),
|
||||
|
||||
'LIBS': (StrictOrderingOnAppendList, list,
|
||||
"""Linker libraries and flags.
|
||||
'USE_LIBS': (StrictOrderingOnAppendList, list,
|
||||
"""List of libraries to link to programs and libraries.
|
||||
""", None),
|
||||
|
||||
A list of libraries and flags to include when linking.
|
||||
'HOST_USE_LIBS': (StrictOrderingOnAppendList, list,
|
||||
"""List of libraries to link to host programs and libraries.
|
||||
""", None),
|
||||
|
||||
'LOCAL_INCLUDES': (StrictOrderingOnAppendList, list,
|
||||
|
@ -15,8 +15,6 @@ CPP_UNIT_TESTS = ['foo.cpp']
|
||||
HOST_SOURCES += ['bar.cpp', 'foo.cpp']
|
||||
HOST_SOURCES += ['bar.c', 'foo.c']
|
||||
|
||||
LIBS = ['bar.lib', 'foo.lib']
|
||||
|
||||
OS_LIBS = ['foo.so', '-l123', 'bar.a']
|
||||
|
||||
SOURCES += ['bar.c', 'foo.c']
|
||||
|
@ -15,8 +15,6 @@ CPP_UNIT_TESTS = ['foo.cpp']
|
||||
HOST_SOURCES += ['fans.cpp', 'tans.cpp']
|
||||
HOST_SOURCES += ['fans.c', 'tans.c']
|
||||
|
||||
LIBS += ['fans.lib', 'tans.lib']
|
||||
|
||||
OS_LIBS += ['foo.so', '-l123', 'aaa.a']
|
||||
|
||||
SOURCES += ['fans.c', 'tans.c']
|
||||
|
@ -167,7 +167,6 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
FAIL_ON_WARNINGS=True,
|
||||
HOST_CPPSRCS=['fans.cpp', 'tans.cpp'],
|
||||
HOST_CSRCS=['fans.c', 'tans.c'],
|
||||
LIBS=['fans.lib', 'tans.lib'],
|
||||
MSVC_ENABLE_PGO=True,
|
||||
NO_DIST_INSTALL=True,
|
||||
OS_LIBS=['foo.so', '-l123', 'aaa.a'],
|
||||
|
Loading…
Reference in New Issue
Block a user