diff --git a/Makefile.in b/Makefile.in index 012f69bebfc8f..845585fe40921 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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))) diff --git a/toolkit/library/gen_buildid.py b/toolkit/library/gen_buildid.py new file mode 100644 index 0000000000000..67be70e03b965 --- /dev/null +++ b/toolkit/library/gen_buildid.py @@ -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') diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build index 0fed95365c7a0..d1c94504beac5 100644 --- a/toolkit/library/moz.build +++ b/toolkit/library/moz.build @@ -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] diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 020fe7ca31205..82fb05f714d20 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -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;