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 @@

about:buildconfig

-#ifdef SOURCE_REPO -#ifdef SOURCE_CHANGESET +#ifdef MOZ_SOURCE_URL

Source

-

Built from @SOURCE_REPO@/rev/@SOURCE_CHANGESET@

-#endif -#elifdef SOURCE_GIT_COMMIT -

Source

-

Built from git commit @SOURCE_GIT_COMMIT@

+

Built from @MOZ_SOURCE_URL@

#endif

Build platform

diff --git a/toolkit/content/moz.build b/toolkit/content/moz.build index 0fb97e3e7c3..7d98435b0a4 100644 --- a/toolkit/content/moz.build +++ b/toolkit/content/moz.build @@ -31,3 +31,5 @@ with Files('customizeToolbar.*'): with Files('widgets/*'): BUG_COMPONENT = ('Toolkit', 'XUL Widgets') + +DEFINES['TOPOBJDIR'] = TOPOBJDIR diff --git a/toolkit/modules/AppConstants.jsm b/toolkit/modules/AppConstants.jsm index 5ceb990c6fc..51c33299e49 100644 --- a/toolkit/modules/AppConstants.jsm +++ b/toolkit/modules/AppConstants.jsm @@ -1,4 +1,5 @@ #filter substitution +#include @TOPOBJDIR@/source-repo.h /* 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/. */ @@ -308,7 +309,10 @@ this.AppConstants = Object.freeze({ // URL to the hg revision this was built from (e.g. // "https://hg.mozilla.org/mozilla-central/rev/6256ec9113c1") // On unofficial builds, this is an empty string. - SOURCE_REVISION_URL: "@SOURCE_REV_URL@", +#ifndef MOZ_SOURCE_URL +#define MOZ_SOURCE_URL +#endif + SOURCE_REVISION_URL: "@MOZ_SOURCE_URL@", MOZ_NUWA_PROCESS: #ifdef MOZ_NUWA_PROCESS diff --git a/toolkit/modules/moz.build b/toolkit/modules/moz.build index b8ff635bc2d..349aa292b2f 100644 --- a/toolkit/modules/moz.build +++ b/toolkit/modules/moz.build @@ -118,8 +118,7 @@ for var in ('ANDROID_PACKAGE_NAME', 'MOZ_WIDGET_TOOLKIT', 'DLL_PREFIX', 'DLL_SUFFIX', - 'DEBUG_JS_MODULES', - 'SOURCE_REV_URL'): + 'DEBUG_JS_MODULES'): DEFINES[var] = CONFIG[var] for var in ('MOZ_TOOLKIT_SEARCH', @@ -128,3 +127,5 @@ for var in ('MOZ_TOOLKIT_SEARCH', 'MOZ_UPDATER'): if CONFIG[var]: DEFINES[var] = True + +DEFINES['TOPOBJDIR'] = TOPOBJDIR diff --git a/toolkit/mozapps/installer/package-name.mk b/toolkit/mozapps/installer/package-name.mk index d3f4b194bfe..04d0b3a7c9c 100644 --- a/toolkit/mozapps/installer/package-name.mk +++ b/toolkit/mozapps/installer/package-name.mk @@ -156,16 +156,6 @@ ifndef INCLUDED_RCS_MK include $(MOZILLA_DIR)/config/makefiles/makeutils.mk endif -MOZ_SOURCE_STAMP = $(firstword $(shell hg -R $(MOZILLA_DIR) parent --template="{node}\n" 2>/dev/null)) - -########################################################################### -# bug: 746277 - preserve existing functionality. -# MOZILLA_DIR="": cd $(SPACE); hg # succeeds if ~/.hg exists -########################################################################### -ifdef MOZ_INCLUDE_SOURCE_INFO -MOZ_SOURCE_REPO = $(call getSourceRepo,$(MOZILLA_DIR)$(NULL) $(NULL)) -endif - MOZ_SOURCESTAMP_FILE = $(DIST)/$(PKG_PATH)/$(MOZ_INFO_BASENAME).txt MOZ_BUILDINFO_FILE = $(DIST)/$(PKG_PATH)/$(MOZ_INFO_BASENAME).json MOZ_MOZINFO_FILE = $(DIST)/$(PKG_PATH)/$(MOZ_INFO_BASENAME).mozinfo.json diff --git a/toolkit/mozapps/installer/packager.mk b/toolkit/mozapps/installer/packager.mk index 1b25ca89d04..a35a9495315 100644 --- a/toolkit/mozapps/installer/packager.mk +++ b/toolkit/mozapps/installer/packager.mk @@ -96,8 +96,8 @@ GARBAGE += make-package make-sourcestamp-file:: $(NSINSTALL) -D $(DIST)/$(PKG_PATH) @echo '$(BUILDID)' > $(MOZ_SOURCESTAMP_FILE) -ifdef MOZ_SOURCE_REPO - @echo '$(MOZ_SOURCE_REPO)/rev/$(MOZ_SOURCE_STAMP)' >> $(MOZ_SOURCESTAMP_FILE) +ifdef MOZ_INCLUDE_SOURCE_INFO + @awk '$$2 == "MOZ_SOURCE_URL" {print $$3}' $(DEPTH)/source-repo.h >> $(MOZ_SOURCESTAMP_FILE) endif .PHONY: make-buildinfo-file @@ -105,8 +105,8 @@ make-buildinfo-file: $(PYTHON) $(MOZILLA_DIR)/toolkit/mozapps/installer/informulate.py \ $(MOZ_BUILDINFO_FILE) \ BUILDID=$(BUILDID) \ - $(addprefix MOZ_SOURCE_REPO=,MOZ_SOURCE_REPO=$(MOZ_SOURCE_REPO)) \ - MOZ_SOURCE_STAMP=$(MOZ_SOURCE_STAMP) \ + $(addprefix MOZ_SOURCE_REPO=,MOZ_SOURCE_REPO=$(shell awk '$$2 == "MOZ_SOURCE_REPO" {print $$3}' $(DEPTH)/source-repo.h)) \ + MOZ_SOURCE_STAMP=$(shell awk '$$2 == "MOZ_SOURCE_STAMP" {print $$3}' $(DEPTH)/source-repo.h) \ MOZ_PKG_PLATFORM=$(MOZ_PKG_PLATFORM) .PHONY: make-mozinfo-file diff --git a/toolkit/mozapps/installer/upload-files.mk b/toolkit/mozapps/installer/upload-files.mk index 9cfe53c11c3..036fa26a14f 100644 --- a/toolkit/mozapps/installer/upload-files.mk +++ b/toolkit/mozapps/installer/upload-files.mk @@ -198,8 +198,8 @@ RPM_CMD = \ --define 'moz_numeric_app_version $(MOZ_NUMERIC_APP_VERSION)' \ --define 'moz_rpm_release $(MOZ_RPM_RELEASE)' \ --define 'buildid $(BUILDID)' \ - $(if $(MOZ_SOURCE_REPO),--define 'moz_source_repo $(MOZ_SOURCE_REPO)') \ - --define 'moz_source_stamp $(MOZ_SOURCE_STAMP)' \ + --define 'moz_source_repo $(shell awk '$$2 == "MOZ_SOURCE_REPO" {print $$3}' $(DEPTH)/source-repo.h)' \ + --define 'moz_source_stamp $(shell awk '$$2 == "MOZ_SOURCE_STAMP" {print $$3}' $(DEPTH)/source-repo.h)' \ --define 'moz_branding_directory $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)' \ --define '_topdir $(RPMBUILD_TOPDIR)' \ --define '_rpmdir $(RPMBUILD_RPMDIR)' \ diff --git a/toolkit/xre/Makefile.in b/toolkit/xre/Makefile.in index 9030fc41fc3..225dc3bbb6e 100644 --- a/toolkit/xre/Makefile.in +++ b/toolkit/xre/Makefile.in @@ -5,29 +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/. -USE_RCS_MK=1 -include $(topsrcdir)/config/makefiles/makeutils.mk - milestone_txt = $(topsrcdir)/config/milestone.txt include $(topsrcdir)/config/rules.mk -MOZ_SOURCE_STAMP ?= $(firstword $(shell hg -R $(topsrcdir) parent --template='{node}\n' 2>/dev/null)) -ifneq (,$(strip $(MOZ_SOURCE_STAMP))) - - DEFINES += -DMOZ_SOURCE_STAMP=$(MOZ_SOURCE_STAMP) - - ifdef MOZ_INCLUDE_SOURCE_INFO - source_repo := $(call getSourceRepo) - - # extra sanity check for old versions of hg, no showconfig support - ifneq (,$(filter http%,$(source_repo))) - DEFINES += -DMOZ_SOURCE_REPO=$(source_repo) - endif - endif - -endif # MOZ_SOURCE_STAMP - MOZ_BUILDID := $(shell awk '{print $$3}' $(DEPTH)/buildid.h) $(call errorIfEmpty,GRE_MILESTONE MOZ_BUILDID) diff --git a/toolkit/xre/platform.ini b/toolkit/xre/platform.ini index 0b337554ab3..01c8b741a1c 100644 --- a/toolkit/xre/platform.ini +++ b/toolkit/xre/platform.ini @@ -5,6 +5,7 @@ #endif #filter substitution #include @TOPOBJDIR@/buildid.h +#include @TOPOBJDIR@/source-repo.h [Build] BuildID=@MOZ_BUILDID@ Milestone=@GRE_MILESTONE@