Bug 1234780 - Use Paths for BRANDING_FILES. r=gps

Also, handle them like other FinalTargetFiles.

After this, TEST_HARNESS_FILES is the last use of plain HierarchicalStringList.
This commit is contained in:
Mike Hommey 2015-12-23 17:30:32 +09:00
parent ae9f999513
commit f8abc7adc8
13 changed files with 66 additions and 87 deletions

View File

@ -10,3 +10,4 @@ DIST_SUBDIR = 'browser'
export('DIST_SUBDIR')
include('../branding-common.mozbuild')
FirefoxBranding()

View File

@ -4,40 +4,42 @@
# 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 += [
'/%s/pref/firefox-branding.js' % CONFIG['MOZ_BRANDING_DIRECTORY'],
]
@template
def FirefoxBranding():
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',
]
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',
]

View File

@ -10,3 +10,4 @@ DIST_SUBDIR = 'browser'
export('DIST_SUBDIR')
include('../branding-common.mozbuild')
FirefoxBranding()

View File

@ -10,3 +10,4 @@ DIST_SUBDIR = 'browser'
export('DIST_SUBDIR')
include('../branding-common.mozbuild')
FirefoxBranding()

View File

@ -10,3 +10,4 @@ DIST_SUBDIR = 'browser'
export('DIST_SUBDIR')
include('../branding-common.mozbuild')
FirefoxBranding()

View File

@ -527,9 +527,6 @@ class RecursiveMakeBackend(CommonBackend):
elif isinstance(obj, TestHarnessFiles):
self._process_test_harness_files(obj, backend_file)
elif isinstance(obj, BrandingFiles):
self._process_branding_files(obj, obj.files, backend_file)
elif isinstance(obj, JARManifest):
backend_file.write('JAR_MANIFEST := %s\n' % obj.path)
@ -929,21 +926,6 @@ class RecursiveMakeBackend(CommonBackend):
for tier in set(self._no_skip.keys()) & affected_tiers:
self._no_skip[tier].add(backend_file.relobjdir)
def _walk_hierarchy(self, obj, element, namespace=''):
"""Walks the ``HierarchicalStringList`` ``element`` in the context of
the mozbuild object ``obj`` as though by ``element.walk()``, but yield
tuple containing the following:
- ``source`` - The path to the source file named by the current string
- ``dest`` - The relative path, including the namespace, of the
destination file.
"""
for path, strings in element.walk():
for s in strings:
source = mozpath.normpath(mozpath.join(obj.srcdir, s))
dest = mozpath.join(namespace, path, mozpath.basename(s))
yield source, dest
def _process_defines(self, obj, backend_file, which='DEFINES'):
"""Output the DEFINES rules to the given backend file."""
defines = list(obj.get_defines())
@ -974,20 +956,6 @@ INSTALL_TARGETS += %(prefix)s
'files': ' '.join(mozpath.relpath(f, backend_file.objdir)
for f in files) })
def _process_branding_files(self, obj, files, backend_file):
for source, dest in self._walk_hierarchy(obj, files):
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
@ -1290,6 +1258,7 @@ INSTALL_TARGETS += %(prefix)s
'dist/xpi-stage',
'_tests',
'dist/include',
'dist/branding',
))
if not path:
raise Exception("Cannot install to " + target)
@ -1298,6 +1267,14 @@ INSTALL_TARGETS += %(prefix)s
install_manifest = self._install_manifests[manifest]
reltarget = mozpath.relpath(target, path)
# Also emit the necessary rules to create $(DIST)/branding during
# partial tree builds. The locale makefiles rely on this working.
if path == 'dist/branding':
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')
for path, files in files.walk():
target_var = (mozpath.join(target, path)
if path else target).replace('/', '_')

View File

@ -1191,7 +1191,7 @@ VARIABLES = {
This variable can only be used on Linux.
""", None),
'BRANDING_FILES': (HierarchicalStringList, list,
'BRANDING_FILES': (ContextDerivedTypedHierarchicalStringList(Path), list,
"""List of files to be installed into the branding directory.
``BRANDING_FILES`` will copy (or symlink, if the platform supports it)

View File

@ -206,20 +206,6 @@ class TestHarnessFiles(ContextDerived):
self.srcdir_pattern_files = srcdir_pattern_files
self.objdir_files = objdir_files
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 IPDLFile(ContextDerived):
"""Describes an individual .ipdl source file."""
@ -826,6 +812,19 @@ class Exports(FinalTargetFiles):
return 'dist/include'
class BrandingFiles(FinalTargetFiles):
"""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.
"""
@property
def install_target(self):
return 'dist/branding'
class GeneratedFile(ContextDerived):
"""Represents a generated file."""

View File

@ -645,6 +645,7 @@ class TreeMetadataEmitter(LoggingMixin):
components = []
for var, cls in (
('BRANDING_FILES', BrandingFiles),
('EXPORTS', Exports),
('FINAL_TARGET_FILES', FinalTargetFiles),
('FINAL_TARGET_PP_FILES', FinalTargetPreprocessedFiles),
@ -719,10 +720,6 @@ class TreeMetadataEmitter(LoggingMixin):
Manifest('components',
mozpath.basename(c)))
branding_files = context.get('BRANDING_FILES')
if branding_files:
yield BrandingFiles(context, branding_files)
for obj in self._handle_libraries(context):
yield obj