Bug 940202 - Make FINAL_LIBRARY work with comm-central, r=glandium

--HG--
extra : rebase_source : fc8bc5cf6e69be02eeefa7dd98eb5273998831db
This commit is contained in:
Joshua Cranmer 2013-11-19 00:12:25 -06:00
parent cb02ce73d6
commit a451d66163
3 changed files with 22 additions and 14 deletions

View File

@ -1069,9 +1069,17 @@ class RecursiveMakeBackend(CommonBackend):
def _process_library_definition(self, libdef, backend_file):
backend_file.write('LIBRARY_NAME = %s\n' % libdef.basename)
for reldir, basename in libdef.static_libraries:
backend_file.write('SHARED_LIBRARY_LIBS += $(DEPTH)/%s/$(LIB_PREFIX)%s.$(LIB_SUFFIX)\n'
% (reldir, basename))
thisobjdir = libdef.objdir
topobjdir = libdef.topobjdir
for objdir, basename in libdef.static_libraries:
# If this is an external objdir (i.e., comm-central), use the other
# directory instead of $(DEPTH).
if objdir.startswith(topobjdir + '/'):
relpath = '$(DEPTH)/%s' % mozpath.relpath(objdir, topobjdir)
else:
relpath = os.path.relpath(objdir, thisobjdir)
backend_file.write('SHARED_LIBRARY_LIBS += %s/$(LIB_PREFIX)%s.$(LIB_SUFFIX)\n'
% (relpath, basename))
def _write_manifests(self, dest, manifests):
man_dir = os.path.join(self.environment.topobjdir, '_build_manifests',

View File

@ -345,8 +345,8 @@ class LibraryDefinition(SandboxDerived):
self.refcount = 0
self.static_libraries = []
def link_static_lib(self, reldir, basename):
self.static_libraries.append((reldir, basename))
def link_static_lib(self, objdir, basename):
self.static_libraries.append((objdir, basename))
class TestManifest(SandboxDerived):

View File

@ -87,7 +87,7 @@ class TreeMetadataEmitter(LoggingMixin):
for out in output:
if isinstance(out, MozbuildSandbox):
# Keep all sandboxes around, we will need them later.
sandboxes[out['RELATIVEDIR']] = out
sandboxes[out['OBJDIR']] = out
for o in self.emit_from_sandbox(out):
yield o
@ -101,22 +101,22 @@ class TreeMetadataEmitter(LoggingMixin):
else:
raise Exception('Unhandled output type: %s' % out)
for reldir, libname, final_lib in self._final_libs:
for objdir, libname, final_lib in self._final_libs:
if final_lib not in self._libs:
raise Exception('FINAL_LIBRARY in %s (%s) does not match any '
'LIBRARY_NAME' % (reldir, final_lib))
'LIBRARY_NAME' % (objdir, final_lib))
libs = self._libs[final_lib]
if len(libs) > 1:
raise Exception('FINAL_LIBRARY in %s (%s) matches a '
'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
(objdir, final_lib, ', '.join(libs.keys())))
libs.values()[0].link_static_lib(objdir, libname)
self._libs[libname][objdir].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
assert self._libs[libname][objdir].refcount <= 1
def recurse_libs(path, name):
for p, n in self._libs[name][path].static_libraries:
@ -310,13 +310,13 @@ class TreeMetadataEmitter(LoggingMixin):
# If no LIBRARY_NAME is given, create one.
libname = sandbox['RELATIVEDIR'].replace('/', '_')
if libname:
self._libs.setdefault(libname, {})[sandbox['RELATIVEDIR']] = \
self._libs.setdefault(libname, {})[sandbox['OBJDIR']] = \
LibraryDefinition(sandbox, libname)
if final_lib:
if sandbox.get('FORCE_STATIC_LIB'):
raise SandboxValidationError('FINAL_LIBRARY implies FORCE_STATIC_LIB')
self._final_libs.append((sandbox['RELATIVEDIR'], libname, final_lib))
self._final_libs.append((sandbox['OBJDIR'], libname, final_lib))
passthru.variables['FORCE_STATIC_LIB'] = True
# While there are multiple test manifests, the behavior is very similar