Bug 1496746 - Remove VPATH; r=glandium

Having a full VPATH for the srcdir sometimes causes make to grab the
wrong prerequisite for a rule, in particular if we have a file in the
srcdir and also generate a file of the same name in the objdir. We don't
really need VPATH anymore though, since most of the information comes
from mozbuild, where we can explicitly list the path to the srcdir or
objdir as necessary.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Shal 2019-09-09 17:44:47 +00:00
parent 1cb0ac3980
commit f8f5fce637
16 changed files with 73 additions and 64 deletions

View File

@ -16,7 +16,7 @@ MIDL_GENERATED_FILES = \
# midl targets to avoid timestamp caching issues.
$(MIDL_GENERATED_FILES): done_gen ;
done_gen: IGeckoCustom.idl
done_gen: $(srcdir)/IGeckoCustom.idl
$(MIDL) $(MIDL_FLAGS) -I $(srcdir) -Oicf $(srcdir)/IGeckoCustom.idl
touch $@

View File

@ -16,10 +16,10 @@ MIDL_GENERATED_FILES = \
# midl targets to avoid timestamp caching issues.
$(MIDL_GENERATED_FILES): done_gen ;
done_gen: ISimpleDOM.idl \
ISimpleDOMNode.idl \
ISimpleDOMDocument.idl \
ISimpleDOMText.idl
done_gen: $(srcdir)/ISimpleDOM.idl \
$(srcdir)/ISimpleDOMNode.idl \
$(srcdir)/ISimpleDOMDocument.idl \
$(srcdir)/ISimpleDOMText.idl
$(MIDL) $(MIDL_FLAGS) -I $(srcdir) -robust -Oicf $(srcdir)/ISimpleDOM.idl
touch $@

View File

@ -21,7 +21,7 @@ export:: $(MIDL_GENERATED_FILES)
# midl targets to avoid timestamp caching issues.
$(MIDL_GENERATED_FILES): midl_done ;
midl_done: HandlerData.acf HandlerData.idl
midl_done: $(srcdir)/HandlerData.acf $(srcdir)/HandlerData.idl
$(MIDL) $(MIDL_FLAGS) $(DEFINES) -I $(topobjdir) -I $(DIST)/include -I $(IA2DIR) -I $(MSAADIR) -Oicf -acf $(srcdir)/HandlerData.acf $(srcdir)/HandlerData.idl
touch $@

View File

@ -15,7 +15,7 @@ MIDL_GENERATED_FILES = \
# midl targets to avoid timestamp caching issues.
$(MIDL_GENERATED_FILES): done_gen ;
done_gen: Accessible.idl
done_gen: $(srcdir)/Accessible.idl
$(MIDL) $(MIDL_FLAGS) -Oicf $(srcdir)/Accessible.idl
touch $@

View File

@ -31,7 +31,7 @@ ifeq ($(OS_ARCH),WINNT)
# (this dependency should really be just for firefox.exe, not other targets)
# Note the manifest file exists in the tree, so we use the explicit filename
# here.
EXTRA_DEPS += firefox.exe.manifest
EXTRA_DEPS += $(srcdir)/firefox.exe.manifest
endif
PROGRAMS_DEST = $(DIST)/bin

View File

