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']
15 self.cmakeParameters = module.get('cmakeParameters', [])
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.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 buildSystem = module.get('build-system', 'cmake')
41 self.autoDebuildConfig = {
42 'sourceName': module['name'],
43 'debDir': os.path.abspath(config['debDir']),
44 'buildSystem': buildSystem,
45 'buildDir': os.path.abspath(buildFolder),
46 'name': config['debName'],
47 'email': config['debEMail'],
49 self.copyOption(config, 'jobs', 'parallelJobs')
50 self.copyOption(module, 'dbgPackage')
51 self.copyOption(module, 'skipFiles', 'binarySkipFiles')
52 self.copyOption(module, 'installFiles', 'binaryInstall')
53 self.copyOption(module, 'buildDepends')
54 self.copyOption(module, 'binaryDepends')
55 self.copyOption(module, 'binaryRecommends')
56 if buildSystem == 'cmake':
57 self.copyOption(module, 'cmakeParameters')
60 def copyOption(self, src, name, dstName = None):
61 if dstName is None: dstName = name # per default, stick with original name
63 self.autoDebuildConfig[dstName] = src[name]
65 def build(self, reconfigure=False): # reconfigure is ignored (we always do a reconfiguration)
66 # Get us a version number
67 self.autoDebuildConfig['version'] = self.vcs.version() # by now, data has been fetched, so this is possible
68 if self.autoDebuildConfig['version'] is None:
69 raise Exception("VCS did not provide us with a proper version, please fix this")
71 os.chdir(self.sourceFolder)
72 files = auto_debuild.createDebianFiles(self.autoDebuildConfig)
74 auto_debuild.buildDebianPackage(self.autoDebuildConfig)
76 subprocess.check_call(['sudo', 'dpkg', '--install'] + files)
79 print "auto_debuild not found, disabling auto-debuild system"