Bug 939074 - Infer LIBXUL_LIBRARY from FINAL_LIBRARY. r=gps

This commit is contained in:
Mike Hommey 2013-11-19 11:47:52 +09:00
parent 61b0bdbe18
commit d8a16abbc8
4 changed files with 43 additions and 1 deletions

View File

@ -44,6 +44,7 @@ _MOZBUILD_EXTERNAL_VARIABLES := \
EXTRA_PP_JS_MODULES \
FORCE_SHARED_LIB \
FORCE_STATIC_LIB \
FINAL_LIBRARY \
GTEST_CMMSRCS \
GTEST_CPPSRCS \
GTEST_CSRCS \
@ -333,6 +334,13 @@ _ENABLE_PIC=1
# Determine if module being compiled is destined
# to be merged into libxul
ifeq ($(FINAL_LIBRARY),xul)
ifdef LIBXUL_LIBRARY
$(error FINAL_LIBRARY is "xul", LIBXUL_LIBRARY is implied)
endif
LIBXUL_LIBRARY := 1
endif
ifdef LIBXUL_LIBRARY
ifdef IS_COMPONENT
$(error IS_COMPONENT is set, but is not compatible with LIBXUL_LIBRARY)

View File

@ -44,6 +44,7 @@ _MOZBUILD_EXTERNAL_VARIABLES := \
EXTRA_PP_JS_MODULES \
FORCE_SHARED_LIB \
FORCE_STATIC_LIB \
FINAL_LIBRARY \
GTEST_CMMSRCS \
GTEST_CPPSRCS \
GTEST_CSRCS \
@ -333,6 +334,13 @@ _ENABLE_PIC=1
# Determine if module being compiled is destined
# to be merged into libxul
ifeq ($(FINAL_LIBRARY),xul)
ifdef LIBXUL_LIBRARY
$(error FINAL_LIBRARY is "xul", LIBXUL_LIBRARY is implied)
endif
LIBXUL_LIBRARY := 1
endif
ifdef LIBXUL_LIBRARY
ifdef IS_COMPONENT
$(error IS_COMPONENT is set, but is not compatible with LIBXUL_LIBRARY)

View File

@ -335,12 +335,14 @@ class LibraryDefinition(SandboxDerived):
__slots__ = (
'basename',
'static_libraries',
'refcount',
)
def __init__(self, sandbox, basename):
SandboxDerived.__init__(self, sandbox)
self.basename = basename
self.refcount = 0
self.static_libraries = []
def link_static_lib(self, reldir, basename):

View File

@ -82,9 +82,13 @@ class TreeMetadataEmitter(LoggingMixin):
"""
file_count = 0
execution_time = 0.0
sandboxes = {}
for out in output:
if isinstance(out, MozbuildSandbox):
# Keep all sandboxes around, we will need them later.
sandboxes[out['RELATIVEDIR']] = out
for o in self.emit_from_sandbox(out):
yield o
if not o._ack:
@ -107,9 +111,29 @@ class TreeMetadataEmitter(LoggingMixin):
'LIBRARY_NAME defined in multiple places (%s)' %
(reldir, final_lib, ', '.join(libs.keys())))
libs.values()[0].link_static_lib(reldir, libname)
self._libs[libname][reldir].refcount += 1
# 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 self._libs[libname][reldir].refcount <= 1
def recurse_libs(path, name):
for p, n in self._libs[name][path].static_libraries:
yield p
for q in recurse_libs(p, n):
yield q
for basename, libs in self._libs.items():
for libdef in libs.values():
for path, libdef in libs.items():
# 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 libdef.refcount:
for p in recurse_libs(path, basename):
passthru = VariablePassthru(sandboxes[p])
passthru.variables['FINAL_LIBRARY'] = basename
yield passthru
yield libdef
yield ReaderSummary(file_count, execution_time)