3 '''A build system has three methods: "configure" (with optionak "force" parameter), "build" and "install"'''
5 # Compile, build, and install cmake projects:
7 def __init__(self, sourceFolder, buildFolder, module, config):
8 self.sourceFolder = os.path.abspath(sourceFolder)
9 self.buildFolder = os.path.abspath(buildFolder)
10 self.installDir = config['installDir']
11 self.buildType = config['buildType']
12 self.jobs = config['jobs']
13 self.buildCmdPrefix = config['buildCmdPrefix']
14 self.installCmdPrefix = config['installCmdPrefix']
17 def build(self, reconfigure=False):
18 # Make sure we have a build directory
19 if not os.path.exists(self.buildFolder): os.makedirs(self.buildFolder)
20 os.chdir(self.buildFolder)
21 # In case of reconfiguration, delete cache file if it exists
22 cacheFile = 'CMakeCache.txt'
23 if os.path.exists(cacheFile) and reconfigure: os.remove(cacheFile)
25 os.putenv('PKG_CONFIG_PATH', os.path.join(self.installDir, 'lib', 'pkgconfig')) # I found no way to do this within cmake
26 subprocess.check_call(['cmake', self.sourceFolder, '-DCMAKE_BUILD_TYPE='+self.buildType,
27 '-DCMAKE_INSTALL_PREFIX='+self.installDir]+self.module.get('cmakeParameters', []))
28 os.unsetenv('PKG_CONFIG_PATH')
30 subprocess.check_call(self.buildCmdPrefix + ['make', '-j'+str(self.jobs)])
32 subprocess.check_call(self.installCmdPrefix + ['make', 'install'])
34 # if auto-debuild is available, provide a wrapper for it
38 def __init__(self, sourceFolder, buildFolder, module, vcs, config):
39 self.sourceFolder = os.path.abspath(sourceFolder)
40 self.buildFolder = os.path.abspath(buildFolder)
41 self.jobs = config['jobs']
42 self.debDir = os.path.abspath(config['debDir'])
43 self.debName = config['debName']
44 self.debEMail = config['debEMail']
48 def build(self, reconfigure=False): # reconfigure is ignored (we always do a reconfiguration)
49 # create auto-debuild configuration
51 'sourceName': self.module['name'],
52 'buildSystem': self.module['buildSystem'],
53 'debDir': self.debDir,
54 'buildDir': self.buildFolder,
56 'email': self.debEMail,
57 'parallelJobs': self.jobs,
58 'version': self.vcs.version()
60 if autoDebuildConfig['version'] is None:
61 raise Exception("VCS did not provide us with a proper version number, please fix this")
62 # copy some more optional configuration
63 for option in ('dbgPackage', 'binarySkipFiles', 'binaryInstallFiles', 'buildDepends', 'binaryDepends', 'binaryRecommends',
64 'binaryProvides', 'cmakeParameters', 'automakeParameters'):
65 if option in self.module:
66 autoDebuildConfig[option] = self.module[option]
68 os.chdir(self.sourceFolder)
69 files = auto_debuild.createDebianFiles(autoDebuildConfig)
71 auto_debuild.buildDebianPackage(autoDebuildConfig)
73 subprocess.check_call(['sudo', 'dpkg', '--install'] + files)
76 print "auto_debuild not found, disabling auto-debuild system"