summaryrefslogtreecommitdiff
path: root/morphlib
diff options
context:
space:
mode:
authorRichard Dale <richard.dale@codethink.co.uk>2013-05-21 11:11:04 +0100
committerRichard Dale <richard.dale@codethink.co.uk>2013-05-29 16:13:48 +0100
commit70f21759d03cfc930d26f8abac0d56a8279276b8 (patch)
tree54fd95dd8450536cc8c359498227c52ce5964a2d /morphlib
parent5a29d98c43fdb637947af893b8604b5d6adcd113 (diff)
downloadmorph-70f21759d03cfc930d26f8abac0d56a8279276b8.tar.gz
Add detection for cmake and qmake build systems
Add tests for cmake and qmake build systems
Diffstat (limited to 'morphlib')
-rw-r--r--morphlib/buildsystem.py57
-rw-r--r--morphlib/buildsystem_tests.py51
2 files changed, 108 insertions, 0 deletions
diff --git a/morphlib/buildsystem.py b/morphlib/buildsystem.py
index a6645eb2..90cc15c2 100644
--- a/morphlib/buildsystem.py
+++ b/morphlib/buildsystem.py
@@ -197,12 +197,69 @@ class CPANBuildSystem(BuildSystem):
return any(x in file_list for x in indicators)
+class CMakeBuildSystem(BuildSystem):
+
+ '''The cmake build system.'''
+
+ name = 'cmake'
+
+ def __init__(self):
+ BuildSystem.__init__(self)
+ self.configure_commands = [
+ 'cmake -DCMAKE_INSTALL_PREFIX=/usr'
+ ]
+ self.build_commands = [
+ 'make',
+ ]
+ self.test_commands = [
+ ]
+ self.install_commands = [
+ 'make DESTDIR="$DESTDIR" install',
+ ]
+
+ def used_by_project(self, file_list):
+ indicators = [
+ 'CMakeLists.txt',
+ ]
+
+ return any(x in file_list for x in indicators)
+
+class QMakeBuildSystem(BuildSystem):
+
+ '''The Qt build system.'''
+
+ name = 'qmake'
+
+ def __init__(self):
+ BuildSystem.__init__(self)
+ self.configure_commands = [
+ 'qmake -makefile '
+ ]
+ self.build_commands = [
+ 'make',
+ ]
+ self.test_commands = [
+ ]
+ self.install_commands = [
+ 'make INSTALL_ROOT="$DESTDIR" install',
+ ]
+
+ def used_by_project(self, file_list):
+ indicator = '.pro'
+
+ for x in file_list:
+ if x.endswith(indicator):
+ return True
+
+ return False
build_systems = [
ManualBuildSystem(),
AutotoolsBuildSystem(),
PythonDistutilsBuildSystem(),
CPANBuildSystem(),
+ CMakeBuildSystem(),
+ QMakeBuildSystem(),
DummyBuildSystem(),
]
diff --git a/morphlib/buildsystem_tests.py b/morphlib/buildsystem_tests.py
index d1095037..f5505ddd 100644
--- a/morphlib/buildsystem_tests.py
+++ b/morphlib/buildsystem_tests.py
@@ -28,6 +28,8 @@ def touch(pathname):
manual_project = []
autotools_project = ['configure.in']
+qmake_project = ['foo.pro']
+cmake_project = ['CMakeLists.txt']
class BuildSystemTests(unittest.TestCase):
@@ -64,6 +66,12 @@ class ManualBuildSystemTests(unittest.TestCase):
def test_does_not_autodetect_autotools(self):
self.assertFalse(self.bs.used_by_project(autotools_project))
+ def test_does_not_autodetect_qmake(self):
+ self.assertFalse(self.bs.used_by_project(qmake_project))
+
+ def test_does_not_autodetect_cmake(self):
+ self.assertFalse(self.bs.used_by_project(cmake_project))
+
class DummyBuildSystemTests(unittest.TestCase):
@@ -76,6 +84,12 @@ class DummyBuildSystemTests(unittest.TestCase):
def test_does_not_autodetect_autotools(self):
self.assertFalse(self.bs.used_by_project(autotools_project))
+ def test_does_not_autodetect_cmake(self):
+ self.assertFalse(self.bs.used_by_project(cmake_project))
+
+ def test_does_not_autodetect_qmake(self):
+ self.assertFalse(self.bs.used_by_project(qmake_project))
+
class AutotoolsBuildSystemTests(unittest.TestCase):
@@ -88,6 +102,27 @@ class AutotoolsBuildSystemTests(unittest.TestCase):
def test_autodetects_autotools(self):
self.assertTrue(self.bs.used_by_project(autotools_project))
+class CMakeBuildSystemTests(unittest.TestCase):
+
+ def setUp(self):
+ self.bs = morphlib.buildsystem.CMakeBuildSystem()
+
+ def test_does_not_autodetect_empty(self):
+ self.assertFalse(self.bs.used_by_project(manual_project))
+
+ def test_autodetects_cmake(self):
+ self.assertTrue(self.bs.used_by_project(cmake_project))
+
+class QMakeBuildSystemTests(unittest.TestCase):
+
+ def setUp(self):
+ self.bs = morphlib.buildsystem.QMakeBuildSystem()
+
+ def test_does_not_autodetect_empty(self):
+ self.assertFalse(self.bs.used_by_project(manual_project))
+
+ def test_autodetects_qmake(self):
+ self.assertTrue(self.bs.used_by_project(qmake_project))
class DetectBuildSystemTests(unittest.TestCase):
@@ -99,6 +134,14 @@ class DetectBuildSystemTests(unittest.TestCase):
bs = morphlib.buildsystem.detect_build_system(autotools_project)
self.assertEqual(type(bs), morphlib.buildsystem.AutotoolsBuildSystem)
+ def test_autodetects_cmake(self):
+ bs = morphlib.buildsystem.detect_build_system(cmake_project)
+ self.assertEqual(type(bs), morphlib.buildsystem.CMakeBuildSystem)
+
+ def test_autodetects_qmake(self):
+ bs = morphlib.buildsystem.detect_build_system(qmake_project)
+ self.assertEqual(type(bs), morphlib.buildsystem.QMakeBuildSystem)
+
class LookupBuildSystemTests(unittest.TestCase):
@@ -116,6 +159,14 @@ class LookupBuildSystemTests(unittest.TestCase):
self.assertEqual(type(self.lookup('autotools')),
morphlib.buildsystem.AutotoolsBuildSystem)
+ def test_looks_up_cmake(self):
+ self.assertEqual(type(self.lookup('cmake')),
+ morphlib.buildsystem.CMakeBuildSystem)
+
+ def test_looks_up_qmake(self):
+ self.assertEqual(type(self.lookup('qmake')),
+ morphlib.buildsystem.QMakeBuildSystem)
+
def test_looks_up_dummy(self):
self.assertEqual(type(self.lookup('dummy')),
morphlib.buildsystem.DummyBuildSystem)