Skip to content

Commit

Permalink
Bug 1551639 - Always update buildid but avoid rebuilding libxul. r=na…
Browse files Browse the repository at this point in the history
…lexander

Differential Revision: https://phabricator.services.mozilla.com/D33772

--HG--
extra : moz-landing-system : lando
  • Loading branch information
glandium committed Jun 6, 2019
1 parent 4725fa3 commit 6f6e8cb
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 11 deletions.
9 changes: 1 addition & 8 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,12 @@ DIST_GARBAGE = config.cache config.log config.status* config-defs.h \
.mozconfig.mk

ifndef MOZ_PROFILE_USE
# Automation builds should always have a new buildid, but for the sake of not
# re-linking libxul on every incremental build we do not enforce this for
# developer builds. Tests always need a new buildid as well.
ifneq (,$(MOZ_AUTOMATION)$(MOZ_BUILD_DATE)$(TEST_MOZBUILD))
ifneq (mobile/android,$(MOZ_BUILD_APP))
$(MDDEPDIR)/buildid.h.stub $(MDDEPDIR)/source-repo.h.stub: FORCE
endif
# Additionally, provide a dummy target during tests, because
# faster/rules.mk will expect these targets to exist.
ifdef TEST_MOZBUILD
source-repo.h: $(MDDEPDIR)/source-repo.h.stub
buildid.h: $(MDDEPDIR)/buildid.h.stub
endif
endif

BUILD_BACKEND_FILES := $(addprefix backend.,$(addsuffix Backend,$(BUILD_BACKENDS)))

Expand Down
34 changes: 34 additions & 0 deletions toolkit/library/gen_buildid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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 distibuted with this
# file, You can obtain one at http://mozilla.og/MPL/2.0/.


from mozbuild.preprocessor import Preprocessor
from io import StringIO
import buildconfig
import os


def main(output, input_file):
with open(input_file) as fh:
if buildconfig.substs['EXPAND_LIBS_LIST_STYLE'] == 'linkerscript':
def cleanup(line):
assert line.startswith('INPUT("')
assert line.endswith('")')
return line[len('INPUT("'):-len('")')]

objs = [cleanup(l.strip()) for l in fh.readlines()]
else:
objs = [l.strip() for l in fh.readlines()]

pp = Preprocessor()
pp.out = StringIO()
pp.do_include(os.path.join(buildconfig.topobjdir, 'buildid.h'))
buildid = pp.context['MOZ_BUILDID']
output.write(
'extern const char gToolkitBuildID[] = "%s";' % buildid
)
return set(o for o in objs
if os.path.splitext(os.path.basename(o))[0] != 'buildid')
17 changes: 17 additions & 0 deletions toolkit/library/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,20 @@ if CONFIG['COMPILE_ENVIRONMENT']:
# This library is entirely composed of Rust code, and needs to come after
# all the C++ code so any possible C++ -> Rust calls can be resolved.
USE_LIBS += ['gkrust']

# The buildid is refreshed on every (incremental) build. But we want to avoid
# rebuilding libxul every time, so instead of having a source file that
# #include's buildid.h, which would have a dependency on it, and that would
# thus trigger make to rebuild everything, we generate a source with the
# buildid hard coded in it. Then we make that source file depend on all the
# objects files that constitute libxul, so that if any of the files linked into
# libxul is rebuilt, we refresh the buildid and link it into libxul.
SOURCES += ['!buildid.cpp']
GENERATED_FILES += ['buildid.cpp']
GENERATED_FILES['buildid.cpp'].script = 'gen_buildid.py'
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'uikit'):
libxul_list = 'XUL'
else:
libxul_list = '%sxul_%s' % (
CONFIG['DLL_PREFIX'], CONFIG['DLL_SUFFIX'].lstrip('.'))
GENERATED_FILES['buildid.cpp'].inputs = ['!%s.list' % libxul_list]
6 changes: 3 additions & 3 deletions toolkit/xre/nsAppRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ static const char kPrefHealthReportUploadEnabled[] =
int gArgc;
char** gArgv;

#include "buildid.h"

static const char gToolkitVersion[] = NS_STRINGIFY(GRE_MILESTONE);
static const char gToolkitBuildID[] = NS_STRINGIFY(MOZ_BUILDID);
// The gToolkitBuildID global is defined to MOZ_BUILDID via gen_buildid.py
// in toolkit/library. See related comment in toolkit/library/moz.build.
extern const char gToolkitBuildID[];

static nsIProfileLock* gProfileLock;

Expand Down

0 comments on commit 6f6e8cb

Please sign in to comment.