bug 746277: replace hg shell pipelines with make logic
☠☠ backed out by 06e7df3a8209 ☠ ☠
authorJoey Armstrong <joey@mozilla.com>
Wed, 16 May 2012 15:09:00 -0400
changeset 97782 6a386d638a1ac6e7f911b3908b1987e4be6b0b46
parent 97781 d6f341e77b68172e828f23701e1e32ae6768ee97
child 97783 93e55dcf0e2ee8fcd9d21def6d9787317856e1ac
push id22999
push useremorley@mozilla.com
push dateThu, 28 Jun 2012 08:03:15 +0000
treeherdermozilla-central@bf8f2961d0cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs746277
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 746277: replace hg shell pipelines with make logic
b2g/app/Makefile.in
build/Makefile.in
config/makefiles/makeutils.mk
config/makefiles/rcs.mk
config/makefiles/test/Makefile.in
config/makefiles/test/check-rcs.mk
config/rules.mk
js/src/config/makefiles/makeutils.mk
js/src/config/makefiles/rcs.mk
js/src/config/rules.mk
toolkit/content/Makefile.in
toolkit/xre/Makefile.in
--- a/b2g/app/Makefile.in
+++ b/b2g/app/Makefile.in
@@ -3,16 +3,18 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 DEPTH     = ../..
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
+USE_RCS_MK=1
+include $(topsrcdir)/config/makefiles/makeutils.mk
 
 PREF_JS_EXPORTS = $(srcdir)/b2g.js
 
 ifndef LIBXUL_SDK
 PROGRAM=$(MOZ_APP_NAME)$(BIN_SUFFIX)
 
 CPPSRCS = nsBrowserApp.cpp
 
@@ -50,25 +52,19 @@ include $(topsrcdir)/config/rules.mk
 APP_ICON = b2g
 
 DEFINES += \
   -DAPP_NAME=$(MOZ_APP_NAME) \
   -DAPP_VERSION=$(MOZ_APP_VERSION) \
   -DMOZ_UPDATER=$(MOZ_UPDATER) \
   $(NULL)
 
-# strip a trailing slash from the repo URL because it's not always present,
-# and we want to construct a working URL in buildconfig.html
-# make+shell+sed = awful
-_dollar=$$
-SOURCE_REPO := $(shell cd $(srcdir)/.. && hg showconfig paths.default 2>/dev/null | head -n1 | sed -e "s/^ssh:/http:/" -e "s/\/$(_dollar)//" )
-# extra sanity check for old versions of hg
-# that don't support showconfig
-ifeq (http,$(patsubst http%,http,$(SOURCE_REPO)))
-DEFINES += -DMOZ_SOURCE_REPO="$(SOURCE_REPO)"
+source_repo := $(call getSourceRepo,$(srcdir)/..)
+ifneq (,$(filter http%,$(source_repo)))
+  DEFINES += -DMOZ_SOURCE_REPO="$(source_repo)"
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 REDIT_PATH = $(LIBXUL_DIST)/bin
 endif
 
 APP_BINARY = $(MOZ_APP_NAME)$(BIN_SUFFIX)
 
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -4,16 +4,18 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 DEPTH		= ..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
+USE_RCS_MK=1
+include $(topsrcdir)/config/makefiles/makeutils.mk
 
 MODULE = build
 
 ifeq (,$(filter WINNT OS2,$(OS_ARCH)))
 DIRS		= unix
 endif
 
 ifeq (WINNT,$(OS_ARCH))
