Skip to content

Commit

Permalink
Bug 1246881 - Generate a header defining MOZ_BUILDID. r=mshal
Browse files Browse the repository at this point in the history
  • Loading branch information
glandium committed Feb 11, 2016
1 parent 8c6f9cf commit fd36539
Show file tree
Hide file tree
Showing 25 changed files with 75 additions and 97 deletions.
6 changes: 6 additions & 0 deletions Makefile.in
Expand Up @@ -15,9 +15,11 @@ export TOPLEVEL_BUILD := 1

default::

ifndef TEST_MOZBUILD
ifdef MOZ_BUILD_APP
include $(topsrcdir)/$(MOZ_BUILD_APP)/build.mk
endif
endif

include $(topsrcdir)/config/config.mk

Expand All @@ -28,6 +30,10 @@ DIST_GARBAGE = config.cache config.log config.status* config-defs.h \
netwerk/necko-config.h xpcom/xpcom-config.h xpcom/xpcom-private.h \
.mozconfig.mk

ifndef MOZ_PROFILE_USE
buildid.h: FORCE
endif

ifdef JS_STANDALONE
configure_dir = $(topsrcdir)/js/src
else
Expand Down
5 changes: 0 additions & 5 deletions build/Makefile.in
Expand Up @@ -9,11 +9,6 @@ include $(topsrcdir)/config/makefiles/makeutils.mk
ifdef MOZ_APP_BASENAME
APP_INI_DEPS = $(topsrcdir)/config/milestone.txt

MOZ_BUILDID := $(shell cat $(DEPTH)/config/buildid)
APP_INI_DEPS += $(DEPTH)/config/buildid

DEFINES += -DMOZ_BUILDID=$(MOZ_BUILDID)

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))
Expand Down
1 change: 1 addition & 0 deletions build/application.ini
Expand Up @@ -15,6 +15,7 @@
; file, You can obtain one at http://mozilla.org/MPL/2.0/.
#endif
#filter substitution
#include @TOPOBJDIR@/buildid.h
[App]
Vendor=@MOZ_APP_VENDOR@
Name=@MOZ_APP_BASENAME@
Expand Down
2 changes: 2 additions & 0 deletions build/moz.build
Expand Up @@ -75,3 +75,5 @@ if CONFIG['MOZ_APP_BASENAME']:
FINAL_TARGET_PP_FILES += ['application.ini']
if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android' and CONFIG['MOZ_UPDATER']:
FINAL_TARGET_PP_FILES += ['update-settings.ini']

DEFINES['TOPOBJDIR'] = TOPOBJDIR
30 changes: 30 additions & 0 deletions build/variables.py
@@ -0,0 +1,30 @@
# 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/.

from __future__ import print_function, unicode_literals

import os
import sys
from datetime import datetime


def buildid_header(output):
buildid = os.environ.get('MOZ_BUILD_DATE')
if buildid and len(buildid) != 14:
print('Ignoring invalid MOZ_BUILD_DATE: %s' % buildid, file=sys.stderr)
buildid = None
if not buildid:
buildid = datetime.now().strftime('%Y%m%d%H%M%S')
output.write("#define MOZ_BUILDID %s\n" % buildid)


def main(args):
if (len(args)):
func = globals().get(args[0])
if func:
return func(sys.stdout, *args[1:])


if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
2 changes: 1 addition & 1 deletion client.mk
Expand Up @@ -238,7 +238,7 @@ profiledbuild::
ifdef MOZ_UNIFY_BDATE
ifndef MOZ_BUILD_DATE
ifdef MOZ_BUILD_PROJECTS
MOZ_BUILD_DATE = $(shell $(PYTHON) $(TOPSRCDIR)/toolkit/xre/make-platformini.py --print-buildid)
MOZ_BUILD_DATE = $(shell $(PYTHON) $(TOPSRCDIR)/build/variables.py buildid_header | awk '{print $$3}')
export MOZ_BUILD_DATE
endif
endif
Expand Down
3 changes: 1 addition & 2 deletions config/faster/rules.mk
Expand Up @@ -80,7 +80,7 @@ $(TOPOBJDIR)/%: FORCE
# corresponding install manifests are named correspondingly, with forward
# slashes replaced with underscores, and prefixed with `install_`. That is,
# the install manifest for `dist/bin` would be `install_dist_bin`.
$(addprefix install-,$(INSTALL_MANIFESTS)): install-%: $(TOPOBJDIR)/config/buildid
$(addprefix install-,$(INSTALL_MANIFESTS)): install-%: $(TOPOBJDIR)/buildid.h
@# For now, force preprocessed files to be reprocessed every time.
@# The overhead is not that big, and this avoids waiting for proper
@# support for defines tracking in process_install_manifest.
Expand All @@ -91,7 +91,6 @@ $(addprefix install-,$(INSTALL_MANIFESTS)): install-%: $(TOPOBJDIR)/config/build
$(TOPOBJDIR)/$* \
-DAB_CD=en-US \
-DBOOKMARKS_INCLUDE_DIR=$(TOPSRCDIR)/browser/locales/en-US/profile \
-DMOZ_BUILDID=$(shell cat $(TOPOBJDIR)/config/buildid) \
$(ACDEFINES) \
install_$(subst /,_,$*)

