author | Mike Hommey <mh+mozilla@glandium.org> |
Mon, 30 Nov 2015 17:43:06 +0900 | |
changeset 308989 | e03b93cbb64d4996a9f170d76a69801b9a708d84 |
parent 308988 | 603b6593c1612caa3eeaddc8bf66993f74c4e825 |
child 308990 | b69aaa0c37118c43a5830c721fb40854a3f5c1cc |
push id | 5513 |
push user | raliiev@mozilla.com |
push date | Mon, 25 Jan 2016 13:55:34 +0000 |
treeherder | mozilla-beta@5ee97dd05b5c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | gps |
bugs | 1229233 |
milestone | 45.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/Makefile.in +++ b/Makefile.in @@ -29,26 +29,28 @@ DIST_GARBAGE = config.cache config.log c .mozconfig.mk ifdef JS_STANDALONE configure_dir = $(topsrcdir)/js/src else configure_dir = $(topsrcdir) endif +ifndef TEST_MOZBUILD ifndef MOZ_PROFILE_USE # We need to explicitly put backend.RecursiveMakeBackend here # otherwise the rule in rules.mk doesn't run early enough. $(TIERS) binaries:: CLOBBER $(configure_dir)/configure config.status backend.RecursiveMakeBackend ifndef JS_STANDALONE ifdef COMPILE_ENVIRONMENT $(TIERS) binaries:: $(topsrcdir)/js/src/configure js/src/config.status endif endif endif +endif ifdef JS_STANDALONE .PHONY: CLOBBER CLOBBER: else CLOBBER: $(topsrcdir)/CLOBBER @echo 'STOP! The CLOBBER file has changed.' @echo 'Please run the build through a sanctioned build wrapper, such as' @@ -76,26 +78,28 @@ config.status js/src/config.status: # Regenerate the build backend if it is out of date. We only have this rule in # this main make file because having it in rules.mk and applied to partial tree # builds resulted in a world of hurt. Gory details are in bug 877308. # # The mach build driver will ensure the backend is up to date for partial tree # builds. This cleanly avoids most of the pain. +ifndef TEST_MOZBUILD backend.RecursiveMakeBackend: @echo 'Build configuration changed. Regenerating backend.' $(PYTHON) config.status Makefile: backend.RecursiveMakeBackend @$(TOUCH) $@ include backend.RecursiveMakeBackend.pp default:: backend.RecursiveMakeBackend +endif install_manifests := \ $(addprefix dist/,bin branding idl include public private sdk xpi-stage) \ _tests \ $(NULL) install_manifest_depends = \ CLOBBER \ $(configure_dir)/configure \
--- a/config/faster/rules.mk +++ b/config/faster/rules.mk @@ -38,25 +38,30 @@ # global Make variables names are uppercase, while "local" Make variables # applied to specific targets are lowercase. # Targets to be triggered for a default build default: $(addprefix install-,$(INSTALL_MANIFESTS)) # Explicit files to be built for a default build default: $(addprefix $(TOPOBJDIR)/,$(MANIFEST_TARGETS)) +ifndef TEST_MOZBUILD default: $(TOPOBJDIR)/dist/bin/platform.ini +endif ifndef NO_XPIDL # Targets from the recursive make backend to be built for a default build default: $(TOPOBJDIR)/config/makefiles/xpidl/xpidl endif ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) # Mac builds require to copy things in dist/bin/*.app +# TODO: remove the MOZ_WIDGET_TOOLKIT and MOZ_BUILD_APP variables from +# faster/Makefile and python/mozbuild/mozbuild/test/backend/test_build.py +# when this is not required anymore. default: $(MAKE) -C $(TOPOBJDIR)/$(MOZ_BUILD_APP)/app repackage endif .PHONY: FORCE # Extra define to trigger some workarounds. We should strive to limit the # use of those. As of writing the only ones are in
--- a/python/moz.build +++ b/python/moz.build @@ -30,16 +30,17 @@ PYTHON_UNIT_TESTS += [ 'mozbuild/dumbmake/test/__init__.py', 'mozbuild/dumbmake/test/test_dumbmake.py', 'mozbuild/mozbuild/test/__init__.py', 'mozbuild/mozbuild/test/action/test_buildlist.py', 'mozbuild/mozbuild/test/action/test_generate_browsersearch.py', 'mozbuild/mozbuild/test/backend/__init__.py', 'mozbuild/mozbuild/test/backend/common.py', 'mozbuild/mozbuild/test/backend/test_android_eclipse.py', + 'mozbuild/mozbuild/test/backend/test_build.py', 'mozbuild/mozbuild/test/backend/test_configenvironment.py', 'mozbuild/mozbuild/test/backend/test_recursivemake.py', 'mozbuild/mozbuild/test/backend/test_visualstudio.py', 'mozbuild/mozbuild/test/common.py', 'mozbuild/mozbuild/test/compilation/__init__.py', 'mozbuild/mozbuild/test/compilation/test_warnings.py', 'mozbuild/mozbuild/test/controller/__init__.py', 'mozbuild/mozbuild/test/controller/test_ccachestats.py',
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/build/app/moz.build @@ -0,0 +1,49 @@ +DIST_SUBDIR = 'app' + +EXTRA_JS_MODULES += [ + '../foo.jsm', +] + +EXTRA_JS_MODULES.child += [ + '../bar.jsm', +] + +EXTRA_PP_JS_MODULES += [ + '../baz.jsm', +] + +EXTRA_PP_JS_MODULES.child2 += [ + '../qux.jsm', +] + +FINAL_TARGET_FILES += [ + '../foo.ini', +] + +FINAL_TARGET_FILES.child += [ + '../bar.ini', +] + +FINAL_TARGET_PP_FILES += [ + '../baz.ini', +] + +FINAL_TARGET_PP_FILES.child2 += [ + '../qux.ini', +] + +EXTRA_COMPONENTS += [ + '../components.manifest', + '../foo.js', +] + +EXTRA_PP_COMPONENTS += [ + '../bar.js', +] + +JS_PREFERENCE_FILES += [ + '../prefs.js', +] + +DEFINES['FOO'] = 'bar' +DEFINES['BAR'] = True
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/build/bar.ini @@ -0,0 +1,1 @@ +bar.ini
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/build/bar.js @@ -0,0 +1,2 @@ +#filter substitution +bar.js: FOO is @FOO@
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/build/bar.jsm @@ -0,0 +1,1 @@ +bar.jsm
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/build/baz.ini @@ -0,0 +1,2 @@ +#filter substitution +baz.ini: FOO is @FOO@
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/build/baz.jsm @@ -0,0 +1,2 @@ +#filter substitution +baz.jsm: FOO is @FOO@
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/build/components.manifest @@ -0,0 +1,2 @@ +component {foo} foo.js +component {bar} bar.js
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/build/foo.ini @@ -0,0 +1,1 @@ +foo.ini
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/build/foo.js @@ -0,0 +1,1 @@ +foo.js
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/build/foo.jsm @@ -0,0 +1,1 @@ +foo.jsm
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/build/moz.build @@ -0,0 +1,63 @@ +CONFIGURE_SUBST_FILES += [ + '/config/autoconf.mk', + '/config/emptyvars.mk', +] + +EXTRA_JS_MODULES += [ + 'foo.jsm', +] + +EXTRA_JS_MODULES.child += [ + 'bar.jsm', +] + +EXTRA_PP_JS_MODULES += [ + 'baz.jsm', +] + +EXTRA_PP_JS_MODULES.child2 += [ + 'qux.jsm', +] + +FINAL_TARGET_FILES += [ + 'foo.ini', +] + +FINAL_TARGET_FILES.child += [ + 'bar.ini', +] + +FINAL_TARGET_PP_FILES += [ + 'baz.ini', +] + +FINAL_TARGET_PP_FILES.child2 += [ + 'qux.ini', +] + +EXTRA_COMPONENTS += [ + 'components.manifest', + 'foo.js', +] + +EXTRA_PP_COMPONENTS += [ + 'bar.js', +] + +JS_PREFERENCE_FILES += [ + 'prefs.js', +] + +RESOURCE_FILES += [ + 'resource', +] + +RESOURCE_FILES.child += [ + 'resource2', +] + +DEFINES['FOO'] = 'foo' + +DIRS += [ + 'app', +]
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/build/prefs.js @@ -0,0 +1,1 @@ +prefs.js
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/build/qux.ini @@ -0,0 +1,5 @@ +#ifdef BAR +qux.ini: BAR is defined +#else +qux.ini: BAR is not defined +#endif
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/build/qux.jsm @@ -0,0 +1,5 @@ +#ifdef BAR +qux.jsm: BAR is defined +#else +qux.jsm: BAR is not defined +#endif
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/build/resource @@ -0,0 +1,1 @@ +resource
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/build/resource2 @@ -0,0 +1,1 @@ +resource2
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/test_build.py @@ -0,0 +1,166 @@ +# 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 unicode_literals, print_function + +import buildconfig +import os +import shutil +import sys +import unittest +import mozpack.path as mozpath +from contextlib import contextmanager +from mozunit import main +from mozbuild.backend.configenvironment import ConfigEnvironment +from mozbuild.backend.recursivemake import RecursiveMakeBackend +from mozbuild.backend.fastermake import FasterMakeBackend +from mozbuild.base import MozbuildObject +from mozbuild.frontend.emitter import TreeMetadataEmitter +from mozbuild.frontend.reader import BuildReader +from mozbuild.util import ensureParentDir +from mozpack.files import FileFinder +from tempfile import mkdtemp + + +BASE_SUBSTS = [ + ('PYTHON', sys.executable), +] + + +class TestBuild(unittest.TestCase): + @contextmanager + def do_test_backend(self, *backends, **kwargs): + topobjdir = mkdtemp() + try: + config = ConfigEnvironment(buildconfig.topsrcdir, topobjdir, + **kwargs) + reader = BuildReader(config) + emitter = TreeMetadataEmitter(config) + moz_build = mozpath.join(config.topsrcdir, 'test.mozbuild') + definitions = list(emitter.emit( + reader.read_mozbuild(moz_build, config))) + for backend in backends: + backend(config).consume(definitions) + + yield config + except: + raise + finally: + if not os.environ.get('MOZ_NO_CLEANUP'): + shutil.rmtree(topobjdir) + + @contextmanager + def line_handler(self): + lines = [] + + def handle_make_line(line): + lines.append(line) + + try: + yield handle_make_line + except: + print('\n'.join(lines)) + raise + + if os.environ.get('MOZ_VERBOSE_MAKE'): + print('\n'.join(lines)) + + def test_recursive_make(self): + substs = list(BASE_SUBSTS) + with self.do_test_backend(RecursiveMakeBackend, + substs=substs) as config: + build = MozbuildObject(config.topsrcdir, None, None, + config.topobjdir) + overrides = [ + 'install_manifest_depends=', + 'TEST_MOZBUILD=1', + ] + with self.line_handler() as handle_make_line: + build._run_make(directory=config.topobjdir, target=overrides, + silent=False, line_handler=handle_make_line) + + self.validate(config) + + def test_faster_make(self): + substs = list(BASE_SUBSTS) + [ + ('MOZ_BUILD_APP', 'dummy_app'), + ('MOZ_WIDGET_TOOLKIT', 'dummy_widget'), + ] + with self.do_test_backend(RecursiveMakeBackend, FasterMakeBackend, + substs=substs) as config: + buildid = mozpath.join(config.topobjdir, 'config', 'buildid') + ensureParentDir(buildid) + with open(buildid, 'w') as fh: + fh.write('20100101012345\n') + + build = MozbuildObject(config.topsrcdir, None, None, + config.topobjdir) + overrides = [ + 'TEST_MOZBUILD=1', + ] + with self.line_handler() as handle_make_line: + build._run_make(directory=mozpath.join(config.topobjdir, + 'faster'), + target=overrides, silent=False, + line_handler=handle_make_line) + + self.validate(config) + + def validate(self, config): + self.maxDiff = None + test_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), + 'data', 'build') + os.sep + + # We want unicode instances out of the files, because having plain str + # makes assertEqual diff output in case of error extra verbose because + # of the difference in type. + result = { + p: f.open().read().decode('utf-8') + for p, f in FileFinder(mozpath.join(config.topobjdir, 'dist')) + } + self.assertTrue(len(result)) + self.assertEqual(result, { + 'bin/baz.ini': 'baz.ini: FOO is foo\n', + 'bin/child/bar.ini': 'bar.ini\n', + 'bin/child2/qux.ini': 'qux.ini: BAR is not defined\n', + 'bin/chrome.manifest': 'manifest components/components.manifest\n', + 'bin/components/bar.js': + '//@line 2 "%sbar.js"\nbar.js: FOO is foo\n' % (test_path), + 'bin/components/components.manifest': + 'component {foo} foo.js\ncomponent {bar} bar.js\n', + 'bin/components/foo.js': 'foo.js\n', + 'bin/defaults/pref/prefs.js': 'prefs.js\n', + 'bin/foo.ini': 'foo.ini\n', + 'bin/modules/baz.jsm': + '//@line 2 "%sbaz.jsm"\nbaz.jsm: FOO is foo\n' % (test_path), + 'bin/modules/child/bar.jsm': 'bar.jsm\n', + 'bin/modules/child2/qux.jsm': + '//@line 4 "%squx.jsm"\nqux.jsm: BAR is not defined\n' + % (test_path), + 'bin/modules/foo.jsm': 'foo.jsm\n', + 'bin/res/resource': 'resource\n', + 'bin/res/child/resource2': 'resource2\n', + + 'bin/app/baz.ini': 'baz.ini: FOO is bar\n', + 'bin/app/child/bar.ini': 'bar.ini\n', + 'bin/app/child2/qux.ini': 'qux.ini: BAR is defined\n', + 'bin/app/chrome.manifest': 'manifest components/components.manifest\n', + 'bin/app/components/bar.js': + '//@line 2 "%sbar.js"\nbar.js: FOO is bar\n' % (test_path), + 'bin/app/components/components.manifest': + 'component {foo} foo.js\ncomponent {bar} bar.js\n', + 'bin/app/components/foo.js': 'foo.js\n', + 'bin/app/defaults/preferences/prefs.js': 'prefs.js\n', + 'bin/app/foo.ini': 'foo.ini\n', + 'bin/app/modules/baz.jsm': + '//@line 2 "%sbaz.jsm"\nbaz.jsm: FOO is bar\n' % (test_path), + 'bin/app/modules/child/bar.jsm': 'bar.jsm\n', + 'bin/app/modules/child2/qux.jsm': + '//@line 2 "%squx.jsm"\nqux.jsm: BAR is defined\n' + % (test_path), + 'bin/app/modules/foo.jsm': 'foo.jsm\n', + }) + +if __name__ == '__main__': + main()
new file mode 100644 --- /dev/null +++ b/test.mozbuild @@ -0,0 +1,10 @@ +# 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/. + +# This file is necessary to "bootstrap" the test case for the test_build +# test, because of the requirement of the top-level directory containing +# config/*.mk. +DIRS += [ + 'python/mozbuild/mozbuild/test/backend/data/build', +]