Bug 911634 - Create a .mozconfig.mk in the objdir when starting a build, and include it from config.mk. r=gps

This commit is contained in:
Mike Hommey 2013-09-05 09:01:44 +09:00
parent ac78d3f835
commit 3cee26c564
5 changed files with 47 additions and 23 deletions

View File

@ -35,7 +35,7 @@ DIST_GARBAGE = config.cache config.log config.status* config-defs.h \
config/autoconf.mk \
mozilla-config.h \
netwerk/necko-config.h xpcom/xpcom-config.h xpcom/xpcom-private.h \
$(topsrcdir)/.mozconfig.mk $(topsrcdir)/.mozconfig.out
.mozconfig.mk
ifndef MOZ_PROFILE_USE
# One of the first things we do in the build is purge "unknown" files

View File

@ -43,15 +43,6 @@ mk_add_options() {
# and substitute '@<word>@' with '$(<word>)'.
_opt=`echo "$_opt" | sed -e 's/\([\"\\]\)/\\\\\1/g; s/@\([^@]*\)@/\$(\1)/g;'`
echo $_opt;
opts="${opts:+$opts^}$_opt";
done
}
mk_echo_options() {
echo "Adding client.mk options from $FOUND_MOZCONFIG:" >&2
IFS=^
for _opt in $opts; do
echo " $_opt" >&2
done
}
@ -60,7 +51,6 @@ mk_echo_options() {
scriptdir=`dirname $0`
topsrcdir=$1
opts=""
# If the path changes, configure should be rerun
echo "# PATH=$PATH"
@ -81,10 +71,6 @@ if [ -n $isfoundset ]; then
then
print_header
. "$FOUND_MOZCONFIG"
fi
echo "export FOUND_MOZCONFIG := $FOUND_MOZCONFIG"
if [ "$opts" ]; then
mk_echo_options
echo "FOUND_MOZCONFIG := $FOUND_MOZCONFIG"
fi
fi

View File

@ -114,8 +114,20 @@ endef
# As $(shell) doesn't preserve newlines, use sed to replace them with an
# unlikely sequence (||), which is then replaced back to newlines by make
# before evaluation.
$(eval $(subst ||,$(CR),$(shell _PYMAKE=$(.PYMAKE) $(TOPSRCDIR)/$(MOZCONFIG_LOADER) $(TOPSRCDIR) 2> $(TOPSRCDIR)/.mozconfig.out | sed 's/$$/||/')))
# before evaluation. $(shell) replacing newlines with spaces, || is always
# followed by a space (since sed doesn't remove newlines), except on the
# last line, so replace both '|| ' and '||'.
MOZCONFIG_CONTENT := $(subst ||,$(CR),$(subst || ,$(CR),$(shell _PYMAKE=$(.PYMAKE) $(TOPSRCDIR)/$(MOZCONFIG_LOADER) $(TOPSRCDIR) | sed 's/$$/||/')))
$(eval $(MOZCONFIG_CONTENT))
# As '||' was used as a newline separator, it means it's not occurring in
# lines themselves. It can thus safely be used to replaces normal spaces,
# to then replace newlines with normal spaces. This allows to get a list
# of mozconfig output lines.
MOZCONFIG_OUT_LINES := $(subst $(CR), ,$(subst $(NULL) $(NULL),||,$(MOZCONFIG_CONTENT)))
# Filter-out comments from those lines.
START_COMMENT = \#
MOZCONFIG_OUT_FILTERED := $(filter-out $(START_COMMENT)%,$(MOZCONFIG_OUT_LINES))
ifdef AUTOCLOBBER
export AUTOCLOBBER=1
@ -175,13 +187,35 @@ build::
include $(TOPSRCDIR)/config/makefiles/makeutils.mk
include $(TOPSRCDIR)/config/makefiles/autotargets.mk
# Create a makefile containing the mk_add_options values from mozconfig,
# but only do so when OBJDIR is defined (see further above).
ifdef MOZ_BUILD_PROJECTS
ifdef MOZ_CURRENT_PROJECT
WANT_MOZCONFIG_MK = 1
else
WANT_MOZCONFIG_MK =
endif
else
WANT_MOZCONFIG_MK = 1
endif
ifdef WANT_MOZCONFIG_MK
# For now, only output "export" lines from mozconfig2client-mk output.
$(OBJDIR)/.mozconfig.mk: $(FOUND_MOZCONFIG) $(call mkdir_deps,$(OBJDIR))
( $(foreach line,$(filter export||%,$(MOZCONFIG_OUT_LINES)), echo "$(subst ||, ,$(line))";) ) > $@
# Include that makefile so that it is created. This should not actually change
# the environment since MOZCONFIG_CONTENT, which MOZCONFIG_OUT_LINES derives
# from, has already been eval'ed.
-include $(OBJDIR)/.mozconfig.mk
endif
# Print out any options loaded from mozconfig.
all realbuild clean depend distclean export libs install realclean::
@if test -f .mozconfig.out; then \
cat .mozconfig.out; \
rm -f .mozconfig.out; \
else true; \
fi
ifneq (,$(strip $(MOZCONFIG_OUT_FILTERED)))
$(info Adding client.mk options from $(FOUND_MOZCONFIG):)
$(foreach line,$(MOZCONFIG_OUT_FILTERED),$(info $(NULL) $(NULL) $(NULL) $(NULL) $(subst ||, ,$(line))))
endif
# Windows equivalents
build_all: build

View File

@ -27,6 +27,8 @@ ifndef INCLUDED_AUTOCONF_MK
include $(DEPTH)/config/autoconf.mk
endif
-include $(DEPTH)/.mozconfig.mk
space = $(NULL) $(NULL)
# Include defs.mk files that can be found in $(srcdir)/$(DEPTH),

View File

@ -27,6 +27,8 @@ ifndef INCLUDED_AUTOCONF_MK
include $(DEPTH)/config/autoconf.mk
endif
-include $(DEPTH)/.mozconfig.mk
space = $(NULL) $(NULL)
# Include defs.mk files that can be found in $(srcdir)/$(DEPTH),