Expand Down
2 changes: 1 addition & 1 deletion mobile/android/base/Makefile.in
Expand Up @@ -2,7 +2,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/.

MOZ_BUILDID := $(shell cat $(DEPTH)/config/buildid)
MOZ_BUILDID := $(shell awk '{print $$3}' $(DEPTH)/buildid.h)

# Set the appropriate version code, based on the existance of the
# MOZ_APP_ANDROID_VERSION_CODE variable.
Expand Down
2 changes: 2 additions & 0 deletions mobile/android/base/moz.build
Expand Up @@ -984,3 +984,5 @@ if CONFIG['MOZ_ANDROID_SEARCH_ACTIVITY']:
]

FINAL_TARGET_PP_FILES += ['package-name.txt.in']

DEFINES['TOPOBJDIR'] = TOPOBJDIR
7 changes: 7 additions & 0 deletions moz.build
Expand Up @@ -31,9 +31,16 @@ if not CONFIG['JS_STANDALONE']:
'mozilla-config.h',
]
EXPORTS += [
'!buildid.h',
'!mozilla-config.h',
]

GENERATED_FILES += [
'buildid.h',
]

GENERATED_FILES['buildid.h'].script = 'build/variables.py:buildid_header'

DIRS += [
'build',
'probes',
Expand Down
8 changes: 4 additions & 4 deletions python/mozbuild/mozbuild/android_version_code.py
Expand Up @@ -75,10 +75,10 @@ def android_version_code_v1(buildid, cpu_arch=None, min_sdk=0, max_sdk=0):
'''
def hours_since_cutoff(buildid):
# The ID is formatted like YYYYMMDDHHMMSS (using
# datetime.now().strftime('%Y%m%d%H%M%S'); see
# toolkit/xre/make-platformini.py). The inverse function is
# time.strptime. N.B.: the time module expresses time as decimal
# seconds since the epoch.
# datetime.now().strftime('%Y%m%d%H%M%S'); see build/variables.py).
# The inverse function is time.strptime.
# N.B.: the time module expresses time as decimal seconds since the
# epoch.
fmt = '%Y%m%d%H%M%S'
build = time.strptime(str(buildid), fmt)
cutoff = time.strptime(str(V1_CUTOFF), fmt)
Expand Down
8 changes: 6 additions & 2 deletions toolkit/xre/Makefile.in
Expand Up @@ -28,9 +28,13 @@ ifneq (,$(strip $(MOZ_SOURCE_STAMP)))

endif # MOZ_SOURCE_STAMP

MOZ_BUILDID := $(strip $(firstword $(shell cat $(DEPTH)/config/buildid 2>/dev/null)))
MOZ_BUILDID := $(shell awk '{print $$3}' $(DEPTH)/buildid.h)
$(call errorIfEmpty,GRE_MILESTONE MOZ_BUILDID)

DEFINES += -DMOZ_BUILDID=$(MOZ_BUILDID)

$(srcdir)/nsAppRunner.cpp: $(DEPTH)/config/buildid $(milestone_txt)
# Note these dependencies are broken because the target is *not* the cpp file.
# BUT, actually fixing it would make libxul rebuilt on every single incremental
# build because of the automatic buildid change. This is why we can't actually
# include buildid.h there, because it would add the dependency.
$(srcdir)/nsAppRunner.cpp: $(DEPTH)/buildid.h $(milestone_txt)
51 changes: 0 additions & 51 deletions toolkit/xre/make-platformini.py

This file was deleted.

1 change: 1 addition & 0 deletions toolkit/xre/moz.build
Expand Up @@ -180,6 +180,7 @@ CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
if CONFIG['MOZ_WIDGET_GTK']:
CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']

DEFINES['TOPOBJDIR'] = TOPOBJDIR
FINAL_TARGET_PP_FILES += [
'platform.ini'
]
6 changes: 6 additions & 0 deletions toolkit/xre/nsAppRunner.cpp
Expand Up @@ -253,6 +253,12 @@ static char **gQtOnlyArgv;
#include <fontconfig/fontconfig.h>
#endif
#include "BinaryPath.h"
#ifndef MOZ_BUILDID
// See comment in Makefile.in why we want to avoid including buildid.h.
// Still include it when MOZ_BUILDID is not set, which can happen with some
// build backends.
#include "buildid.h"
#endif

#ifdef MOZ_LINKER
extern "C" MFBT_API bool IsSignalHandlingBroken();
Expand Down
1 change: 1 addition & 0 deletions toolkit/xre/platform.ini
Expand Up @@ -4,6 +4,7 @@
; file, You can obtain one at http://mozilla.org/MPL/2.0/.
#endif
#filter substitution
#include @TOPOBJDIR@/buildid.h
[Build]
BuildID=@MOZ_BUILDID@
Milestone=@GRE_MILESTONE@
Expand Down
12 changes: 0 additions & 12 deletions webapprt/Makefile.in

This file was deleted.

7 changes: 0 additions & 7 deletions webapprt/gtk/Makefile.in
Expand Up @@ -5,10 +5,3 @@
NSDISTMODE = copy

PROGRAMS_DEST = $(DIST)/bin

include $(topsrcdir)/config/rules.mk

MOZ_BUILDID := $(shell cat $(DEPTH)/config/buildid)
DEFINES += -DMOZ_BUILDID=$(MOZ_BUILDID)

webapprt.$(OBJ_SUFFIX): $(DEPTH)/config/buildid
1 change: 1 addition & 0 deletions webapprt/gtk/webapprt.cpp
Expand Up @@ -19,6 +19,7 @@
#include "nsXPCOMPrivate.h" // for MAXPATHLEN and XPCOM_DLL
#include "nsXULAppAPI.h"
#include "BinaryPath.h"
#include "buildid.h"

const char kAPP_INI[] = "application.ini";
const char kWEBAPP_INI[] = "webapp.ini";
Expand Down
7 changes: 0 additions & 7 deletions webapprt/mac/Makefile.in
Expand Up @@ -7,10 +7,3 @@
NSDISTMODE = copy

PROGRAMS_DEST = $(DIST)/bin

include $(topsrcdir)/config/rules.mk

MOZ_BUILDID := $(shell cat $(DEPTH)/config/buildid)
DEFINES += -DMOZ_BUILDID=$(MOZ_BUILDID)

webapprt.$(OBJ_SUFFIX): $(DEPTH)/config/buildid
1 change: 1 addition & 0 deletions webapprt/mac/webapprt.mm
Expand Up @@ -29,6 +29,7 @@
#include "nsIFile.h"
#include "nsStringGlue.h"
#include "mozilla/AppData.h"
#include "buildid.h"

using namespace mozilla;

Expand Down
2 changes: 2 additions & 0 deletions webapprt/moz.build
Expand Up @@ -57,3 +57,5 @@ JS_PREFERENCE_PP_FILES += [
FINAL_TARGET_PP_FILES += [
'webapprt.ini',
]

DEFINES['TOPOBJDIR'] = TOPOBJDIR
1 change: 1 addition & 0 deletions webapprt/webapprt.ini
Expand Up @@ -5,6 +5,7 @@
#endif

#filter substitution
#include @TOPOBJDIR@/buildid.h

[App]
ID=webapprt@mozilla.org
Expand Down
5 changes: 0 additions & 5 deletions webapprt/win/Makefile.in
Expand Up @@ -48,8 +48,3 @@ PROGRAMS_DEST = $(DIST)/bin

include $(topsrcdir)/config/rules.mk
include $(topsrcdir)/toolkit/mozapps/installer/windows/nsis/makensis.mk

MOZ_BUILDID := $(shell cat $(DEPTH)/config/buildid)
DEFINES += -DMOZ_BUILDID=$(MOZ_BUILDID)

webapprt.$(OBJ_SUFFIX): $(DEPTH)/config/buildid
1 change: 1 addition & 0 deletions webapprt/win/webapprt.cpp
Expand Up @@ -19,6 +19,7 @@
#include "nsXPCOMPrivate.h" // for MAXPATHLEN and XPCOM_DLL
#include "nsXULAppAPI.h"
#include "mozilla/AppData.h"
#include "buildid.h"

using namespace mozilla;

Expand Down

0 comments on commit fd36539

Please sign in to comment.