diff --git a/Makefile.in b/Makefile.in index c5e6c31d2d61a0b87a6e8def6da2fadf89b2b163..43d3c6732227c8b6ab1777d16a4f277aa3c39532 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 456034d92bc3e0e93c40ec5d95fad70fe8c93264..6b50b87f72b6faed12ac26c17ffc8fb69fc123c2 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 7b225eb3487f0fb0c282ff466e4a03f9b6c1441d..5c8d74f4cb26bf6eb5b99a19d9ed9b274a48c0ce 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 d09090d3e403485d920364c098e1626214b251a2..6d27b409730bc97eb2383883f9cd99dfb2df97d8 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 e22de41392c8564b00132c344e1fbe391250cc30..77ffba0751ee39ca8ee96afd76212e4c400823eb 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 07961c797c0b3b265df7d54fdef82cdfb5451f20..95c7791a4b3f134807c306f76370812d7cdeb9c4 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 b9acada47b31cfa9d381ef8d0fc4049efece5436..0000000000000000000000000000000000000000 --- 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 aedfd392a0c52f09c43a98c2ec3edc26faf4469f..348cd0a46f763d4ed2bb3cc2fccc440fd319df21 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 da220fad781b8932aed7468617b9fe5a8c4d5767..e2d50c4f66b9265fe880c01b495d934e18ef7b52 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 deea2264c16df8b1a4f4c4723eb888999f88e72a..52016707ccc97172edf81f2849cda6ec09f20b11 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 e42ed6dc7258a948f2ce38591cfc7bcd6033385b..0e0e6316dc7141b6783aa4a644d577a36a48dd6e 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 c2480d17886e8da48fcdef0f47302f859a7d32ec..40f71b850eda4184c604f73d454564c9db38739d 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 <html> <head> <meta charset="UTF-8"> @@ -18,14 +19,9 @@ </head> <body class="aboutPageWideContainer"> <h1>about:buildconfig</h1> -#ifdef SOURCE_REPO -#ifdef SOURCE_CHANGESET +#ifdef MOZ_SOURCE_URL <h2>Source</h2> -<p>Built from <a href="@SOURCE_REPO@/rev/@SOURCE_CHANGESET@">@SOURCE_REPO@/rev/@SOURCE_CHANGESET@</a></p> -#endif -#elifdef SOURCE_GIT_COMMIT -<h2>Source</h2> -<p>Built from git commit <a href="#">@SOURCE_GIT_COMMIT@</a></p> +<p>Built from <a href="@MOZ_SOURCE_URL@">@MOZ_SOURCE_URL@</a></p> #endif <h2>Build platform</h2> <table> diff --git a/toolkit/content/moz.build b/toolkit/content/moz.build index 0fb97e3e7c3d036ba2729cb06486e0bca759a40e..7d98435b0a401fdf2f2b65650bdb21ceffd5bc90 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 5ceb990c6fc43d5dd296ed96b2af0225a0340726..51c33299e491eae796198132782397120d893078 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 b8ff635bc2d064e620ef8a6fc9256ee760dc54d7..349aa292b2fdef96b5fe18a07243f67cf598efb6 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 d3f4b194bfe35574b9fabb141c835344fb259286..04d0b3a7c9c26a228d57f1a0a52152247450187d 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 1b25ca89d048e091ad4cefb9df5353ffb0122818..a35a949531521a7499c5df5685809376952f6317 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 9cfe53c11c340593fe2d88505b4d3f453e28ed76..036fa26a14f8c5011e50eedea013e75d8fc42bc4 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 9030fc41fc3e0455360762ac258973c5b8ba3d86..225dc3bbb6ee81841535a9a2661194514883bdd6 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 0b337554ab3e17810800c8a126bfe375260618f9..01c8b741a1cf3abaac4acb1df329c2e144237d20 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@