Commit 1d537257 authored by Mike Hommey's avatar Mike Hommey
Browse files

Bug 1247162 - Generate a header defining MOZ_SOURCE_*. r=mshal

The behavior is not entirely idempotent (most notably for
buildconfig.html), but this can be improved later if necessary.
It is idempotent where it matters.

This allows to get rid of config/makefiles/rcs.mk and its uses.
parent 520ccddd
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -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
+0 −3
Original line number Diff line number Diff line
@@ -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

+0 −13
Original line number Diff line number Diff line
@@ -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.
+1 −0
Original line number Diff line number Diff line
@@ -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@
+48 −0
Original line number Diff line number Diff line
@@ -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])
Loading