Bug 1382697 - Honor file install mode when processing install manifests; r=glandium
Now that configure determines what file install mode is preferred, we
can start honoring it.
This commit adds a helper function to return an appropriate
InstallManifest instance based on a configured install mode.
The "process_install_manifest" build action is changed to call this
function with configure's preferred install mode.
This means that all install manifests in the build system now honor
--with-file-install-mode. So --with-file-install-mode=copy can be
used to disable symlinks. This can be used to restore the old
SpiderMonkey behavior broken by the previous commit in this series.
MozReview-Commit-ID: 4f7bL4Qtn6W
--- a/python/mozbuild/mozbuild/action/process_install_manifest.py
+++ b/python/mozbuild/mozbuild/action/process_install_manifest.py
@@ -4,64 +4,68 @@
from __future__ import absolute_import, print_function, unicode_literals
import argparse
import os
import sys
import time
+import buildconfig
+
from mozpack.copier import (
FileCopier,
FileRegistry,
)
from mozpack.files import (
BaseFile,
FileFinder,
)
from mozpack.manifests import (
- InstallManifest,
+ get_install_manifest,
)
from mozbuild.util import DefinesAction
COMPLETE = 'Elapsed: {elapsed:.2f}s; From {dest}: Kept {existing} existing; ' \
'Added/updated {updated}; ' \
'Removed {rm_files} files and {rm_dirs} directories.'
def process_manifest(destdir, paths, track=None,
remove_unaccounted=True,
remove_all_directory_symlinks=True,
remove_empty_directories=True,
defines={}):
+ install_mode = buildconfig.substs['FILE_INSTALL_MODE']
+
if track:
if os.path.exists(track):
# We use the same format as install manifests for the tracking
# data.
- manifest = InstallManifest(path=track)
+ manifest = get_install_manifest(install_mode, path=track)
remove_unaccounted = FileRegistry()
dummy_file = BaseFile()
finder = FileFinder(destdir, find_dotfiles=True)
for dest in manifest._dests:
for p, f in finder.find(dest):
remove_unaccounted.add(p, dummy_file)
else:
# If tracking is enabled and there is no file, we don't want to
# be removing anything.
remove_unaccounted=False
remove_empty_directories=False
remove_all_directory_symlinks=False
- manifest = InstallManifest()
+ manifest = get_install_manifest(install_mode)
for path in paths:
- manifest |= InstallManifest(path=path)
+ manifest |= get_install_manifest(install_mode, path=path)
copier = FileCopier()
manifest.populate_registry(copier, defines_override=defines)
result = copier.copy(destdir,
remove_unaccounted=remove_unaccounted,
remove_all_directory_symlinks=remove_all_directory_symlinks,
remove_empty_directories=remove_empty_directories)
--- a/python/mozbuild/mozpack/manifests.py
+++ b/python/mozbuild/mozpack/manifests.py
@@ -412,8 +412,26 @@ class InstallManifestNoSymlinks(InstallM
"""A wrapper that accept symlink entries and install file copies.
source will be copied to dest.
"""
self.add_copy(source, dest)
def add_pattern_symlink(self, base, pattern, dest):
self.add_pattern_copy(base, pattern, dest)
+
+
+def get_install_manifest(mode, *args, **kwargs):
+ """Obtain an install manifest instance using an appropriate install policy.
+
+ Configure determines what file install support is wanted. This function
+ returns an install manifest taking configure's wishes into account.
+ Essentially, links in the underlying manifest are converted to copies if
+ links aren't supported or desired.
+
+ ``mode`` shoulde be the value of config.status's subst['FILE_INSTALL_MODE']
+ """
+ if mode == 'copy':
+ return InstallManifestNoSymlinks(*args, **kwargs)
+ elif mode == 'symlink':
+ return InstallManifest(*args, **kwargs)
+ else:
+ raise ValueError('unsupported file install mode: %s' % mode)