[jhbuild] cmake: add force-non-srcdir-builds



commit 36c637705c1444b93c87d0b46dda21848a56cc56
Author: Dmitry Shachnev <mitya57 gmail com>
Date:   Wed Jan 28 17:47:13 2015 +0300

    cmake: add force-non-srcdir-builds
    
    Add force-non-srcdir-builds attribute. This will allow one to mark
    module as "out-of-source" build only. JHBuild will never try to
    build such modules in source directory.
    
    Done-with: Alberts Muktupāvels <alberts muktupavels gmail com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742475

 doc/C/index.docbook       |    7 ++++++-
 jhbuild/modtypes/cmake.py |   14 ++++++++++----
 2 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/doc/C/index.docbook b/doc/C/index.docbook
index 413befe..e82bda0 100644
--- a/doc/C/index.docbook
+++ b/doc/C/index.docbook
@@ -2781,7 +2781,8 @@ Optional packages: (JHBuild will build the missing packages)
              [ uninstall-before-install="<replaceable>uninstall-before-install</replaceable>" ]
              [ autogen-template="<replaceable>autogen-template</replaceable>" ]
              [ check-target="<replaceable>check-target</replaceable>" ]
-             [ supports-non-srcdir-builds="<replaceable>supports-non-srcdir-builds</replaceable>" ]&gt;
+             [ supports-non-srcdir-builds="<replaceable>supports-non-srcdir-builds</replaceable>" ]
+             [ force-non-srcdir-builds="<replaceable>force-non-srcdir-builds</replaceable>" ]&gt;
 
   &lt;branch [ ... ] &gt;
     [...]
@@ -2836,6 +2837,10 @@ Optional packages: (JHBuild will build the missing packages)
           attribute is used to mark modules that can't be cleanly built using a
           separate source directory.</para>
 
+        <para>The <sgmltag class="attribute">force-non-srcdir-builds</sgmltag>
+          attribute is used to mark modules that can't be cleanly built from
+          the source directory, but can be built from outside it.</para>
+
         <para>The <sgmltag class="attribute">autogen-template</sgmltag>
           attribute can be used if you need finer control over the autogen
           command line. It is a python format string, which will be substituted
diff --git a/jhbuild/modtypes/cmake.py b/jhbuild/modtypes/cmake.py
index 1d4e752..688dc1b 100644
--- a/jhbuild/modtypes/cmake.py
+++ b/jhbuild/modtypes/cmake.py
@@ -44,6 +44,7 @@ class CMakeModule(MakeModule, DownloadableModule):
         MakeModule.__init__(self, name, branch=branch, makeargs=makeargs)
         self.cmakeargs = cmakeargs
         self.supports_non_srcdir_builds = True
+        self.force_non_srcdir_builds = False
         self.supports_install_destdir = True
 
     def eval_args(self, args):
@@ -55,12 +56,14 @@ class CMakeModule(MakeModule, DownloadableModule):
         return self.branch.srcdir
 
     def get_builddir(self, buildscript):
+        builddir = self.get_srcdir(buildscript)
         if buildscript.config.buildroot and self.supports_non_srcdir_builds:
             d = buildscript.config.builddir_pattern % (
                 self.branch.checkoutdir or self.branch.get_module_basename())
-            return os.path.join(buildscript.config.buildroot, d)
-        else:
-            return self.get_srcdir(buildscript)
+            builddir = os.path.join(buildscript.config.buildroot, d)
+        if self.force_non_srcdir_builds and builddir == self.get_srcdir(buildscript):
+            builddir = os.path.join(builddir, 'build')
+        return builddir
 
     def get_cmakeargs(self):
         args = '%s %s' % (self.cmakeargs,
@@ -72,7 +75,7 @@ class CMakeModule(MakeModule, DownloadableModule):
         buildscript.set_action(_('Configuring'), self)
         srcdir = self.get_srcdir(buildscript)
         builddir = self.get_builddir(buildscript)
-        if buildscript.config.buildroot and not os.path.exists(builddir):
+        if not os.path.exists(builddir):
             os.makedirs(builddir)
         prefix = os.path.expanduser(buildscript.config.prefix)
         if not inpath('cmake', os.environ['PATH'].split(os.pathsep)):
@@ -145,6 +148,9 @@ def parse_cmake(node, config, uri, repositories, default_repo):
     if node.hasAttribute('supports-non-srcdir-builds'):
         instance.supports_non_srcdir_builds = \
                 (node.getAttribute('supports-non-srcdir-builds') != 'no')
+    if node.hasAttribute('force-non-srcdir-builds'):
+        instance.force_non_srcdir_builds = \
+                (node.getAttribute('force-non-srcdir-builds') != 'no')
     if node.hasAttribute('cmakeargs'):
         instance.cmakeargs = node.getAttribute('cmakeargs')
     if node.hasAttribute('makeargs'):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]