summaryrefslogtreecommitdiff
path: root/morphlib/buildsystem.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2012-08-24 18:05:16 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2012-08-24 18:05:16 +0100
commit3525f81ecea60f53d3ef842c1e11c4cab1538511 (patch)
treeea49c69e6baa1a000c78b3156eb5965c72ed68fd /morphlib/buildsystem.py
parent98b802e36b2a291b39dbdb83b55546b1acae1573 (diff)
downloadmorph-3525f81ecea60f53d3ef842c1e11c4cab1538511.tar.gz
Refactor build system code for easier testing
Diffstat (limited to 'morphlib/buildsystem.py')
-rw-r--r--morphlib/buildsystem.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/morphlib/buildsystem.py b/morphlib/buildsystem.py
index 86eac850..6287063a 100644
--- a/morphlib/buildsystem.py
+++ b/morphlib/buildsystem.py
@@ -55,7 +55,7 @@ class BuildSystem(object):
'bs': self.name,
}
- def used_by_project(self, exists):
+ def used_by_project(self, file_list):
'''Does a project use this build system?
``exists`` is a function that returns a boolean telling if a
@@ -71,7 +71,7 @@ class ManualBuildSystem(BuildSystem):
name = 'manual'
- def used_by_project(self, exists):
+ def used_by_project(self, file_list):
return False
@@ -87,7 +87,7 @@ class DummyBuildSystem(BuildSystem):
self.test_commands = ['echo dummy test']
self.install_commands = ['echo dummy install']
- def used_by_project(self, exists):
+ def used_by_project(self, file_list):
return False
@@ -114,7 +114,7 @@ class AutotoolsBuildSystem(BuildSystem):
'make DESTDIR="$DESTDIR" install',
]
- def used_by_project(self, exists):
+ def used_by_project(self, file_list):
indicators = [
'autogen',
'autogen.sh',
@@ -124,7 +124,7 @@ class AutotoolsBuildSystem(BuildSystem):
'configure.in.in',
]
- return any(exists(x) for x in indicators)
+ return any(x in file_list for x in indicators)
class PythonDistutilsBuildSystem(BuildSystem):
@@ -145,12 +145,12 @@ class PythonDistutilsBuildSystem(BuildSystem):
'python setup.py install --prefix "$PREFIX" --root "$DESTDIR"',
]
- def used_by_project(self, exists):
+ def used_by_project(self, file_list):
indicators = [
'setup.py',
]
- return any(exists(x) for x in indicators)
+ return any(x in file_list for x in indicators)
class CPANBuildSystem(BuildSystem):
@@ -178,12 +178,12 @@ class CPANBuildSystem(BuildSystem):
'make DESTDIR="$DESTDIR" install',
]
- def used_by_project(self, exists):
+ def used_by_project(self, file_list):
indicators = [
'Makefile.PL',
]
- return any(exists(x) for x in indicators)
+ return any(x in file_list for x in indicators)
build_systems = [
@@ -202,11 +202,8 @@ def detect_build_system(file_list):
For ``exists`` see the ``BuildSystem.exists`` method.
'''
- def exists(filename):
- return filename in file_list
-
for bs in build_systems:
- if bs.used_by_project(exists):
+ if bs.used_by_project(file_list):
return bs
return None