Use the configuration as dictionary, and add stub for auto-debuild system
[mass-build.git] / build_system.py
index e18d9ffa98545ca16fab9ccfece768b931cea020..073d432663ee5143f3c49831e18f0bca3747690c 100644 (file)
@@ -7,14 +7,13 @@ class CMake:
        def __init__(self, sourceFolder, buildFolder, config):
                self.sourceFolder = os.path.abspath(sourceFolder)
                self.buildFolder = os.path.abspath(buildFolder)
-               self.installDir = config.installDir
-               self.buildType = config.buildType
-               self.jobs = config.jobs
-               self.buildCmdPrefix = config.buildCmdPrefix
-               self.installCmdPrefix = config.installCmdPrefix
+               self.installDir = config['installDir']
+               self.buildType = config['buildType']
+               self.jobs = config['jobs']
+               self.buildCmdPrefix = config['buildCmdPrefix']
+               self.installCmdPrefix = config['installCmdPrefix']
        
        def configure(self, force=False):
-               print "Configuring",self.sourceFolder
                if not os.path.exists(self.buildFolder): os.makedirs(self.buildFolder)
                os.chdir(self.buildFolder)
                # check if we actually need to work
@@ -27,13 +26,27 @@ class CMake:
                os.unsetenv('PKG_CONFIG_PATH')
        
        def build(self):
-               print "Building",self.sourceFolder
                os.chdir(self.buildFolder)
                subprocess.check_call(self.buildCmdPrefix + ['make', '-j'+str(self.jobs)])
        
        def install(self):
-               print "Installing",self.sourceFolder
                os.chdir(self.buildFolder)
                subprocess.check_call(self.installCmdPrefix + ['make', 'install'])
 
-# TODO: class Debian, which creates & install a debian package
+# if auto-debuild is available, provide a wrapper for it
+try:
+       import auto_debuild
+       class AutoDebuild:
+               def __init__(self, sourceFolder, module):
+                       self.autoDebuildConfig = {}
+
+               def configure(self, force=False): # force is ignored
+                       self.files = auto_debuild.createDebianFiles(self.autoDebuildConfig)
+
+               def build(self):
+                       auto_debuild.buildDebianPackage(self.autoDebuildConfig)
+
+               def install(self):
+                       subprocess.check_call(['sudo', 'dpkg', '--install'] + self.files)
+except ImportError:
+       pass