mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 07:34:20 +00:00
Bug 1043862 - Make the binaries target use the compile tier. r=gps
This commit is contained in:
parent
2bab6202af
commit
179299ea01
@ -5,10 +5,10 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
binaries libs:: $(SUBMAKEFILES) $(TARGETS)
|
||||
ifndef NO_DIST_INSTALL
|
||||
ifdef SHARED_LIBRARY
|
||||
ifdef IS_COMPONENT
|
||||
libs target:: $(SUBMAKEFILES) $(SHARED_LIBRARY)
|
||||
$(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)/components
|
||||
ifndef NO_COMPONENTS_MANIFEST
|
||||
$(call py_action,buildlist,$(FINAL_TARGET)/chrome.manifest 'manifest components/components.manifest')
|
||||
@ -23,7 +23,7 @@ ifndef NO_DIST_INSTALL
|
||||
ifneq (,$(strip $(PROGRAM)$(SIMPLE_PROGRAMS)))
|
||||
PROGRAMS_EXECUTABLES = $(SIMPLE_PROGRAMS) $(PROGRAM)
|
||||
PROGRAMS_DEST ?= $(FINAL_TARGET)
|
||||
PROGRAMS_TARGET := binaries libs target
|
||||
PROGRAMS_TARGET := libs target
|
||||
INSTALL_TARGETS += PROGRAMS
|
||||
endif
|
||||
|
||||
@ -34,7 +34,7 @@ $(error Shipping static component libs makes no sense.)
|
||||
else
|
||||
DIST_LIBRARY_FILES = $(LIBRARY)
|
||||
DIST_LIBRARY_DEST ?= $(DIST)/lib
|
||||
DIST_LIBRARY_TARGET = binaries libs target
|
||||
DIST_LIBRARY_TARGET = libs target
|
||||
INSTALL_TARGETS += DIST_LIBRARY
|
||||
endif
|
||||
endif # DIST_INSTALL
|
||||
@ -45,7 +45,7 @@ ifdef SHARED_LIBRARY
|
||||
ifndef IS_COMPONENT
|
||||
SHARED_LIBRARY_FILES = $(SHARED_LIBRARY)
|
||||
SHARED_LIBRARY_DEST ?= $(FINAL_TARGET)
|
||||
SHARED_LIBRARY_TARGET = binaries libs target
|
||||
SHARED_LIBRARY_TARGET = libs target
|
||||
INSTALL_TARGETS += SHARED_LIBRARY
|
||||
|
||||
ifneq (,$(filter WINNT,$(OS_ARCH)))
|
||||
@ -57,7 +57,7 @@ IMPORT_LIB_FILES = $(SHARED_LIBRARY)
|
||||
endif
|
||||
|
||||
IMPORT_LIB_DEST ?= $(DIST)/lib
|
||||
IMPORT_LIB_TARGET = binaries libs target
|
||||
IMPORT_LIB_TARGET = libs target
|
||||
ifdef IMPORT_LIB_FILES
|
||||
INSTALL_TARGETS += IMPORT_LIB
|
||||
endif
|
||||
@ -68,30 +68,17 @@ endif # SHARED_LIBRARY
|
||||
ifneq (,$(strip $(HOST_SIMPLE_PROGRAMS)$(HOST_PROGRAM)))
|
||||
HOST_PROGRAMS_EXECUTABLES = $(HOST_SIMPLE_PROGRAMS) $(HOST_PROGRAM)
|
||||
HOST_PROGRAMS_DEST ?= $(DIST)/host/bin
|
||||
HOST_PROGRAMS_TARGET = binaries libs host
|
||||
HOST_PROGRAMS_TARGET = libs host
|
||||
INSTALL_TARGETS += HOST_PROGRAMS
|
||||
endif
|
||||
|
||||
ifdef HOST_LIBRARY
|
||||
HOST_LIBRARY_FILES = $(HOST_LIBRARY)
|
||||
HOST_LIBRARY_DEST ?= $(DIST)/host/lib
|
||||
HOST_LIBRARY_TARGET = binaries libs host
|
||||
HOST_LIBRARY_TARGET = libs host
|
||||
INSTALL_TARGETS += HOST_LIBRARY
|
||||
endif
|
||||
|
||||
endif # !NO_DIST_INSTALL
|
||||
|
||||
BINARIES_INSTALL_TARGETS := $(foreach category,$(INSTALL_TARGETS),$(if $(filter binaries,$($(category)_TARGET)),$(category)))
|
||||
|
||||
# Fill a dependency file with all the binaries installed somewhere in $(DIST)
|
||||
# and with dependencies on the relevant backend files.
|
||||
BINARIES_PP := $(MDDEPDIR)/binaries.pp
|
||||
|
||||
$(BINARIES_PP): Makefile $(wildcard backend.mk) $(call mkdir_deps,$(MDDEPDIR))
|
||||
@echo '$(strip $(foreach category,$(BINARIES_INSTALL_TARGETS),\
|
||||
$(foreach file,$($(category)_FILES) $($(category)_EXECUTABLES),\
|
||||
$($(category)_DEST)/$(notdir $(file)): $(file)%\
|
||||
)\
|
||||
))binaries: Makefile $(wildcard backend.mk)' | tr % '\n' > $@
|
||||
|
||||
# EOF
|
||||
|
@ -36,17 +36,21 @@ ifndef TIERS
|
||||
BUILDSTATUS =
|
||||
endif
|
||||
|
||||
# Main rules (export, compile, binaries, libs and tools) call recurse_* rules.
|
||||
# Main rules (export, compile, libs and tools) call recurse_* rules.
|
||||
# This wrapping is only really useful for build status.
|
||||
compile binaries libs export tools::
|
||||
compile libs export tools::
|
||||
$(call BUILDSTATUS,TIER_START $@)
|
||||
+$(MAKE) recurse_$@
|
||||
$(call BUILDSTATUS,TIER_FINISH $@)
|
||||
|
||||
# Special rule that does install-manifests (cf. Makefile.in) + compile
|
||||
binaries::
|
||||
+$(MAKE) recurse_compile
|
||||
|
||||
# Carefully avoid $(eval) type of rule generation, which makes pymake slower
|
||||
# than necessary.
|
||||
# Get current tier and corresponding subtiers from the data in root.mk.
|
||||
CURRENT_TIER := $(filter $(foreach tier,compile binaries libs export tools,recurse_$(tier) $(tier)-deps),$(MAKECMDGOALS))
|
||||
CURRENT_TIER := $(filter $(foreach tier,compile libs export tools,recurse_$(tier) $(tier)-deps),$(MAKECMDGOALS))
|
||||
ifneq (,$(filter-out 0 1,$(words $(CURRENT_TIER))))
|
||||
$(error $(CURRENT_TIER) not supported on the same make command line)
|
||||
endif
|
||||
@ -71,11 +75,6 @@ endif
|
||||
# TIERS (like for js/src).
|
||||
CURRENT_DIRS := $($(CURRENT_TIER)_dirs)
|
||||
|
||||
ifneq (,$(filter binaries libs,$(CURRENT_TIER)))
|
||||
WANT_STAMPS = 1
|
||||
STAMP_TOUCH = $(TOUCH) $(@D)/binaries
|
||||
endif
|
||||
|
||||
# The compile tier has different rules from other tiers.
|
||||
ifeq ($(CURRENT_TIER),compile)
|
||||
|
||||
@ -91,12 +90,8 @@ else
|
||||
# current tier.
|
||||
$(addsuffix /$(CURRENT_TIER),$(CURRENT_DIRS)): %/$(CURRENT_TIER):
|
||||
$(call SUBMAKE,$(CURRENT_TIER),$*)
|
||||
# Ensure existing stamps are up-to-date, but don't create one if submake didn't create one.
|
||||
$(if $(wildcard $@),@$(STAMP_TOUCH))
|
||||
|
||||
ifndef STAMP_TOUCH
|
||||
.PHONY: $(addsuffix /$(CURRENT_TIER),$(CURRENT_DIRS))
|
||||
endif
|
||||
|
||||
# Dummy rules for possibly inexisting dependencies for the above tier targets
|
||||
$(addsuffix /Makefile,$(CURRENT_DIRS)) $(addsuffix /backend.mk,$(CURRENT_DIRS)):
|
||||
@ -123,46 +118,12 @@ endif
|
||||
|
||||
endif # ifeq ($(CURRENT_TIER),compile)
|
||||
|
||||
ifdef COMPILE_ENVIRONMENT
|
||||
# Disable dependency aggregation on PGO builds because of bug 934166.
|
||||
ifeq (,$(MOZ_PGO)$(MOZ_PROFILE_USE)$(MOZ_PROFILE_GENERATE))
|
||||
ifneq (,$(filter libs binaries,$(CURRENT_TIER)))
|
||||
# When doing a "libs" build, target_libs.mk ensures the interesting dependency data
|
||||
# is available in the "binaries" stamp. Once recursion is done, aggregate all that
|
||||
# dependency info so that stamps depend on relevant files and relevant other stamps.
|
||||
# When doing a "binaries" build, the aggregate dependency file and those stamps are
|
||||
# used and allow to skip recursing directories where changes are not going to require
|
||||
# rebuild. A few directories, however, are still traversed all the time, mostly, the
|
||||
# gyp managed ones and js/src.
|
||||
# A few things that are not traversed by a "binaries" build, but should, in an ideal
|
||||
# world, are nspr, nss, icu and ffi.
|
||||
recurse_$(CURRENT_TIER):
|
||||
@$(MAKE) binaries-deps
|
||||
|
||||
# Creating binaries-deps.mk directly would make us build it twice: once when beginning
|
||||
# the build because of the include, and once at the end because of the stamps.
|
||||
binaries-deps:
|
||||
@$(call py_action,link_deps,-o $@.mk --group-by-depfile --topsrcdir $(topsrcdir) --topobjdir $(DEPTH) --dist $(DIST) --guard $(addprefix ',$(addsuffix ', $(wildcard $(addsuffix /binaries,$(CURRENT_DIRS))))))
|
||||
@$(TOUCH) $@
|
||||
|
||||
ifeq (recurse_binaries,$(MAKECMDGOALS))
|
||||
$(call include_deps,binaries-deps.mk)
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
DIST_GARBAGE += binaries-deps.mk binaries-deps
|
||||
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
# Don't recurse if MAKELEVEL is NO_RECURSE_MAKELEVEL as defined above
|
||||
ifeq ($(NO_RECURSE_MAKELEVEL),$(MAKELEVEL))
|
||||
|
||||
compile binaries libs export tools::
|
||||
compile libs export tools::
|
||||
|
||||
else
|
||||
#########################
|
||||
@ -188,7 +149,7 @@ $(1):: $$(SUBMAKEFILES)
|
||||
|
||||
endef
|
||||
|
||||
$(foreach subtier,export binaries libs tools,$(eval $(call CREATE_SUBTIER_TRAVERSAL_RULE,$(subtier))))
|
||||
$(foreach subtier,export libs tools,$(eval $(call CREATE_SUBTIER_TRAVERSAL_RULE,$(subtier))))
|
||||
|
||||
endif # ifdef TIERS
|
||||
|
||||
@ -196,30 +157,6 @@ endif # ifeq ($(NO_RECURSE_MAKELEVEL),$(MAKELEVEL))
|
||||
|
||||
endif # ifeq (.,$(DEPTH))
|
||||
|
||||
ifdef COMPILE_ENVIRONMENT
|
||||
|
||||
# Aggregate all dependency files relevant to a binaries build except in
|
||||
# the mozilla top-level directory.
|
||||
ifneq (.,$(DEPTH))
|
||||
ALL_DEP_FILES := \
|
||||
$(BINARIES_PP) \
|
||||
$(addsuffix .pp,$(addprefix $(MDDEPDIR)/,$(sort \
|
||||
$(TARGETS) \
|
||||
$(filter-out $(SOBJS) $(ASOBJS) $(EXCLUDED_OBJS),$(OBJ_TARGETS)) \
|
||||
))) \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
binaries libs:: $(TARGETS) $(BINARIES_PP)
|
||||
# Disable dependency aggregation on PGO builds because of bug 934166.
|
||||
ifeq (,$(MOZ_PGO)$(MOZ_PROFILE_USE)$(MOZ_PROFILE_GENERATE))
|
||||
ifneq (.,$(DEPTH))
|
||||
@$(if $^,$(call py_action,link_deps,-o binaries --group-all --topsrcdir $(topsrcdir) --topobjdir $(DEPTH) --dist $(DIST) $(ALL_DEP_FILES)))
|
||||
endif
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
recurse:
|
||||
@$(RECURSED_COMMAND)
|
||||
$(LOOP_OVER_DIRS)
|
||||
|
@ -87,7 +87,7 @@ LIBS += $(NSPR_LIBS)
|
||||
ifndef MOZ_PROFILE_GENERATE
|
||||
CPP_UNIT_TESTS_FILES = $(CPP_UNIT_TESTS)
|
||||
CPP_UNIT_TESTS_DEST = $(DIST)/cppunittests
|
||||
CPP_UNIT_TESTS_TARGET = binaries libs target
|
||||
CPP_UNIT_TESTS_TARGET = libs target
|
||||
INSTALL_TARGETS += CPP_UNIT_TESTS
|
||||
endif
|
||||
|
||||
@ -234,7 +234,6 @@ endif
|
||||
|
||||
# Don't build SIMPLE_PROGRAMS during the MOZ_PROFILE_GENERATE pass
|
||||
ifdef MOZ_PROFILE_GENERATE
|
||||
EXCLUDED_OBJS := $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.$(OBJ_SUFFIX))
|
||||
SIMPLE_PROGRAMS :=
|
||||
endif
|
||||
|
||||
@ -784,7 +783,6 @@ endif
|
||||
ifdef DTRACE_PROBE_OBJ
|
||||
EXTRA_DEPS += $(DTRACE_PROBE_OBJ)
|
||||
OBJS += $(DTRACE_PROBE_OBJ)
|
||||
EXCLUDED_OBJS += $(DTRACE_PROBE_OBJ)
|
||||
endif
|
||||
|
||||
$(filter %.$(LIB_SUFFIX),$(LIBRARY)): $(OBJS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
|
||||
@ -1254,7 +1252,7 @@ ifneq (,$(SDK_LIBRARY))
|
||||
ifndef NO_DIST_INSTALL
|
||||
SDK_LIBRARY_FILES := $(SDK_LIBRARY)
|
||||
SDK_LIBRARY_DEST := $(SDK_LIB_DIR)
|
||||
SDK_LIBRARY_TARGET := binaries libs target
|
||||
SDK_LIBRARY_TARGET := libs target
|
||||
INSTALL_TARGETS += SDK_LIBRARY
|
||||
endif
|
||||
endif # SDK_LIBRARY
|
||||
@ -1264,7 +1262,7 @@ ifndef NO_DIST_INSTALL
|
||||
SDK_BINARY_FILES := $(SDK_BINARY)
|
||||
SDK_BINARY_DEST := $(SDK_BIN_DIR)
|
||||
# SDK_BINARY_TARGET is set in xpcom/idl-parser/Makefile.in
|
||||
SDK_BINARY_TARGET ?= binaries libs target
|
||||
SDK_BINARY_TARGET ?= libs target
|
||||
INSTALL_TARGETS += SDK_BINARY
|
||||
endif
|
||||
endif # SDK_BINARY
|
||||
|
@ -1,229 +0,0 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
'''
|
||||
Read dependency Makefiles and merge them together. Also normalizes paths
|
||||
relative to a given topobjdir and topsrcdir, and drops files outside topobjdir
|
||||
and topsrcdir.
|
||||
|
||||
The build creates many .pp files under .deps directories. Those contain
|
||||
specific dependencies for individual targets.
|
||||
|
||||
As an example, let's say we have a tree like the following:
|
||||
foo/ contains foo1.cpp and foo2.cpp, built, respectively, as foo1.o and
|
||||
foo2.o, and depending on foo.h, in the same directory, and bar.h in a bar/
|
||||
directory.
|
||||
bar/ contains bar.cpp, built as bar.cpp, and depending on bar.h.
|
||||
build/ contains no source, but builds a libfoobar.a library from foo1.o,
|
||||
foo2.o and bar.o.
|
||||
|
||||
In that example, we have .pp files like the following (ignoring removal
|
||||
guards):
|
||||
foo/.deps/foo1.o.pp:
|
||||
foo1.o: /path/to/foo/foo1.cpp /path/to/foo/foo.h \
|
||||
/path/to/bar/bar.h /usr/include/some/system/headers
|
||||
foo/.deps/foo2.o.pp:
|
||||
foo2.o: /path/to/foo/foo2.cpp /path/to/foo/foo.h \
|
||||
/path/to/bar/bar.h /usr/include/some/system/headers
|
||||
bar/.deps/bar.o.pp:
|
||||
bar.o: /path/to/bar/bar.cpp /path/to/bar/bar.h \
|
||||
/usr/include/some/system/headers
|
||||
build/.deps/libfoobar.a.pp:
|
||||
libfoobar.a: ../foo/foo1.o ../foo/foo2.o ../bar/bar.o
|
||||
|
||||
The first stage is to group and normalize all dependencies per directory.
|
||||
This is the Grouping.ALL_TARGETS case.
|
||||
|
||||
The intermediate result would be:
|
||||
foo/binaries:
|
||||
$(DEPTH)/foo/foo1.o $(DEPTH)/foo/foo2.o: $(topsrcdir)/foo/foo1.cpp \
|
||||
$(topsrcdir)/foo/foo2.cpp $(topsrcdir)/foo/foo.h $(topsrcdir)/bar/bar.h
|
||||
bar/binaries:
|
||||
$(DEPTH)/bar/bar.o: $(topsrcdir)/bar/bar.cpp $(topsrcdir)/bar/bar.h
|
||||
build/binaries:
|
||||
$(DEPTH)/build/libfoobar.a: $(DEPTH)/foo/foo1.o $(DEPTH)/foo/foo2.o \
|
||||
$(DEPTH)/bar/bar.o
|
||||
|
||||
Those files are not meant to be directly included by a Makefile, so the broad
|
||||
dependencies they represent is not a problem. But it helps making the next step
|
||||
faster, by reading less and smaller files.
|
||||
|
||||
The second stage is grouping those rules by file they are defined in. This
|
||||
means replacing occurrences of, e.g. $(DEPTH)/foo/foo1.o with the file that
|
||||
defines $(DEPTH)/foo/foo1.o as a target, which is $(DEPTH)/foo/binaries.
|
||||
|
||||
The end result would thus be:
|
||||
binaries-deps.mk:
|
||||
$(DEPTH)/foo/binaries: $(topsrcdir)/foo/foo1.cpp \
|
||||
$(topsrcdir)/foo/foo2.cpp $(topsrcdir)/foo/foo.h \
|
||||
$(topsrcdir)/bar/bar.h
|
||||
$(DEPTH)/bar/binaries: $(topsrcdir)/bar/bar.cpp $(topsrcdir)/bar/bar.h
|
||||
$(DEPTH)/build/binaries: $(DEPTH)/foo/binaries $(DEPTH)/bar/binaries
|
||||
|
||||
A change in foo/foo1.cpp would then trigger a rebuild of foo/binaries and
|
||||
build/binaries.
|
||||
'''
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
from collections import OrderedDict
|
||||
from mozbuild.makeutil import (
|
||||
Makefile,
|
||||
read_dep_makefile,
|
||||
)
|
||||
import mozpack.path as mozpath
|
||||
|
||||
|
||||
def enum(**enums):
|
||||
return type('Enum', (), enums)
|
||||
|
||||
|
||||
Grouping = enum(NO=0, BY_DEPFILE=1, ALL_TARGETS=2)
|
||||
|
||||
|
||||
class DependencyLinker(Makefile):
|
||||
def __init__(self, topsrcdir, topobjdir, dist, group=Grouping.NO,
|
||||
abspaths=False):
|
||||
topsrcdir = mozpath.normsep(os.path.normcase(os.path.abspath(topsrcdir)))
|
||||
topobjdir = mozpath.normsep(os.path.normcase(os.path.abspath(topobjdir)))
|
||||
dist = mozpath.normsep(os.path.normcase(os.path.abspath(dist)))
|
||||
if abspaths:
|
||||
topsrcdir_value = topsrcdir
|
||||
topobjdir_value = topobjdir
|
||||
dist_value = dist
|
||||
else:
|
||||
topsrcdir_value = '$(topsrcdir)'
|
||||
topobjdir_value = '$(DEPTH)'
|
||||
dist_value = '$(DIST)'
|
||||
|
||||
self._normpaths = {
|
||||
topsrcdir: topsrcdir_value,
|
||||
topobjdir: topobjdir_value,
|
||||
dist: dist_value,
|
||||
'$(topsrcdir)': topsrcdir_value,
|
||||
'$(DEPTH)': topobjdir_value,
|
||||
'$(DIST)': dist_value,
|
||||
'$(depth)': topobjdir_value, # normcase may lowercase variable refs when
|
||||
'$(dist)': dist_value, # they are in the original dependency file
|
||||
mozpath.relpath(topobjdir, os.curdir): topobjdir_value,
|
||||
mozpath.relpath(dist, os.curdir): dist_value,
|
||||
}
|
||||
try:
|
||||
# mozpath.relpath(topsrcdir, os.curdir) fails when source directory
|
||||
# and object directory are not on the same drive on Windows. In
|
||||
# this case, the value is not useful in self._normpaths anyways.
|
||||
self._normpaths[mozpath.relpath(topsrcdir, os.curdir)] = topsrcdir_value
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
Makefile.__init__(self)
|
||||
self._group = group
|
||||
self._targets = OrderedDict()
|
||||
|
||||
def add_dependencies(self, fh):
|
||||
depfile = self.normpath(os.path.abspath(fh.name))
|
||||
for rule in read_dep_makefile(fh):
|
||||
deps = list(rule.dependencies())
|
||||
if deps:
|
||||
deps = list(self.normpaths(deps))
|
||||
for t in self.normpaths(rule.targets()):
|
||||
if t in self._targets:
|
||||
raise Exception('Found target %s in %s and %s'
|
||||
% (t, self._targets[t][0], depfile))
|
||||
self._targets[t] = (depfile, deps)
|
||||
|
||||
def dump(self, fh, removal_guard=True):
|
||||
rules = {}
|
||||
for t, (depfile, deps) in self._targets.items():
|
||||
if self._group == Grouping.BY_DEPFILE:
|
||||
if depfile not in rules:
|
||||
rules[depfile] = self.create_rule([depfile])
|
||||
rules[depfile].add_dependencies(d if d not in self._targets else self._targets[d][0] for d in deps)
|
||||
elif self._group == Grouping.ALL_TARGETS:
|
||||
if 'all' not in rules:
|
||||
rules['all'] = self.create_rule()
|
||||
rules['all'].add_targets([t]) \
|
||||
.add_dependencies(deps)
|
||||
elif self._group == Grouping.NO:
|
||||
self.create_rule([t]) \
|
||||
.add_dependencies(deps)
|
||||
Makefile.dump(self, fh, removal_guard)
|
||||
|
||||
# os.path.abspath is slow, especially when run hundred of thousands of
|
||||
# times with a lot of times the same path or partial path, so cleverly
|
||||
# cache results and partial results.
|
||||
def normpath(self, path):
|
||||
key = mozpath.normsep(os.path.normcase(path))
|
||||
result = self._normpaths.get(key, False)
|
||||
if result != False:
|
||||
return result
|
||||
dir, file = os.path.split(path)
|
||||
if file in ['.', '..']:
|
||||
result = self.normpath(os.path.abspath(path))
|
||||
self._normpaths[key] = result
|
||||
return result
|
||||
if dir != path:
|
||||
if dir == '':
|
||||
dir = '.'
|
||||
d = self.normpath(dir)
|
||||
if d:
|
||||
result = '%s/%s' % (d, os.path.basename(path))
|
||||
self._normpaths[key] = result
|
||||
return result
|
||||
self._normpaths[key] = None
|
||||
return None
|
||||
|
||||
def normpaths(self, paths):
|
||||
for p in paths:
|
||||
r = self.normpath(p)
|
||||
if r:
|
||||
yield r
|
||||
|
||||
|
||||
def main(args):
|
||||
parser = argparse.ArgumentParser(description='Link dependency files.')
|
||||
parser.add_argument('--topsrcdir', required=True,
|
||||
help='Path to the top-level source directory.')
|
||||
parser.add_argument('--topobjdir', required=True,
|
||||
help='Path to the top-level object directory.')
|
||||
parser.add_argument('--dist', required=True,
|
||||
help='Path to the dist directory.')
|
||||
parser.add_argument('-o', '--output',
|
||||
help='Send output to the given file.')
|
||||
parser.add_argument('dependency_files', nargs='*')
|
||||
parser.add_argument('--guard', action="store_true",
|
||||
help='Add removal guards in the linked result.')
|
||||
group = parser.add_mutually_exclusive_group()
|
||||
group.add_argument('--group-by-depfile', action='store_true',
|
||||
help='Group dependencies by depfile.')
|
||||
group.add_argument('--group-all', action='store_true',
|
||||
help='Group all dependencies under one target.')
|
||||
parser.add_argument('--abspaths', action='store_true',
|
||||
help='Use absolute paths instead of using make variable references.')
|
||||
opts = parser.parse_args(args)
|
||||
|
||||
if opts.group_by_depfile:
|
||||
group = Grouping.BY_DEPFILE
|
||||
elif opts.group_all:
|
||||
group = Grouping.ALL_TARGETS
|
||||
else:
|
||||
group = Grouping.NO
|
||||
linker = DependencyLinker(topsrcdir=opts.topsrcdir,
|
||||
topobjdir=opts.topobjdir,
|
||||
dist=opts.dist,
|
||||
group=group,
|
||||
abspaths=opts.abspaths)
|
||||
for f in opts.dependency_files:
|
||||
linker.add_dependencies(open(f))
|
||||
|
||||
if opts.output:
|
||||
out = open(opts.output, 'w')
|
||||
else:
|
||||
out = sys.stdout
|
||||
linker.dump(out, removal_guard=opts.guard)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv[1:])
|
@ -327,7 +327,6 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
|
||||
self._may_skip = {
|
||||
'export': set(),
|
||||
'binaries': set(),
|
||||
'libs': set(),
|
||||
}
|
||||
self._no_skip = {
|
||||
@ -538,10 +537,8 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
return current, [], subdirs.parallel + \
|
||||
subdirs.dirs + subdirs.tests
|
||||
|
||||
# compile, binaries and tools tiers use the same traversal as export
|
||||
filters = [
|
||||
('export', parallel_filter),
|
||||
('binaries', parallel_filter),
|
||||
('libs', libs_filter),
|
||||
('tools', tools_filter),
|
||||
]
|
||||
@ -704,8 +701,6 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
self.summary.makefile_in_count += 1
|
||||
|
||||
for tier, skiplist in self._may_skip.items():
|
||||
if tier in ('compile', 'binaries'):
|
||||
continue
|
||||
if bf.relobjdir in skiplist:
|
||||
skiplist.remove(bf.relobjdir)
|
||||
else:
|
||||
|
@ -1,159 +0,0 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import mozunit
|
||||
import os
|
||||
import unittest
|
||||
from collections import OrderedDict
|
||||
from mozbuild.action.link_deps import (
|
||||
DependencyLinker,
|
||||
Grouping,
|
||||
)
|
||||
from mozbuild.makeutil import Makefile
|
||||
from StringIO import StringIO
|
||||
|
||||
|
||||
class TestDependencyLinker(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self._cwd = os.getcwd()
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
||||
def tearDown(self):
|
||||
os.chdir(self._cwd)
|
||||
|
||||
def gen_depfile(self, name, rules):
|
||||
mk = Makefile()
|
||||
for target, deps in rules.items():
|
||||
mk.create_rule([target]) \
|
||||
.add_dependencies(deps)
|
||||
depfile = StringIO()
|
||||
mk.dump(depfile, removal_guard=True)
|
||||
depfile.seek(0)
|
||||
depfile.name = name
|
||||
return depfile
|
||||
|
||||
def test_dependency_linker(self):
|
||||
linker = DependencyLinker(
|
||||
topsrcdir=os.path.abspath(os.path.join(os.pardir, os.pardir)),
|
||||
topobjdir=os.path.abspath(os.pardir),
|
||||
dist=os.path.abspath(os.path.join(os.pardir, 'dist'))
|
||||
)
|
||||
linker.add_dependencies(self.gen_depfile('.deps/foo.o.pp', {'foo.o': [
|
||||
'../../foo/foo.cpp',
|
||||
'/usr/include/stdint.h',
|
||||
'../dist/include/bar.h',
|
||||
'../qux_gen/qux.h',
|
||||
'../../hoge/hoge.h'
|
||||
]}))
|
||||
|
||||
linker.add_dependencies(self.gen_depfile('.deps/bar.o.pp', {'bar.o': [
|
||||
'../../foo/bar.cpp',
|
||||
'/usr/include/stdint.h',
|
||||
'../dist/include/bar.h',
|
||||
'../../foo/foo.h',
|
||||
'../../hoge/hoge.h'
|
||||
]}))
|
||||
|
||||
result = StringIO()
|
||||
linker.dump(result)
|
||||
|
||||
self.assertEqual(result.getvalue().splitlines(), [
|
||||
'$(DEPTH)/test/foo.o: $(topsrcdir)/foo/foo.cpp '
|
||||
'$(DIST)/include/bar.h $(DEPTH)/qux_gen/qux.h '
|
||||
'$(topsrcdir)/hoge/hoge.h',
|
||||
'$(DEPTH)/test/bar.o: $(topsrcdir)/foo/bar.cpp '
|
||||
'$(DIST)/include/bar.h $(topsrcdir)/foo/foo.h '
|
||||
'$(topsrcdir)/hoge/hoge.h',
|
||||
'$(DEPTH)/qux_gen/qux.h $(DIST)/include/bar.h '
|
||||
'$(topsrcdir)/foo/bar.cpp $(topsrcdir)/foo/foo.cpp '
|
||||
'$(topsrcdir)/foo/foo.h $(topsrcdir)/hoge/hoge.h:'
|
||||
])
|
||||
|
||||
def test_dependency_grouping(self):
|
||||
linker = DependencyLinker(
|
||||
topsrcdir=os.path.abspath(os.path.join(os.pardir, os.pardir)),
|
||||
topobjdir=os.path.abspath(os.pardir),
|
||||
dist=os.path.abspath(os.path.join(os.pardir, 'dist')),
|
||||
group=Grouping.ALL_TARGETS
|
||||
)
|
||||
linker.add_dependencies(self.gen_depfile('.deps/foo.o.pp', {'foo.o': [
|
||||
'../../foo/foo.cpp',
|
||||
'/usr/include/stdint.h',
|
||||
'../dist/include/bar.h',
|
||||
'../qux_gen/qux.h',
|
||||
'../../hoge/hoge.h'
|
||||
]}))
|
||||
|
||||
linker.add_dependencies(self.gen_depfile('.deps/bar.o.pp', {'bar.o': [
|
||||
'../../foo/bar.cpp',
|
||||
'/usr/include/stdint.h',
|
||||
'../dist/include/bar.h',
|
||||
'../../foo/foo.h',
|
||||
'../../hoge/hoge.h'
|
||||
]}))
|
||||
|
||||
result = StringIO()
|
||||
linker.dump(result)
|
||||
|
||||
self.assertEqual(result.getvalue().splitlines(), [
|
||||
'$(DEPTH)/test/foo.o $(DEPTH)/test/bar.o: '
|
||||
'$(topsrcdir)/foo/foo.cpp $(DIST)/include/bar.h '
|
||||
'$(DEPTH)/qux_gen/qux.h $(topsrcdir)/hoge/hoge.h '
|
||||
'$(topsrcdir)/foo/bar.cpp $(topsrcdir)/foo/foo.h',
|
||||
'$(DEPTH)/qux_gen/qux.h $(DIST)/include/bar.h '
|
||||
'$(topsrcdir)/foo/bar.cpp $(topsrcdir)/foo/foo.cpp '
|
||||
'$(topsrcdir)/foo/foo.h $(topsrcdir)/hoge/hoge.h:'
|
||||
])
|
||||
|
||||
def test_dependency_by_depfile(self):
|
||||
linker = DependencyLinker(
|
||||
topsrcdir=os.path.abspath(os.pardir),
|
||||
topobjdir=os.path.abspath(os.curdir),
|
||||
dist=os.path.abspath('dist'),
|
||||
group=Grouping.BY_DEPFILE
|
||||
)
|
||||
linker.add_dependencies(self.gen_depfile('foo/binaries', OrderedDict([
|
||||
('$(DEPTH)/foo/foo.o', [
|
||||
'$(topsrcdir)/foo/foo.cpp',
|
||||
'$(DIST)/include/bar.h',
|
||||
'$(DEPTH)/qux_gen/qux.h',
|
||||
'$(topsrcdir)/hoge/hoge.h',
|
||||
]),
|
||||
('$(DEPTH)/foo/bar.o', [
|
||||
'$(topsrcdir)/foo/bar.cpp',
|
||||
'$(DIST)/include/bar.h',
|
||||
'$(topsrcdir)/foo/foo.h',
|
||||
'$(topsrcdir)/hoge/hoge.h',
|
||||
]),
|
||||
('$(DEPTH)/foo/foobar.lib', [
|
||||
'$(DEPTH)/foo/foo.o',
|
||||
'$(DEPTH)/foo/bar.o',
|
||||
]),
|
||||
('$(DIST)/lib/foobar.lib', [ '$(DEPTH)/foo/foobar.lib' ]),
|
||||
])))
|
||||
linker.add_dependencies(self.gen_depfile('hoge/binaries', OrderedDict([
|
||||
('$(DEPTH)/hoge/hoge.exe', [
|
||||
'$(DEPTH)/hoge/hoge.o',
|
||||
'$(DIST)/lib/foobar.lib',
|
||||
]),
|
||||
('$(DEPTH)/hoge/hoge.o', [
|
||||
'$(topsrcdir)/hoge/hoge.cpp',
|
||||
'$(topsrcdir)/hoge/hoge.h',
|
||||
]),
|
||||
])))
|
||||
|
||||
result = StringIO()
|
||||
linker.dump(result, removal_guard=False)
|
||||
|
||||
self.assertEqual(result.getvalue().splitlines(), [
|
||||
'$(DEPTH)/foo/binaries: $(topsrcdir)/foo/foo.cpp '
|
||||
'$(DIST)/include/bar.h $(DEPTH)/qux_gen/qux.h '
|
||||
'$(topsrcdir)/hoge/hoge.h $(topsrcdir)/foo/bar.cpp '
|
||||
'$(topsrcdir)/foo/foo.h',
|
||||
'$(DEPTH)/hoge/binaries: $(DEPTH)/foo/binaries '
|
||||
'$(topsrcdir)/hoge/hoge.cpp $(topsrcdir)/hoge/hoge.h',
|
||||
])
|
||||
|
||||
if __name__ == '__main__':
|
||||
mozunit.main()
|
@ -303,7 +303,7 @@ endif # MOZ_FOLD_LIBS
|
||||
# Filter-out $(LIBRARY_NAME) because it's already handled in config/rules.mk.
|
||||
NSS_DIST_DLL_FILES := $(addprefix $(DIST)/lib/$(DLL_PREFIX),$(addsuffix $(DLL_SUFFIX),$(filter-out $(LIBRARY_NAME),$(NSS_DLLS)) $(NSS_EXTRA_DLLS)))
|
||||
NSS_DIST_DLL_DEST := $(DIST)/bin
|
||||
NSS_DIST_DLL_TARGET := binaries libs target
|
||||
NSS_DIST_DLL_TARGET := libs target
|
||||
INSTALL_TARGETS += NSS_DIST_DLL
|
||||
|
||||
ifeq ($(OS_ARCH)_$(1), SunOS_softokn3)
|
||||
@ -316,7 +316,7 @@ NSS_SDK_LIB_FILES := \
|
||||
$(addprefix $(DIST)/bin/$(DLL_PREFIX),$(addsuffix $(DLL_SUFFIX),$(NSS_DLLS))) \
|
||||
$(NULL)
|
||||
NSS_SDK_LIB_DEST := $(DIST)/sdk/lib
|
||||
NSS_SDK_LIB_TARGET := binaries libs target
|
||||
NSS_SDK_LIB_TARGET := libs target
|
||||
INSTALL_TARGETS += NSS_SDK_LIB
|
||||
|
||||
ifdef MOZ_FOLD_LIBS
|
||||
|
Loading…
x
Reference in New Issue
Block a user