diff --git a/Makefile.in b/Makefile.in index c5e6c31d2d6..43d3c673222 100644 --- a/Makefile.in +++ b/Makefile.in @@ -31,7 +31,7 @@ DIST_GARBAGE = config.cache config.log config.status* config-defs.h \ .mozconfig.mk ifndef MOZ_PROFILE_USE -buildid.h: FORCE +buildid.h source-repo.h: FORCE endif ifdef JS_STANDALONE @@ -315,12 +315,6 @@ ifdef SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE else $(SHELL) $(topsrcdir)/toolkit/crashreporter/tools/upload_symbols.sh $(SYMBOL_INDEX_NAME) '$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip' endif - -# MOZ_SOURCE_STAMP is defined in package-name.mk with a deferred assignment. -# exporting it makes make run its $(shell) command for each invoked submake, -# so transform it to an immediate assignment. -MOZ_SOURCE_STAMP := $(MOZ_SOURCE_STAMP) -export MOZ_SOURCE_STAMP endif .PHONY: update-packaging diff --git a/b2g/app/Makefile.in b/b2g/app/Makefile.in index 456034d92bc..6b50b87f72b 100644 --- a/b2g/app/Makefile.in +++ b/b2g/app/Makefile.in @@ -2,9 +2,6 @@ # 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/. -USE_RCS_MK := 1 -include $(topsrcdir)/config/makefiles/rcs.mk - # Make sure the standalone glue doesn't try to get libxpcom.so from b2g/app. NSDISTMODE = copy diff --git a/build/Makefile.in b/build/Makefile.in index 7b225eb3487..5c8d74f4cb2 100644 --- a/build/Makefile.in +++ b/build/Makefile.in @@ -10,19 +10,6 @@ ifdef MOZ_APP_BASENAME APP_INI_DEPS = $(topsrcdir)/config/milestone.txt APP_INI_DEPS += $(DEPTH)/config/autoconf.mk - -MOZ_SOURCE_STAMP := $(firstword $(shell cd $(topsrcdir)/$(MOZ_BUILD_APP)/.. && hg parent --template='{node}\n' 2>/dev/null)) -ifdef MOZ_SOURCE_STAMP -DEFINES += -DMOZ_SOURCE_STAMP='$(MOZ_SOURCE_STAMP)' -endif - -ifdef MOZ_INCLUDE_SOURCE_INFO -source_repo ?= $(call getSourceRepo,$(topsrcdir)/$(MOZ_BUILD_APP)/..) -ifneq (,$(source_repo)) - DEFINES += -DMOZ_SOURCE_REPO='$(source_repo)' -endif -endif - endif # NOTE: Keep .gdbinit in the topsrcdir for people who run gdb from the topsrcdir. diff --git a/build/application.ini b/build/application.ini index d09090d3e40..6d27b409730 100644 --- a/build/application.ini +++ b/build/application.ini @@ -16,6 +16,7 @@ #endif #filter substitution #include @TOPOBJDIR@/buildid.h +#include @TOPOBJDIR@/source-repo.h [App] Vendor=@MOZ_APP_VENDOR@ Name=@MOZ_APP_BASENAME@ diff --git a/build/variables.py b/build/variables.py index e22de41392c..77ffba0751e 100644 --- a/build/variables.py +++ b/build/variables.py @@ -5,6 +5,7 @@ from __future__ import print_function, unicode_literals import os +import subprocess import sys from datetime import datetime @@ -19,6 +20,53 @@ def buildid_header(output): output.write("#define MOZ_BUILDID %s\n" % buildid) +def get_program_output(*command): + try: + with open(os.devnull) as stderr: + return subprocess.check_output(command, stderr=stderr) + except: + return '' + + +def get_hg_info(workdir): + repo = get_program_output('hg', '-R', workdir, 'path', 'default') + if repo: + repo = repo.strip() + if repo.startswith('ssh://'): + repo = 'https://' + repo[6:] + repo = repo.rstrip('/') + + changeset = get_program_output( + 'hg', '-R', workdir, 'parent', '--template={node}') + + return repo, changeset + + +def source_repo_header(output): + # We allow the source repo and changeset to be specified via the + # environment (see configure) + import buildconfig + repo = buildconfig.substs.get('MOZ_SOURCE_REPO') + changeset = buildconfig.substs.get('MOZ_SOURCE_CHANGESET') + source = '' + + if bool(repo) != bool(changeset): + raise Exception('MOZ_SOURCE_REPO and MOZ_SOURCE_CHANGESET both must ' + 'be set (or not set).') + + if not repo: + if os.path.exists(os.path.join(buildconfig.topsrcdir, '.hg')): + repo, changeset = get_hg_info(buildconfig.topsrcdir) + + if changeset: + output.write('#define MOZ_SOURCE_STAMP %s\n' % changeset) + + if repo and buildconfig.substs.get('MOZ_INCLUDE_SOURCE_INFO'): + source = '%s/rev/%s' % (repo, changeset) + output.write('#define MOZ_SOURCE_REPO %s\n' % repo) + output.write('#define MOZ_SOURCE_URL %s\n' % source) + + def main(args): if (len(args)): func = globals().get(args[0]) diff --git a/config/makefiles/makeutils.mk b/config/makefiles/makeutils.mk index 07961c797c0..95c7791a4b3 100644 --- a/config/makefiles/makeutils.mk +++ b/config/makefiles/makeutils.mk @@ -117,9 +117,5 @@ ifdef USE_AUTOTARGETS_MK # mkdir_deps include $(topORerr)/config/makefiles/autotargets.mk endif -ifdef USE_RCS_MK - include $(topORerr)/config/makefiles/rcs.mk -endif - ## copy(src, dst): recursive copy copy_dir = (cd $(1)/. && $(TAR) $(TAR_CREATE_FLAGS) - .) | (cd $(2)/. && tar -xf -) diff --git a/config/makefiles/rcs.mk b/config/makefiles/rcs.mk deleted file mode 100644 index b9acada47b3..00000000000 --- a/config/makefiles/rcs.mk +++ /dev/null @@ -1,54 +0,0 @@ -# -*- 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/. -# - -ifdef USE_RCS_MK #{ - -ifndef INCLUDED_RCS_MK #{ - -MOZ_RCS_TYPE_HG ?= $(notdir $(wildcard $(topsrcdir)/.hg)) -MOZ_RCS_TYPE_GIT ?= $(notdir $(wildcard $(topsrcdir)/.git)) - - -########################################################################### -# HAVE_MERCURIAL_RCS -########################################################################### -ifeq (.hg,$(MOZ_RCS_TYPE_HG)) #{ - -# 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))) - -# return: http://hg.mozilla.org/mozilla-central -FUNC_getSourceRepo = \ - $(strip \ - $(patsubst %/,%,\ - $(patsubst ssh://%,http://%,\ - $(firstword $(shell $(getargv) showconfig paths.default))\ - ))) - -#} HAVE_MERCURIAL_RCS - -########################################################################### -# HAVE_GIT_RCS -########################################################################### -else ifeq (.git,$(MOZ_RCS_TYPE_GIT)) #{ - -GIT ?= git -getSourceRepo = \ - $(shell cd $(topsrcdir) && $(GIT) rev-parse --verify HEAD) - -endif #} HAVE_GIT_RCS - - -INCLUDED_RCS_MK := 1 -endif #} - -endif #} diff --git a/configure.in b/configure.in index aedfd392a0c..348cd0a46f7 100644 --- a/configure.in +++ b/configure.in @@ -8724,15 +8724,8 @@ fi # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to # explicitly set the repository and changeset information in. -if test "$MOZILLA_OFFICIAL"; then - if test -z "$MOZ_SOURCE_REPO" && test -z "$MOZ_SOURCE_CHANGESET" && test -d ${_topsrcdir}/.hg; then - MOZ_SOURCE_CHANGESET=`cd $_topsrcdir && hg parent --template='{node}'` - MOZ_SOURCE_REPO=`cd $_topsrcdir && hg showconfig paths.default | sed -e 's|^ssh://|http://|' -e 's|/$||'` - fi - SOURCE_REV_URL=$MOZ_SOURCE_REPO/rev/$MOZ_SOURCE_CHANGESET -fi -AC_SUBST(SOURCE_REV_URL) - +AC_SUBST(MOZ_SOURCE_REPO) +AC_SUBST(MOZ_SOURCE_CHANGESET) AC_SUBST(MOZ_INCLUDE_SOURCE_INFO) if test "$MOZ_TELEMETRY_REPORTING"; then diff --git a/moz.build b/moz.build index da220fad781..e2d50c4f66b 100644 --- a/moz.build +++ b/moz.build @@ -33,13 +33,16 @@ if not CONFIG['JS_STANDALONE']: EXPORTS += [ '!buildid.h', '!mozilla-config.h', + '!source-repo.h', ] GENERATED_FILES += [ 'buildid.h', + 'source-repo.h', ] GENERATED_FILES['buildid.h'].script = 'build/variables.py:buildid_header' + GENERATED_FILES['source-repo.h'].script = 'build/variables.py:source_repo_header' DIRS += [ 'build', diff --git a/toolkit/components/telemetry/Makefile.in b/toolkit/components/telemetry/Makefile.in index deea2264c16..52016707ccc 100644 --- a/toolkit/components/telemetry/Makefile.in +++ b/toolkit/components/telemetry/Makefile.in @@ -3,9 +3,6 @@ # 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/. -USE_RCS_MK := 1 -include $(topsrcdir)/config/makefiles/rcs.mk - include $(topsrcdir)/config/rules.mk # This is so hacky. Waiting on bug 988938. diff --git a/toolkit/content/Makefile.in b/toolkit/content/Makefile.in index e42ed6dc725..0e0e6316dc7 100644 --- a/toolkit/content/Makefile.in +++ b/toolkit/content/Makefile.in @@ -3,24 +3,7 @@ # 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/. -USE_RCS_MK := 1 -include $(topsrcdir)/config/makefiles/makeutils.mk - DEFINES += \ -DCXXFLAGS='$(CXXFLAGS)' \ -DCPPFLAGS='$(CPPFLAGS)' \ $(NULL) - -MOZ_SOURCE_STAMP ?= $(shell hg -R $(topsrcdir) parent --template='{node}\n' 2>/dev/null) -ifdef MOZ_SOURCE_STAMP -DEFINES += -DSOURCE_CHANGESET='$(MOZ_SOURCE_STAMP)' -endif - -ifdef MOZ_INCLUDE_SOURCE_INFO -source_repo ?= $(call getSourceRepo) -ifneq (,$(filter http%,$(source_repo))) - DEFINES += -DSOURCE_REPO='$(source_repo)' -else ifneq (,$(strip $(source_repo))) - DEFINES += -DSOURCE_GIT_COMMIT='$(source_repo)' -endif -endif diff --git a/toolkit/content/buildconfig.html b/toolkit/content/buildconfig.html index c2480d17886..40f71b850ed 100644 --- a/toolkit/content/buildconfig.html +++ b/toolkit/content/buildconfig.html @@ -4,6 +4,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # #filter substitution +#include @TOPOBJDIR@/source-repo.h
@@ -18,14 +19,9 @@Built from @SOURCE_REPO@/rev/@SOURCE_CHANGESET@
-#endif -#elifdef SOURCE_GIT_COMMIT -Built from git commit @SOURCE_GIT_COMMIT@
+Built from @MOZ_SOURCE_URL@
#endif