@@ -61,20 +63,19 @@ DEFINES += -DGRE_MILESTONE=$(GRE_MILESTO
 DEFINES += -DMOZ_APP_VERSION="$(MOZ_APP_VERSION)"
 APP_INI_DEPS += $(DEPTH)/config/autoconf.mk
 
 MOZ_SOURCE_STAMP := $(firstword $(shell cd $(topsrcdir)/$(MOZ_BUILD_APP)/.. && hg parent --template="{node|short}\n" 2>/dev/null))
 ifdef MOZ_SOURCE_STAMP
 DEFINES += -DMOZ_SOURCE_STAMP="$(MOZ_SOURCE_STAMP)"
 endif
 
-_dollar=$$
-SOURCE_REPO := $(shell cd $(topsrcdir)/$(MOZ_BUILD_APP)/.. && hg showconfig paths.default 2>/dev/null | head -n1 | sed -e "s/^ssh:/http:/" -e "s/\/$(_dollar)//" )
-ifdef SOURCE_REPO
-DEFINES += -DMOZ_SOURCE_REPO="$(SOURCE_REPO)"
+source_repo := $(call getSourceRepo,$(topsrcdir)/$(MOZ_BUILD_APP)/..)
+ifneq (,$(source_repo))
+  DEFINES += -DMOZ_SOURCE_REPO="$(source_repo)"
 endif
 
 DEFINES += \
   -DMOZ_APP_BASENAME="$(MOZ_APP_BASENAME)" \
   -DMOZ_APP_VENDOR="$(MOZ_APP_VENDOR)" \
   -DMOZ_APP_ID="$(MOZ_APP_ID)" \
   -DMAR_CHANNEL_ID="$(MAR_CHANNEL_ID)" \
   -DACCEPTED_MAR_CHANNEL_IDS="$(ACCEPTED_MAR_CHANNEL_IDS)" \
--- a/config/makefiles/makeutils.mk
+++ b/config/makefiles/makeutils.mk
@@ -101,14 +101,20 @@ checkIfEmpty =$(foreach var,$(wordlist 2
 # Usage: $(call errorIfEmpty,foo NULL bar)
 errorIfEmpty =$(call checkIfEmpty,error $(argv))
 warnIfEmpty  =$(call checkIfEmpty,warning $(argv))
 
 endif #}
 
 ###########################################################################
 ## Common makefile library loader
+##   USE_AUTOTARGETS_MK - mkdir_deps directory creation
+##   USE_RCS_MK         - revision control functions
 ###########################################################################
 topORerr =$(if $(topsrcdir),$(topsrcdir),$(error topsrcdir is not defined))
 
 ifdef USE_AUTOTARGETS_MK # mkdir_deps
   include $(topORerr)/config/makefiles/autotargets.mk
 endif
+
+ifdef USE_RCS_MK
+  include $(topORerr)/config/makefiles/rcs.mk
+endif
new file mode 100644
--- /dev/null
+++ b/config/makefiles/rcs.mk
@@ -0,0 +1,64 @@
+# -*- makefile -*-
+# vim:set ts=8 sw=8 sts=8 noet:
+#
+# 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/.
+#
+
+###########################################################################
+## Accessor functions:
+##   $(call getRcsType): .git, .hg
+##   $(call getSourceRepo) == http://hg.mozilla.org/mozilla-central
+###########################################################################
+
+ifdef USE_RCS_MK #{
+ifndef INCLUDED_RCS_MK #{
+
+# Determine revision control system in use: .hg, .git, etc
+# Call getRcsType() at least once, $(RCS_TYPE) will be defined
+#
+define FUNC_rcstype =
+  MOZ_RCS_TYPE := $(notdir $(firstword \
+    $(wildcard \
+      $(or $(1),$(topsrcdir))/.hg\
+      $(or $(1),$(topsrcdir))/.git\
+    ))
+  )
+endef
+getRcsType = $(or $(MOZ_RCS_TYPE),$(eval $(call FUNC_rcstype))$(MOZ_RCS_TYPE))
+MOZ_RCS_TYPE := $(call getRcsType)
+
+###########################################################################
+# HAVE_MERCURIAL_RCS (todo: include rcs.$(MOZ_RCS_TYPE).mk git, hg)
+###########################################################################
+ifneq (,$(findstring .hg,$(MOZ_RCS_TYPE)))
+
+# Intent: Retrieve the http:// repository path for a directory.
+# Usage: $(call getSourceRepo[,repo_dir|args])
+# Args:
+#   path (optional): repository to query.  Defaults to $(topsrcdir)
+getSourceRepo =$(call FUNC_getSourceRepo,$(if $(1),cd $(1) && hg,hg --repository $(topsrcdir)))
+
+# http://hg.mozilla.org/mozilla-central
+FUNC_getSourceRepo=\
+  $(patsubst %/,%,\
+  $(patsubst ssh://%,http://%,\
+  $(strip \
+    $(firstword $(shell $(getargv) showconfig paths.default))\
+    )))
+
+endif #} HAVE_MERCURIAL_RCS
+
+###########################################################################
+# HAVE_GIT_RCS
+###########################################################################
+ifneq (,$(findstring .git,$(MOZ_RCS_TYPE)))
+  # git://github.com/mozilla/...
+  getSourceRepo = $(firstword $(shell $(getargv) git config --get remote.origin.url))
+endif #} HAVE_GIT_RCS
+
+INCLUDED_RCS_MK=1
+endif #}
+
+endif #}
--- a/config/makefiles/test/Makefile.in
+++ b/config/makefiles/test/Makefile.in
@@ -14,22 +14,24 @@ include $(DEPTH)/config/autoconf.mk
 USE_AUTOTARGETS_MK  = 1
 MAKEUTILS_UNIT_TEST = 1
 include $(topsrcdir)/config/makefiles/makeutils.mk
 
 dir-ts = .deps/test
 check-arglist        = $(dir-ts)/arglist.ts
 check-autotargets    = $(dir-ts)/autotargets_mk.ts
 check-export-targets = $(dir-ts)/export-targets-mk.ts
+check-rcs-mk         = $(dir-ts)/rcs-mk.ts
 check-XinY           = $(dir-ts)/check_XinY_mk.ts
 check-xpidl          = $(dir-ts)/xpidl-mk.ts
 check-tests =\
   $(check-arglist) \
   $(check-autotargets) \
   $(check-export-targets) \
+  $(check-rcs-mk) \
   $(check-XinY) \
   $(check-xpidl) \
   $(NULL)
 
 
 ##------------------_##
 ##---]  TARGETS  [---##
 ##------------------_##
@@ -119,16 +121,31 @@ check-export-targets-preqs=\
 
 # include then test
 checkup: $(eval include $(srcdir)/check-export-targets.mk)
 
 $(check-export-targets): $(check-export-targets-preqs)
 	@$(TOUCH) $@
 # </CHECK: export-targets.mk>
 
+
+###########################################################################
+# <CHECK: rcs.mk>
+check-rcs-preqs=\
+  $(call mkdir_deps,$(dir-ts)) \
+  $(topsrcdir)/config/makefiles/rcs.mk \
+  $(srcdir)/check-rcs.mk \
+  $(NULL)
+
+$(check-rcs-mk): $(check-rcs-preqs)
+	$(MAKE) --no-print-directory -f $(srcdir)/check-rcs.mk topsrcdir=$(topsrcdir)
+	$(TOUCH) $@
+# </CHECK: rcs.mk>
+
+
 ###########################################################################
 ##{ <CHECK: xpidl.mk>
 check-xpidl-preqs=\
   $(call mkdir_deps,$(dir-ts)) \
   $(topsrcdir)/config/makefiles/makeutils.mk \
   $(topsrcdir)/config/makefiles/xpidl.mk \
   $(srcdir)/check-xpidl.mk \
   $(NULL)
new file mode 100644
--- /dev/null
+++ b/config/makefiles/test/check-rcs.mk
@@ -0,0 +1,40 @@
+# -*- makefile -*-
+#
+# 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/.
+
+ifdef VERBOSE
+  $(warning loading test)
+endif
+
+include $(topsrcdir)/config/makefiles/makeutils.mk
+
+USE_RCS_MK = 1
+include $(topsrcdir)/config/makefiles/rcs.mk
+
+$(call requiredfunction,getargv)
+$(call requiredfunction,getRcsType)
+$(call errorIfEmpty,INCLUDED_RCS_MK)
+
+saved := $(MOZ_RCS_TYPE)
+undefine MOZ_RCS_TYPE # Clear to force value gathering
+type = $(call getRcsType)
+ifneq ($(type),$(saved))
+  $(error getRcsType[$(type)] != MOZ_RCS_TYPE[$(saved)])
+endif
+
+# Limit testing to systems getSourceRepo() has been written for
+ifneq (,$(MOZ_RCS_TYPE))
+  $(call requiredfunction,getSourceRepo)
+
+  repo := $(call getSourceRepo)
+  $(if $(eq $(repo),$(NULL)),$(error getSourceRepo() failed))
+
+  repo := $(call getSourceRepo,../..)
+  $(if $(eq $(repo),$(NULL)),$(error getSourceRepo(../..) failed))
+endif
+
+
+compile-time-tests:
+	@true
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -1759,13 +1759,12 @@ libs export::
 
 default all::
 	if test -d $(DIST)/bin ; then touch $(DIST)/bin/.purgecaches ; fi
 
 
 #############################################################################
 # Derived targets and dependencies
 
-include $(topsrcdir)/config/makefiles/autotargets.mk
 ifneq ($(NULL),$(AUTO_DEPS))
   default all libs tools export:: $(AUTO_DEPS)
 endif
 
--- a/js/src/config/makefiles/makeutils.mk
+++ b/js/src/config/makefiles/makeutils.mk
@@ -101,14 +101,20 @@ checkIfEmpty =$(foreach var,$(wordlist 2
 # Usage: $(call errorIfEmpty,foo NULL bar)
 errorIfEmpty =$(call checkIfEmpty,error $(argv))
 warnIfEmpty  =$(call checkIfEmpty,warning $(argv))
 
 endif #}
 
 ###########################################################################
 ## Common makefile library loader
+##   USE_AUTOTARGETS_MK - mkdir_deps directory creation
+##   USE_RCS_MK         - revision control functions
 ###########################################################################
 topORerr =$(if $(topsrcdir),$(topsrcdir),$(error topsrcdir is not defined))
 
 ifdef USE_AUTOTARGETS_MK # mkdir_deps
   include $(topORerr)/config/makefiles/autotargets.mk
 endif
+
+ifdef USE_RCS_MK
+  include $(topORerr)/config/makefiles/rcs.mk
+endif
new file mode 100644
--- /dev/null
+++ b/js/src/config/makefiles/rcs.mk
@@ -0,0 +1,64 @@
+# -*- makefile -*-
+# vim:set ts=8 sw=8 sts=8 noet:
+#
+# 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/.
+#
+
+###########################################################################
+## Accessor functions:
+##   $(call getRcsType): .git, .hg
+##   $(call getSourceRepo) == http://hg.mozilla.org/mozilla-central
+###########################################################################
+
+ifdef USE_RCS_MK #{
+ifndef INCLUDED_RCS_MK #{
+
+# Determine revision control system in use: .hg, .git, etc
+# Call getRcsType() at least once, $(RCS_TYPE) will be defined
+#
+define FUNC_rcstype =
+  MOZ_RCS_TYPE := $(notdir $(firstword \
+    $(wildcard \
+      $(or $(1),$(topsrcdir))/.hg\
+      $(or $(1),$(topsrcdir))/.git\
+    ))
+  )
+endef
+getRcsType = $(or $(MOZ_RCS_TYPE),$(eval $(call FUNC_rcstype))$(MOZ_RCS_TYPE))
+MOZ_RCS_TYPE := $(call getRcsType)
+
+###########################################################################
+# HAVE_MERCURIAL_RCS (todo: include rcs.$(MOZ_RCS_TYPE).mk git, hg)
+###########################################################################
+ifneq (,$(findstring .hg,$(MOZ_RCS_TYPE)))
+
+# Intent: Retrieve the http:// repository path for a directory.
+# Usage: $(call getSourceRepo[,repo_dir|args])
+# Args:
+#   path (optional): repository to query.  Defaults to $(topsrcdir)
+getSourceRepo =$(call FUNC_getSourceRepo,$(if $(1),cd $(1) && hg,hg --repository $(topsrcdir)))
+
+# http://hg.mozilla.org/mozilla-central
+FUNC_getSourceRepo=\
+  $(patsubst %/,%,\
+  $(patsubst ssh://%,http://%,\
+  $(strip \
+    $(firstword $(shell $(getargv) showconfig paths.default))\
+    )))
+
+endif #} HAVE_MERCURIAL_RCS
+
+###########################################################################
+# HAVE_GIT_RCS
+###########################################################################
+ifneq (,$(findstring .git,$(MOZ_RCS_TYPE)))
+  # git://github.com/mozilla/...
+  getSourceRepo = $(firstword $(shell $(getargv) git config --get remote.origin.url))
+endif #} HAVE_GIT_RCS
+
+INCLUDED_RCS_MK=1
+endif #}
+
+endif #}
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -1759,13 +1759,12 @@ libs export::
 
 default all::
 	if test -d $(DIST)/bin ; then touch $(DIST)/bin/.purgecaches ; fi
 
 
 #############################################################################
 # Derived targets and dependencies
 
-include $(topsrcdir)/config/makefiles/autotargets.mk
 ifneq ($(NULL),$(AUTO_DEPS))
   default all libs tools export:: $(AUTO_DEPS)
 endif
 
--- a/toolkit/content/Makefile.in
+++ b/toolkit/content/Makefile.in
@@ -4,16 +4,19 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 
 DEPTH     = ../..
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
+USE_RCS_MK=1
+include $(topsrcdir)/config/makefiles/makeutils.mk
+
 CHROME_DEPS = buildconfig.html
 
 include $(DEPTH)/config/autoconf.mk
 
 DEFINES += \
   -Dtarget="$(target)" \
   -Dac_configure_args="$(ac_configure_args)" \
   -DCC="$(CC)" \
@@ -31,25 +34,19 @@ MOZ_SOURCE_STAMP ?= $(shell hg -R $(tops
 ifdef MOZ_SOURCE_STAMP
 DEFINES += -DSOURCE_CHANGESET="$(MOZ_SOURCE_STAMP)"
 endif
 
 ifeq (Android,$(OS_TARGET))
 DEFINES += -DANDROID_PACKAGE_NAME=$(ANDROID_PACKAGE_NAME)
 endif
 
-# strip a trailing slash from the repo URL because it's not always present,
-# and we want to construct a working URL in buildconfig.html
-# make+shell+sed = awful
-_dollar=$$
-SOURCE_REPO := $(shell cd $(topsrcdir) && hg showconfig paths.default 2>/dev/null | head -n1 | sed -e "s/^ssh:/http:/" -e "s/\/$(_dollar)//" )
-# extra sanity check for old versions of hg
-# that don't support showconfig
-ifeq (http,$(patsubst http%,http,$(SOURCE_REPO)))
-DEFINES += -DSOURCE_REPO="$(SOURCE_REPO)"
+source_repo := $(call getSourceRepo)
+ifneq (,$(filter http%,$(source_repo)))
+  DEFINES += -DSOURCE_REPO="$(source_repo)"
 endif
 
 BUILD_HOSTNAME = $(shell hostname -s || hostname)
 DEFINES += -DBUILD_HOSTNAME="$(BUILD_HOSTNAME)"
 
 ifdef MOZ_TOOLKIT_SEARCH
 DEFINES += -DMOZ_TOOLKIT_SEARCH
 endif
--- a/toolkit/xre/Makefile.in
+++ b/toolkit/xre/Makefile.in
@@ -6,16 +6,18 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 DEPTH     = ../..
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
+USE_RCS_MK=1
+include $(topsrcdir)/config/makefiles/makeutils.mk
 
 milestone_txt = $(topsrcdir)/config/milestone.txt
 
 MODULE = xulapp
 LIBRARY_NAME = xulapp_s
 LIBXUL_LIBRARY = 1
 
 FORCE_STATIC_LIB = 1
@@ -217,30 +219,23 @@ DEFINES += -DHAVE_USR_LIB64_DIR
 endif
 endif
 
 MOZ_SOURCE_STAMP ?= $(firstword $(shell hg -R $(topsrcdir) parent --template="{node|short}\n" 2>/dev/null))
 ifdef MOZ_SOURCE_STAMP
 
   INIARGS = --sourcestamp=$(MOZ_SOURCE_STAMP)
 
-  # strip a trailing slash from the repo URL because it's not always present,
-  # and we want to construct a working URL in buildconfig.html
-  SOURCE_REPO := $(firstword $(shell hg --repository $(topsrcdir) showconfig paths.default 2>/dev/null))
-  SOURCE_REPO := $(strip $(SOURCE_REPO))
-  SOURCE_REPO := $(patsubst ssh://%,http://%,$(SOURCE_REPO))
-  SOURCE_REPO := $(patsubst %/,%,$(SOURCE_REPO))
-
   # command set should change based on revision control use.
   # warn for now in case (git, bzr, ...) is in use.
-  $(call warnIfEmpty,SOURCE_REPO) 
+  source_repo := $(call getSourceRepo)
 
   # extra sanity check for old versions of hg, no showconfig support
-  ifeq (http,$(patsubst http%,http,$(SOURCE_REPO)))
-    INIARGS += --sourcerepo=$(SOURCE_REPO)
+  ifneq (,$(filter http%,$(source_repo)))
+    INIARGS += --sourcerepo=$(source_repo)
   endif
 
 endif # MOZ_SOURCE_STAMP
 
 GRE_MILESTONE := $(strip $(lastword $(shell cat $(milestone_txt) 2>/dev/null)))
 GRE_BUILDID   := $(strip $(firstword $(shell cat $(DEPTH)/config/buildid 2>/dev/null)))
 $(call errorIfEmpty,GRE_MILESTONE GRE_BUILDID)