@ -43,8 +43,6 @@ endif
EXEC = exec
_VPATH_SRCS = $(abspath $<)
################################################################################
# Testing frameworks support
################################################################################
@ -711,31 +709,31 @@ $(OBJS) $(HOST_OBJS) $(PROGOBJS) $(HOST_PROGOBJS): $(GLOBAL_DEPS)
# Rules for building native targets must come first because of the host_ prefix
$(HOST_COBJS):
$(REPORT_BUILD_VERBOSE)
$(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CFLAGS) $(NSPR_CFLAGS) $(_VPATH_SRCS)
$(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CFLAGS) $(NSPR_CFLAGS) $<
$(HOST_CPPOBJS):
$(REPORT_BUILD_VERBOSE)
$(call BUILDSTATUS,OBJECT_FILE $@)
$(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CXXFLAGS) $(NSPR_CFLAGS) $(_VPATH_SRCS)
$(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CXXFLAGS) $(NSPR_CFLAGS) $<
$(HOST_CMOBJS):
$(REPORT_BUILD_VERBOSE)
$(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CFLAGS) $(HOST_CMFLAGS) $(NSPR_CFLAGS) $(_VPATH_SRCS)
$(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CFLAGS) $(HOST_CMFLAGS) $(NSPR_CFLAGS) $<
$(HOST_CMMOBJS):
$(REPORT_BUILD_VERBOSE)
$(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CXXFLAGS) $(HOST_CMMFLAGS) $(NSPR_CFLAGS) $(_VPATH_SRCS)
$(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CXXFLAGS) $(HOST_CMMFLAGS) $(NSPR_CFLAGS) $<
$(COBJS):
$(REPORT_BUILD_VERBOSE)
$(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
$(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $<
ifdef ASFILES
# The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept
# a '-c' flag.
$(ASOBJS):
$(REPORT_BUILD_VERBOSE)
$(AS) $(ASOUTOPTION)$@ $(ASFLAGS) $($(notdir $<)_FLAGS) $(AS_DASH_C_FLAG) $(_VPATH_SRCS)
$(AS) $(ASOUTOPTION)$@ $(ASFLAGS) $($(notdir $<)_FLAGS) $(AS_DASH_C_FLAG) $<
endif
define syms_template
@ -786,31 +784,31 @@ $(SOBJS):
$(CPPOBJS):
$(REPORT_BUILD_VERBOSE)
$(call BUILDSTATUS,OBJECT_FILE $@)
$(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
$(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $<
$(CMMOBJS):
$(REPORT_BUILD_VERBOSE)
$(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
$(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $($(notdir $<)_FLAGS) $<
$(CMOBJS):
$(REPORT_BUILD_VERBOSE)
$(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
$(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $($(notdir $<)_FLAGS) $<
$(filter %.s,$(CPPSRCS:%.cpp=%.s)): %.s: %.cpp $(call mkdir_deps,$(MDDEPDIR))
$(REPORT_BUILD_VERBOSE)
$(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
$(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $<
$(filter %.s,$(CPPSRCS:%.cc=%.s)): %.s: %.cc $(call mkdir_deps,$(MDDEPDIR))
$(REPORT_BUILD_VERBOSE)
$(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
$(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $<
$(filter %.s,$(CPPSRCS:%.cxx=%.s)): %.s: %.cpp $(call mkdir_deps,$(MDDEPDIR))
$(REPORT_BUILD_VERBOSE)
$(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
$(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $<
$(filter %.s,$(CSRCS:%.c=%.s)): %.s: %.c $(call mkdir_deps,$(MDDEPDIR))
$(REPORT_BUILD_VERBOSE)
$(CC) -S $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
$(CC) -S $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $<
ifneq (,$(filter %.i,$(MAKECMDGOALS)))
# Call as $(call _group_srcs,extension,$(SRCS)) - this will create a list
@ -837,7 +835,7 @@ $$(_PREPROCESSED_$1_FILES): _DEPEND_CFLAGS=
$$(_PREPROCESSED_$1_FILES): %.i: %.$1
$$(REPORT_BUILD_VERBOSE)
$$(addprefix $$(MKDIR) -p ,$$(filter-out .,$$(@D)))
$$($3) -C $$(PREPROCESS_OPTION)$$@ $(foreach var,$4,$$($(var))) $$($$(notdir $$<)_FLAGS) $$(_VPATH_SRCS)
$$($3) -C $$(PREPROCESS_OPTION)$$@ $(foreach var,$4,$$($(var))) $$($$(notdir $$<)_FLAGS) $$<
endef
@ -899,13 +897,13 @@ endif
endif
$(RESFILE): %.res: %.rc
$(RESFILE): %.res: $(RCFILE)
$(REPORT_BUILD)
@echo Creating Resource file: $@
ifdef GNU_CC
$(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) $(OUTOPTION)$@ $(_VPATH_SRCS)
$(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) $(OUTOPTION)$@ $<
else
$(RC) $(RCFLAGS) -r $(DEFINES) $(INCLUDES) $(OUTOPTION)$@ $(_VPATH_SRCS)
$(RC) $(RCFLAGS) -r $(DEFINES) $(INCLUDES) $(OUTOPTION)$@ $<
endif
# Cancel GNU make built-in implicit rules

View File

@ -34,7 +34,7 @@ endif
endif
endif
ifdef RCINCLUDE
_RC_STRING += -RCINCLUDE $(srcdir)/$(RCINCLUDE)
_RC_STRING += -RCINCLUDE $(RCINCLUDE)
endif
GARBAGE += $(RESFILE) $(RCFILE)

View File

@ -11,10 +11,10 @@ celt_pitch_xcorr_arm-gnu.s: celt/arm/armopts-gnu.S
# armopts needs a specific rule, because arm2gnu.pl will always add the .S
# suffix when translating the files that include it.
celt/arm/armopts-gnu.S: celt/arm/armopts.s $(call mkdir_deps,celt/arm) $(GLOBAL_DEPS)
celt/arm/armopts-gnu.S: $(srcdir)/celt/arm/armopts.s $(call mkdir_deps,celt/arm) $(GLOBAL_DEPS)
$(PERL) $(srcdir)/celt/arm/arm2gnu.pl < $< > $@
# For all others, we can use an implicit rule
%-gnu.s: celt/arm/%.s $(GLOBAL_DEPS)
%-gnu.s: $(srcdir)/celt/arm/%.s $(GLOBAL_DEPS)
$(PERL) $(srcdir)/celt/arm/arm2gnu.pl < $< > $@
endif

View File

@ -12,10 +12,10 @@ armloop-gnu.s: armopts-gnu.S
# armopts needs a specific rule, because arm2gnu.pl will always add the .S
# suffix when translating the files that include it.
armopts-gnu.S: lib/arm/armopts.s
armopts-gnu.S: $(srcdir)/lib/arm/armopts.s
$(PERL) $(srcdir)/lib/arm/arm2gnu.pl < $< > $@
# For all others, we can use an implicit rule
%-gnu.s: lib/arm/%.s
%-gnu.s: $(srcdir)/lib/arm/%.s
$(PERL) $(srcdir)/lib/arm/arm2gnu.pl < $< > $@
endif

View File

@ -16,7 +16,7 @@ ifdef GNU_AS
# one directory with arm assembly currently so enumerate it manually.
GENERATED_DIRS += libvpx/vpx_dsp/arm
%.asm.S: %.asm $(ASM_OFFSETS) $(call mkdir_deps,libvpx/vpx_dsp/arm)
libvpx/vpx_dsp/arm/%.asm.S: $(srcdir)/libvpx/vpx_dsp/arm/%.asm $(call mkdir_deps,libvpx/vpx_dsp/arm)
$(PERL) $(topsrcdir)/media/libvpx/libvpx/build/make/ads2gas.pl < $< > $@
$(addsuffix .$(OBJ_SUFFIX), idct4x4_add_neon.asm idct8x8_add_neon.asm idct16x16_add_neon.asm): libvpx/vpx_dsp/arm/idct_neon.asm.S

View File

@ -7,7 +7,7 @@
include $(topsrcdir)/config/config.mk
ifeq (WINNT,$(OS_TARGET))
mozglue.def: mozglue.def.in $(GLOBAL_DEPS)
mozglue.def: $(srcdir)/mozglue.def.in $(GLOBAL_DEPS)
$(call py_action,preprocessor,$(if $(MOZ_REPLACE_MALLOC),-DMOZ_REPLACE_MALLOC) $(ACDEFINES) $< -o $@)
GARBAGE += mozglue.def
@ -16,7 +16,7 @@ GARBAGE += mozglue.def
# (this dependency should really be just for mozglue.dll, not other targets)
# Note the manifest file exists in the tree, so we use the explicit filename
# here.
EXTRA_DEPS += mozglue.dll.manifest
EXTRA_DEPS += $(srcdir)/mozglue.dll.manifest
endif
include $(topsrcdir)/mozglue/build/replace_malloc.mk

View File

@ -472,12 +472,19 @@ class RecursiveMakeBackend(CommonBackend):
if isinstance(obj, GeneratedSources):
variables.append('GARBAGE')
base = backend_file.objdir
cls = ObjDirPath
prefix = '!'
else:
base = backend_file.srcdir
cls = SourcePath
prefix = ''
for f in sorted(obj.files):
f = mozpath.relpath(f, base)
p = self._pretty_path(
cls(obj._context, prefix + mozpath.relpath(f, base)),
backend_file,
)
for var in variables:
backend_file.write('%s += %s\n' % (var, f))
backend_file.write('%s += %s\n' % (var, p))
self._compile_graph[mozpath.join(
backend_file.relobjdir, 'target-objects')]
elif isinstance(obj, (HostSources, HostGeneratedSources)):
@ -490,12 +497,19 @@ class RecursiveMakeBackend(CommonBackend):
if isinstance(obj, HostGeneratedSources):
variables.append('GARBAGE')
base = backend_file.objdir
cls = ObjDirPath
prefix = '!'
else:
base = backend_file.srcdir
cls = SourcePath
prefix = ''
for f in sorted(obj.files):
f = mozpath.relpath(f, base)
p = self._pretty_path(
cls(obj._context, prefix + mozpath.relpath(f, base)),
backend_file,
)
for var in variables:
backend_file.write('%s += %s\n' % (var, f))
backend_file.write('%s += %s\n' % (var, p))
self._compile_graph[mozpath.join(
backend_file.relobjdir, 'host-objects')]
elif isinstance(obj, VariablePassthru):
@ -511,6 +525,9 @@ class RecursiveMakeBackend(CommonBackend):
elif isinstance(v, bool):
if v:
backend_file.write('%s := 1\n' % k)
elif isinstance(v, Path):
path = self._pretty_path(Path(obj._context, v), backend_file)
backend_file.write('%s := %s\n' % (k, path))
else:
backend_file.write('%s := %s\n' % (k, v))
elif isinstance(obj, HostDefines):
@ -1708,7 +1725,6 @@ class RecursiveMakeBackend(CommonBackend):
pp.handleLine(b'topsrcdir := @top_srcdir@\n')
pp.handleLine(b'srcdir := @srcdir@\n')
pp.handleLine(b'srcdir_rel := @srcdir_rel@\n')
pp.handleLine(b'VPATH := @srcdir@\n')
pp.handleLine(b'relativesrcdir := @relativesrcdir@\n')
pp.handleLine(b'include $(DEPTH)/config/@autoconfmk@\n')
if not stub:

View File

@ -1656,7 +1656,7 @@ VARIABLES = {
This variable contains a list of system libaries to link against.
"""),
'RCFILE': (unicode, unicode,
'RCFILE': (Path, unicode,
"""The program .rc file.
This variable can only be used on Windows.
@ -1668,7 +1668,7 @@ VARIABLES = {
This variable can only be used on Windows.
"""),
'RCINCLUDE': (unicode, unicode,
'RCINCLUDE': (Path, unicode,
"""The resource script file to be included in the default .res file.
This variable can only be used on Windows.

View File

@ -227,7 +227,6 @@ class TestRecursiveMakeBackend(BackendTester):
'topsrcdir := %s' % env.topsrcdir,
'srcdir := %s' % env.topsrcdir,
'srcdir_rel := %s' % mozpath.relpath(env.topsrcdir, env.topobjdir),
'VPATH := %s' % env.topsrcdir,
'relativesrcdir := .',
'include $(DEPTH)/config/autoconf.mk',
'',
@ -244,7 +243,7 @@ class TestRecursiveMakeBackend(BackendTester):
self.assertTrue(os.path.exists(p))
lines = [l.strip() for l in open(p, 'rt').readlines()]
self.assertEqual(len(lines), 11)
self.assertEqual(len(lines), 10)
self.assertTrue(lines[0].startswith('# THIS FILE WAS AUTOMATICALLY'))
@ -319,13 +318,13 @@ class TestRecursiveMakeBackend(BackendTester):
expected = {
'RCFILE': [
'RCFILE := foo.rc',
'RCFILE := $(srcdir)/foo.rc',
],
'RESFILE': [
'RESFILE := bar.res',
],
'RCINCLUDE': [
'RCINCLUDE := bar.rc',
'RCINCLUDE := $(srcdir)/bar.rc',
],
'EXTRA_DEPS': [
'EXTRA_DEPS += %s' % mozpath.join(mozpath.relpath(env.topsrcdir,
@ -351,28 +350,28 @@ class TestRecursiveMakeBackend(BackendTester):
expected = {
'ASFILES': [
'ASFILES += bar.s',
'ASFILES += foo.asm',
'ASFILES += $(srcdir)/bar.s',
'ASFILES += $(srcdir)/foo.asm',
],
'CMMSRCS': [
'CMMSRCS += bar.mm',
'CMMSRCS += foo.mm',
'CMMSRCS += $(srcdir)/bar.mm',
'CMMSRCS += $(srcdir)/foo.mm',
],
'CSRCS': [
'CSRCS += bar.c',
'CSRCS += foo.c',
'CSRCS += $(srcdir)/bar.c',
'CSRCS += $(srcdir)/foo.c',
],
'HOST_CPPSRCS': [
'HOST_CPPSRCS += bar.cpp',
'HOST_CPPSRCS += foo.cpp',
'HOST_CPPSRCS += $(srcdir)/bar.cpp',
'HOST_CPPSRCS += $(srcdir)/foo.cpp',
],
'HOST_CSRCS': [
'HOST_CSRCS += bar.c',
'HOST_CSRCS += foo.c',
'HOST_CSRCS += $(srcdir)/bar.c',
'HOST_CSRCS += $(srcdir)/foo.c',
],
'SSRCS': [
'SSRCS += baz.S',
'SSRCS += foo.S',
'SSRCS += $(srcdir)/baz.S',
'SSRCS += $(srcdir)/foo.S',
],
}

View File

@ -54,11 +54,7 @@ def Libxul(name, output_category=None):
'/widget/windows',
'/xpcom/base',
]
# config/version.mk says $(srcdir)/$(RCINCLUDE), and this needs to
# be valid in both toolkit/library and toolkit/library/gtest.
# Eventually, the make backend would do its own path canonicalization
# and config/version.mk would lift the $(srcdir)
RCINCLUDE = '$(DEPTH)/toolkit/library/xulrunner.rc'
RCINCLUDE = '/toolkit/library/xulrunner.rc'
# Show a breakdown of linker time. (Too verbose for local builds.)
if CONFIG['CC_TYPE'] == 'clang-cl' and not CONFIG['DEVELOPER_OPTIONS']:

View File

@ -6,7 +6,7 @@ MOZ_WINCONSOLE = 1
include $(topsrcdir)/config/rules.mk
libs:: TestXREMakeCommandLineWin.ini
libs:: $(srcdir)/TestXREMakeCommandLineWin.ini
$(INSTALL) $^ $(FINAL_TARGET)/
check::