diff --git a/Makefile.in b/Makefile.in index ee49503acc6..40da7d2a1c4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -95,7 +95,7 @@ include backend.RecursiveMakeBackend.pp default:: backend.RecursiveMakeBackend install_manifests := \ - $(addprefix dist/,bin idl include public private sdk xpi-stage) \ + $(addprefix dist/,bin branding idl include public private sdk xpi-stage) \ _tests \ $(NULL) install_manifest_depends = \ diff --git a/browser/branding/aurora/Makefile.in b/browser/branding/aurora/Makefile.in deleted file mode 100644 index 6fea2c9dc53..00000000000 --- a/browser/branding/aurora/Makefile.in +++ /dev/null @@ -1,48 +0,0 @@ -# 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/. - -include $(topsrcdir)/config/config.mk - -ifeq ($(MOZ_WIDGET_TOOLKIT),windows) -BRANDING_FILES := \ - firefox.ico \ - document.ico \ - branding.nsi \ - appname.bmp \ - bgintro.bmp \ - clock.bmp \ - particles.bmp \ - pencil.bmp \ - pencil-rtl.bmp \ - wizHeader.bmp \ - wizHeaderRTL.bmp \ - wizWatermark.bmp \ - newwindow.ico \ - newtab.ico \ - pbmode.ico \ - $(NULL) -endif - -ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa) -BRANDING_FILES := \ - background.png \ - firefox.icns \ - disk.icns \ - document.icns \ - dsstore \ - $(NULL) -endif - -ifdef MOZ_WIDGET_GTK -BRANDING_FILES := \ - default16.png \ - default32.png \ - default48.png \ - mozicon128.png \ - $(NULL) -endif - -BRANDING_DEST := $(DIST)/branding -BRANDING_TARGET := export -INSTALL_TARGETS += BRANDING diff --git a/browser/branding/aurora/moz.build b/browser/branding/aurora/moz.build index ee56b1fecc1..3e58719c85a 100644 --- a/browser/branding/aurora/moz.build +++ b/browser/branding/aurora/moz.build @@ -9,7 +9,4 @@ DIRS += ['content', 'locales'] DIST_SUBDIR = 'browser' export('DIST_SUBDIR') -JS_PREFERENCE_FILES += [ - 'pref/firefox-branding.js', -] - +include('../branding-common.mozbuild') diff --git a/browser/branding/branding-common.mozbuild b/browser/branding/branding-common.mozbuild new file mode 100644 index 00000000000..524ff3046a8 --- /dev/null +++ b/browser/branding/branding-common.mozbuild @@ -0,0 +1,43 @@ +# -*- Mode: python; c-basic-offset: 4; 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 distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +JS_PREFERENCE_FILES += [ + 'pref/firefox-branding.js', +] + +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': + BRANDING_FILES += [ + 'appname.bmp', + 'bgintro.bmp', + 'branding.nsi', + 'clock.bmp', + 'document.ico', + 'firefox.ico', + 'newtab.ico', + 'newwindow.ico', + 'particles.bmp', + 'pbmode.ico', + 'pencil-rtl.bmp', + 'pencil.bmp', + 'wizHeader.bmp', + 'wizHeaderRTL.bmp', + 'wizWatermark.bmp', + ] +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': + BRANDING_FILES += [ + 'background.png', + 'disk.icns', + 'document.icns', + 'dsstore', + 'firefox.icns', + ] +elif CONFIG['MOZ_WIDGET_GTK']: + BRANDING_FILES += [ + 'default16.png', + 'default32.png', + 'default48.png', + 'mozicon128.png', + ] diff --git a/browser/branding/nightly/Makefile.in b/browser/branding/nightly/Makefile.in deleted file mode 100644 index 6fea2c9dc53..00000000000 --- a/browser/branding/nightly/Makefile.in +++ /dev/null @@ -1,48 +0,0 @@ -# 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/. - -include $(topsrcdir)/config/config.mk - -ifeq ($(MOZ_WIDGET_TOOLKIT),windows) -BRANDING_FILES := \ - firefox.ico \ - document.ico \ - branding.nsi \ - appname.bmp \ - bgintro.bmp \ - clock.bmp \ - particles.bmp \ - pencil.bmp \ - pencil-rtl.bmp \ - wizHeader.bmp \ - wizHeaderRTL.bmp \ - wizWatermark.bmp \ - newwindow.ico \ - newtab.ico \ - pbmode.ico \ - $(NULL) -endif - -ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa) -BRANDING_FILES := \ - background.png \ - firefox.icns \ - disk.icns \ - document.icns \ - dsstore \ - $(NULL) -endif - -ifdef MOZ_WIDGET_GTK -BRANDING_FILES := \ - default16.png \ - default32.png \ - default48.png \ - mozicon128.png \ - $(NULL) -endif - -BRANDING_DEST := $(DIST)/branding -BRANDING_TARGET := export -INSTALL_TARGETS += BRANDING diff --git a/browser/branding/nightly/moz.build b/browser/branding/nightly/moz.build index ee56b1fecc1..3e58719c85a 100644 --- a/browser/branding/nightly/moz.build +++ b/browser/branding/nightly/moz.build @@ -9,7 +9,4 @@ DIRS += ['content', 'locales'] DIST_SUBDIR = 'browser' export('DIST_SUBDIR') -JS_PREFERENCE_FILES += [ - 'pref/firefox-branding.js', -] - +include('../branding-common.mozbuild') diff --git a/browser/branding/official/Makefile.in b/browser/branding/official/Makefile.in deleted file mode 100644 index 6fea2c9dc53..00000000000 --- a/browser/branding/official/Makefile.in +++ /dev/null @@ -1,48 +0,0 @@ -# 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/. - -include $(topsrcdir)/config/config.mk - -ifeq ($(MOZ_WIDGET_TOOLKIT),windows) -BRANDING_FILES := \ - firefox.ico \ - document.ico \ - branding.nsi \ - appname.bmp \ - bgintro.bmp \ - clock.bmp \ - particles.bmp \ - pencil.bmp \ - pencil-rtl.bmp \ - wizHeader.bmp \ - wizHeaderRTL.bmp \ - wizWatermark.bmp \ - newwindow.ico \ - newtab.ico \ - pbmode.ico \ - $(NULL) -endif - -ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa) -BRANDING_FILES := \ - background.png \ - firefox.icns \ - disk.icns \ - document.icns \ - dsstore \ - $(NULL) -endif - -ifdef MOZ_WIDGET_GTK -BRANDING_FILES := \ - default16.png \ - default32.png \ - default48.png \ - mozicon128.png \ - $(NULL) -endif - -BRANDING_DEST := $(DIST)/branding -BRANDING_TARGET := export -INSTALL_TARGETS += BRANDING diff --git a/browser/branding/official/moz.build b/browser/branding/official/moz.build index ee56b1fecc1..3e58719c85a 100644 --- a/browser/branding/official/moz.build +++ b/browser/branding/official/moz.build @@ -9,7 +9,4 @@ DIRS += ['content', 'locales'] DIST_SUBDIR = 'browser' export('DIST_SUBDIR') -JS_PREFERENCE_FILES += [ - 'pref/firefox-branding.js', -] - +include('../branding-common.mozbuild') diff --git a/browser/branding/unofficial/Makefile.in b/browser/branding/unofficial/Makefile.in deleted file mode 100644 index 6fea2c9dc53..00000000000 --- a/browser/branding/unofficial/Makefile.in +++ /dev/null @@ -1,48 +0,0 @@ -# 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/. - -include $(topsrcdir)/config/config.mk - -ifeq ($(MOZ_WIDGET_TOOLKIT),windows) -BRANDING_FILES := \ - firefox.ico \ - document.ico \ - branding.nsi \ - appname.bmp \ - bgintro.bmp \ - clock.bmp \ - particles.bmp \ - pencil.bmp \ - pencil-rtl.bmp \ - wizHeader.bmp \ - wizHeaderRTL.bmp \ - wizWatermark.bmp \ - newwindow.ico \ - newtab.ico \ - pbmode.ico \ - $(NULL) -endif - -ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa) -BRANDING_FILES := \ - background.png \ - firefox.icns \ - disk.icns \ - document.icns \ - dsstore \ - $(NULL) -endif - -ifdef MOZ_WIDGET_GTK -BRANDING_FILES := \ - default16.png \ - default32.png \ - default48.png \ - mozicon128.png \ - $(NULL) -endif - -BRANDING_DEST := $(DIST)/branding -BRANDING_TARGET := export -INSTALL_TARGETS += BRANDING diff --git a/browser/branding/unofficial/moz.build b/browser/branding/unofficial/moz.build index ee56b1fecc1..3e58719c85a 100644 --- a/browser/branding/unofficial/moz.build +++ b/browser/branding/unofficial/moz.build @@ -9,7 +9,4 @@ DIRS += ['content', 'locales'] DIST_SUBDIR = 'browser' export('DIST_SUBDIR') -JS_PREFERENCE_FILES += [ - 'pref/firefox-branding.js', -] - +include('../branding-common.mozbuild') diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py index 371c259a085..2138e593bad 100644 --- a/python/mozbuild/mozbuild/backend/recursivemake.py +++ b/python/mozbuild/mozbuild/backend/recursivemake.py @@ -28,6 +28,7 @@ import mozpack.path as mozpath from .common import CommonBackend from ..frontend.data import ( AndroidEclipseProjectData, + BrandingFiles, ConfigFileSubstitution, ContextDerived, ContextWrapped, @@ -377,6 +378,7 @@ class RecursiveMakeBackend(CommonBackend): self._install_manifests = { k: InstallManifest() for k in [ 'dist_bin', + 'dist_branding', 'dist_idl', 'dist_include', 'dist_public', @@ -493,6 +495,9 @@ class RecursiveMakeBackend(CommonBackend): elif isinstance(obj, Resources): self._process_resources(obj, obj.resources, backend_file) + elif isinstance(obj, BrandingFiles): + self._process_branding_files(obj, obj.files, backend_file) + elif isinstance(obj, JsPreferenceFile): if obj.path.startswith('/'): backend_file.write('PREF_JS_EXPORTS += $(topsrcdir)%s\n' % obj.path) @@ -940,6 +945,22 @@ INSTALL_TARGETS += %(prefix)s if not os.path.exists(source): raise Exception('File listed in RESOURCE_FILES does not exist: %s' % source) + def _process_branding_files(self, obj, files, backend_file): + for source, dest, flags in self._walk_hierarchy(obj, files): + if flags and flags.source: + source = mozpath.normpath(mozpath.join(obj.srcdir, flags.source)) + if not os.path.exists(source): + raise Exception('File listed in BRANDING_FILES does not exist: %s' % source) + + self._install_manifests['dist_branding'].add_symlink(source, dest) + + # Also emit the necessary rules to create $(DIST)/branding during partial + # tree builds. The locale makefiles rely on this working. + backend_file.write('NONRECURSIVE_TARGETS += export\n') + backend_file.write('NONRECURSIVE_TARGETS_export += branding\n') + backend_file.write('NONRECURSIVE_TARGETS_export_branding_DIRECTORY = $(DEPTH)\n') + backend_file.write('NONRECURSIVE_TARGETS_export_branding_TARGETS += install-dist/branding\n') + def _process_installation_target(self, obj, backend_file): # A few makefiles need to be able to override the following rules via # make XPI_NAME=blah commands, so we default to the lazy evaluation as diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py index 5ab86e2618f..aa53ee1975a 100644 --- a/python/mozbuild/mozbuild/frontend/context.py +++ b/python/mozbuild/mozbuild/frontend/context.py @@ -953,6 +953,27 @@ VARIABLES = { This variable can only be used on Linux. """, None), + 'BRANDING_FILES': (HierarchicalStringListWithFlagsFactory({'source': unicode}), list, + """List of files to be installed into the branding directory. + + ``BRANDING_FILES`` will copy (or symlink, if the platform supports it) + the contents of its files to the ``dist/branding`` directory. Files that + are destined for a subdirectory can be specified by accessing a field. + For example, to export ``foo.png`` to the top-level directory and + ``bar.png`` to the directory ``images/subdir``, append to + ``BRANDING_FILES`` like so:: + + BRANDING_FILES += ['foo.png'] + BRANDING_FILES.images.subdir += ['bar.png'] + + If the source and destination have different file names, add the + destination name to the list and set the ``source`` property on the + entry, like so:: + + BRANDING_FILES.dir += ['baz.png'] + BRANDING_FILES.dir['baz.png'].source = 'quux.png' + """, None), + 'RESOURCE_FILES': (HierarchicalStringListWithFlagsFactory({'preprocess': bool}), list, """List of resources to be exported, and in which subdirectories. diff --git a/python/mozbuild/mozbuild/frontend/data.py b/python/mozbuild/mozbuild/frontend/data.py index f80a15d4ec9..c59fc6840dc 100644 --- a/python/mozbuild/mozbuild/frontend/data.py +++ b/python/mozbuild/mozbuild/frontend/data.py @@ -248,6 +248,20 @@ class Resources(ContextDerived): defs.update(defines) self.defines = defs +class BrandingFiles(ContextDerived): + """Sandbox container object for BRANDING_FILES, which is a + HierarchicalStringList. + + We need an object derived from ContextDerived for use in the backend, so + this object fills that role. It just has a reference to the underlying + HierarchicalStringList, which is created when parsing BRANDING_FILES. + """ + __slots__ = ('files') + + def __init__(self, sandbox, files): + ContextDerived.__init__(self, sandbox) + self.files = files + class JsPreferenceFile(ContextDerived): """Context derived container object for a Javascript preference file. diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index 66ceeec2f6e..cf4685dc055 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -25,6 +25,7 @@ import reftest import mozinfo from .data import ( + BrandingFiles, ConfigFileSubstitution, ContextWrapped, Defines, @@ -664,6 +665,10 @@ class TreeMetadataEmitter(LoggingMixin): yield DistFiles(context, dist_files, context['FINAL_TARGET']) + branding_files = context.get('BRANDING_FILES') + if branding_files: + yield BrandingFiles(context, branding_files) + self._handle_libraries(context) for obj in self._process_test_manifests(context): diff --git a/python/mozbuild/mozbuild/test/backend/data/branding-files/bar.ico b/python/mozbuild/mozbuild/test/backend/data/branding-files/bar.ico new file mode 100644 index 00000000000..e69de29bb2d diff --git a/python/mozbuild/mozbuild/test/backend/data/branding-files/foo.ico b/python/mozbuild/mozbuild/test/backend/data/branding-files/foo.ico new file mode 100644 index 00000000000..e69de29bb2d diff --git a/python/mozbuild/mozbuild/test/backend/data/branding-files/moz.build b/python/mozbuild/mozbuild/test/backend/data/branding-files/moz.build new file mode 100644 index 00000000000..c515db46d94 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/branding-files/moz.build @@ -0,0 +1,14 @@ +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +BRANDING_FILES += [ + 'app.ico', + 'bar.ico', + 'sub/quux.png', +] +BRANDING_FILES['app.ico'].source = 'bar.ico' + +BRANDING_FILES.icons += [ + 'foo.ico', +] + diff --git a/python/mozbuild/mozbuild/test/backend/data/branding-files/sub/quux.png b/python/mozbuild/mozbuild/test/backend/data/branding-files/sub/quux.png new file mode 100644 index 00000000000..e69de29bb2d diff --git a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py index 10b2273d030..c28821f11e8 100644 --- a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py +++ b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py @@ -405,6 +405,19 @@ class TestRecursiveMakeBackend(BackendTester): self.assertIn('res/tests/test.manifest', m) self.assertIn('res/tests/extra.manifest', m) + def test_branding_files(self): + """Ensure BRANDING_FILES is handled properly.""" + env = self._consume('branding-files', RecursiveMakeBackend) + + #BRANDING_FILES should appear in the dist_branding install manifest. + m = InstallManifest(path=os.path.join(env.topobjdir, + '_build_manifests', 'install', 'dist_branding')) + self.assertEqual(len(m), 4) + self.assertIn('app.ico', m) + self.assertIn('bar.ico', m) + self.assertIn('quux.png', m) + self.assertIn('icons/foo.ico', m) + def test_js_preference_files(self): """Ensure PREF_JS_EXPORTS is written out correctly.""" env = self._consume('js_preference_files', RecursiveMakeBackend) diff --git a/python/mozbuild/mozbuild/test/frontend/data/branding-files/moz.build b/python/mozbuild/mozbuild/test/frontend/data/branding-files/moz.build new file mode 100644 index 00000000000..13354e272f5 --- /dev/null +++ b/python/mozbuild/mozbuild/test/frontend/data/branding-files/moz.build @@ -0,0 +1,15 @@ +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +BRANDING_FILES += [ + 'app.ico', + 'bar.ico', + 'baz.png', + 'foo.xpm', +] +BRANDING_FILES['app.ico'].source = 'test/bar.ico' + +BRANDING_FILES.icons += [ + 'quux.icns', +] + diff --git a/python/mozbuild/mozbuild/test/frontend/test_emitter.py b/python/mozbuild/mozbuild/test/frontend/test_emitter.py index e0f4a8e3ec0..492b5299544 100644 --- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py +++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py @@ -10,6 +10,7 @@ import unittest from mozunit import main from mozbuild.frontend.data import ( + BrandingFiles, ConfigFileSubstitution, Defines, DistFiles, @@ -345,6 +346,23 @@ class TestEmitterBasic(unittest.TestCase): overwrite = resources._children['overwrite'] self.assertEqual(overwrite._strings, ['new.res']) + def test_branding_files(self): + reader = self.reader('branding-files') + objs = self.read_topsrcdir(reader) + + self.assertEqual(len(objs), 1) + self.assertIsInstance(objs[0], BrandingFiles) + + files = objs[0].files + + self.assertEqual(files._strings, ['app.ico', 'bar.ico', 'baz.png', 'foo.xpm']) + self.assertEqual(files['app.ico'].source, 'test/bar.ico') + + self.assertIn('icons', files._children) + icons = files._children['icons'] + + self.assertEqual(icons._strings, ['quux.icns']) + def test_preferences_js(self): reader = self.reader('js_preference_files') objs = self.read_topsrcdir(reader) diff --git a/xulrunner/app/Makefile.in b/xulrunner/app/Makefile.in index 8486ebb2d96..98e377d69c8 100644 --- a/xulrunner/app/Makefile.in +++ b/xulrunner/app/Makefile.in @@ -38,19 +38,6 @@ endif #export:: brand.dtd.in # $(call py_action,preprocessor,$(DEFINES) $(ACDEFINES) $^ -o brand.dtd) -export:: - $(NSINSTALL) -D $(DIST)/branding -ifeq ($(OS_ARCH),WINNT) - cp $(srcdir)/xulrunner.ico $(DIST)/branding/xulrunner.ico - cp $(srcdir)/xulrunner.ico $(DIST)/branding/app.ico - cp $(srcdir)/document.ico $(DIST)/branding/document.ico -endif -ifdef MOZ_WIDGET_GTK - cp $(srcdir)/default16.png $(DIST)/branding/default16.png - cp $(srcdir)/default32.png $(DIST)/branding/default32.png - cp $(srcdir)/default48.png $(DIST)/branding/default48.png -endif - ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) FRAMEWORK_NAME = XUL diff --git a/xulrunner/app/moz.build b/xulrunner/app/moz.build index 541738e2cb2..791bdba9bd9 100644 --- a/xulrunner/app/moz.build +++ b/xulrunner/app/moz.build @@ -60,3 +60,17 @@ JS_PREFERENCE_FILES += [ 'xulrunner.js', ] +if CONFIG['OS_ARCH'] == 'WINNT': + BRANDING_FILES += [ + 'app.ico', + 'document.ico', + 'xulrunner.ico', + ] + BRANDING_FILES['app.ico'].source = 'xulrunner.ico' + +if CONFIG['MOZ_WIDGET_GTK']: + BRANDING_FILES += [ + 'default16.png', + 'default32.png', + 'default48.png', + ]