Bug 1252301 - allow installing CONFIGURE_SUBST_FILES; r?glandium draft
authorMike Shal <mshal@mozilla.com>
Mon, 29 Feb 2016 16:49:59 -0500
changeset 335608 5224dd9684b85f8d4ae63f30a0eba9e6de628978
parent 335409 9da51cb4974e03cdd8fa45a34086fe1033abfeaf
child 515175 a61687291da82563008bf7f787e9f8eed458ddc5
push id11830
push userbmo:mshal@mozilla.com
push dateTue, 01 Mar 2016 00:37:52 +0000
reviewersglandium
bugs1252301
milestone47.0a1
Bug 1252301 - allow installing CONFIGURE_SUBST_FILES; r?glandium We need to consider CONFIGURE_SUBST_FILES as generated files when processing FinalTargetFiles and related variables. Additionally, we have to make sure that we actually recurse into such directories during the export phase. MozReview-Commit-ID: 6ZwHMzjoT6t
python/mozbuild/mozbuild/backend/recursivemake.py
python/mozbuild/mozbuild/frontend/emitter.py
python/mozbuild/mozbuild/test/backend/data/install_substitute_config_files/moz.build
python/mozbuild/mozbuild/test/backend/data/install_substitute_config_files/sub/foo.h.in
python/mozbuild/mozbuild/test/backend/data/install_substitute_config_files/sub/moz.build
python/mozbuild/mozbuild/test/backend/test_recursivemake.py
--- a/python/mozbuild/mozbuild/backend/recursivemake.py
+++ b/python/mozbuild/mozbuild/backend/recursivemake.py
@@ -1270,16 +1270,17 @@ INSTALL_TARGETS += %(prefix)s
                 if not isinstance(f, ObjDirPath):
                     install_manifest.add_symlink(f.full_path, dest)
                 else:
                     install_manifest.add_optional_exists(dest)
                     backend_file.write('%s_FILES += %s\n' % (
                         target_var, self._pretty_path(f, backend_file)))
                     have_objdir_files = True
             if have_objdir_files:
+                self._no_skip['export'].add(backend_file.relobjdir)
                 backend_file.write('%s_DEST := $(DEPTH)/%s\n'
                                    % (target_var,
                                       mozpath.join(target, path)))
                 backend_file.write('%s_TARGET := export\n' % target_var)
                 backend_file.write('INSTALL_TARGETS += %s\n' % target_var)
 
     def _process_final_target_pp_files(self, obj, files, backend_file):
         # Bug 1177710 - We'd like to install these via manifests as
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -706,20 +706,16 @@ class TreeMetadataEmitter(LoggingMixin):
         # early.
         if any(k in context for k in ('FINAL_TARGET', 'XPI_NAME', 'DIST_SUBDIR')):
             yield InstallationTarget(context)
 
         # We always emit a directory traversal descriptor. This is needed by
         # the recursive make backend.
         for o in self._emit_directory_traversal_from_context(context): yield o
 
-        for path in context['CONFIGURE_SUBST_FILES']:
-            yield self._create_substitution(ConfigFileSubstitution, context,
-                path)
-
         for obj in self._process_xpidl(context):
             yield obj
 
         # Proxy some variables as-is until we have richer classes to represent
         # them. We should aim to keep this set small because it violates the
         # desired abstraction of the build definition away from makefiles.
         passthru = VariablePassthru(context)
         varlist = [
@@ -783,16 +779,22 @@ class TreeMetadataEmitter(LoggingMixin):
             # Use a list, like MOZBUILD_*FLAGS variables
             passthru.variables['RTL_FLAGS'] = [rtl_flag]
 
         generated_files = set()
         for obj in self._process_generated_files(context):
             generated_files.add(obj.output)
             yield obj
 
+        for path in context['CONFIGURE_SUBST_FILES']:
+            sub = self._create_substitution(ConfigFileSubstitution, context,
+                path)
+            generated_files.add(str(sub.relpath))
+            yield sub
+
         for obj in self._process_test_harness_files(context):
             yield obj
 
         defines = context.get('DEFINES')
         if defines:
             yield Defines(context, defines)
 
         host_defines = context.get('HOST_DEFINES')
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/test/backend/data/install_substitute_config_files/moz.build
@@ -0,0 +1,6 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+# We want to test recursion into the subdir, so do the real work in 'sub'
+DIRS += ['sub']
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/test/backend/data/install_substitute_config_files/sub/foo.h.in
@@ -0,0 +1,1 @@
+#define MOZ_FOO @MOZ_FOO@
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/test/backend/data/install_substitute_config_files/sub/moz.build
@@ -0,0 +1,7 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+CONFIGURE_SUBST_FILES = ['foo.h']
+
+EXPORTS.out += ['!foo.h']
--- a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py
+++ b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py
@@ -258,16 +258,27 @@ class TestRecursiveMakeBackend(BackendTe
 
         p = mozpath.join(env.topobjdir, 'foo')
         self.assertTrue(os.path.exists(p))
         lines = [l.strip() for l in open(p, 'rt').readlines()]
         self.assertEqual(lines, [
             'TEST = foo',
         ])
 
+    def test_install_substitute_config_files(self):
+        """Ensure we recurse into the dirs that install substituted config files."""
+        env = self._consume('install_substitute_config_files', RecursiveMakeBackend)
+
+        root_deps_path = mozpath.join(env.topobjdir, 'root-deps.mk')
+        lines = [l.strip() for l in open(root_deps_path, 'rt').readlines()]
+
+        # Make sure we actually recurse into the sub directory during export to
+        # install the subst file.
+        self.assertTrue(any(l == 'recurse_export: sub/export' for l in lines))
+
     def test_variable_passthru(self):
         """Ensure variable passthru is written out correctly."""
         env = self._consume('variable_passthru', RecursiveMakeBackend)
 
         backend_path = mozpath.join(env.topobjdir, 'backend.mk')
         lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]
 
         expected = {