projects
/
mass-build.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
10b1a87
)
Make config inherited
author
Ralf Jung
<post@ralfj.de>
Wed, 15 Aug 2012 10:47:32 +0000
(12:47 +0200)
committer
Ralf Jung
<post@ralfj.de>
Wed, 15 Aug 2012 10:47:32 +0000
(12:47 +0200)
build_system.py
patch
|
blob
|
history
mass_build.py
patch
|
blob
|
history
diff --git
a/build_system.py
b/build_system.py
index 197d7ac08feb3d84b83cb8aab89d151fa5bb690f..8325aeda98c62e2ddaba9c1d6cc5e71ee0b1eb13 100644
(file)
--- a/
build_system.py
+++ b/
build_system.py
@@
-4,16
+4,10
@@
import os, shutil, subprocess
# Compile, build, and install cmake projects:
class CMake:
# Compile, build, and install cmake projects:
class CMake:
- def __init__(self, sourceFolder, buildFolder,
projectConfig, globalC
onfig):
+ def __init__(self, sourceFolder, buildFolder,
c
onfig):
self.sourceFolder = os.path.abspath(sourceFolder)
self.buildFolder = os.path.abspath(buildFolder)
self.sourceFolder = os.path.abspath(sourceFolder)
self.buildFolder = os.path.abspath(buildFolder)
- self.installDir = globalConfig['installDir']
- self.buildType = globalConfig['buildType']
- self.jobs = globalConfig['jobs']
- self.buildCmdPrefix = globalConfig['buildCmdPrefix']
- self.installCmdPrefix = globalConfig['installCmdPrefix']
- self.waitAfterConfig = globalConfig.get('waitAfterConfig', False)
- self.projectConfig = projectConfig
+ self.config = config
def build(self, reconfigure=False):
# Make sure we have a build directory
def build(self, reconfigure=False):
# Make sure we have a build directory
@@
-23,54
+17,49
@@
class CMake:
cacheFile = 'CMakeCache.txt'
if os.path.exists(cacheFile) and reconfigure: os.remove(cacheFile)
# Run cmake
cacheFile = 'CMakeCache.txt'
if os.path.exists(cacheFile) and reconfigure: os.remove(cacheFile)
# Run cmake
- os.putenv('PKG_CONFIG_PATH', os.path.join(self.
installDir
, 'lib', 'pkgconfig')) # I found no way to do this within cmake
- subprocess.check_call(['cmake', self.sourceFolder, '-DCMAKE_BUILD_TYPE='+self.
buildType
,
- '-DCMAKE_INSTALL_PREFIX='+self.
installDir]+self.projectC
onfig.get('cmakeParameters', []))
+ os.putenv('PKG_CONFIG_PATH', os.path.join(self.
config['installDir']
, 'lib', 'pkgconfig')) # I found no way to do this within cmake
+ subprocess.check_call(['cmake', self.sourceFolder, '-DCMAKE_BUILD_TYPE='+self.
config['buildType']
,
+ '-DCMAKE_INSTALL_PREFIX='+self.
config['installDir']]+self.c
onfig.get('cmakeParameters', []))
os.unsetenv('PKG_CONFIG_PATH')
# if asked to do so, wait
os.unsetenv('PKG_CONFIG_PATH')
# if asked to do so, wait
- if self.
waitAfterConfig
:
+ if self.
config['waitAfterConfig']
:
raw_input('Configuration done. Hit "Enter" to build the project. ')
# run compilation
raw_input('Configuration done. Hit "Enter" to build the project. ')
# run compilation
- subprocess.check_call(self.
buildCmdPrefix + ['make', '-j'+str(self.jobs
)])
+ subprocess.check_call(self.
config['buildCmdPrefix'] + ['make', '-j'+str(self.config['jobs']
)])
# run installation
# run installation
- subprocess.check_call(self.
installCmdPrefix
+ ['make', 'install'])
+ subprocess.check_call(self.
config['installCmdPrefix']
+ ['make', 'install'])
# if auto-debuild is available, provide a wrapper for it
try:
import auto_debuild
class AutoDebuild:
# if auto-debuild is available, provide a wrapper for it
try:
import auto_debuild
class AutoDebuild:
- def __init__(self, sourceFolder, buildFolder,
projectConfig, vcs, globalConfig
):
+ def __init__(self, sourceFolder, buildFolder,
config, vcs
):
self.sourceFolder = os.path.abspath(sourceFolder)
self.buildFolder = os.path.abspath(buildFolder)
self.sourceFolder = os.path.abspath(sourceFolder)
self.buildFolder = os.path.abspath(buildFolder)
- self.jobs = globalConfig['jobs']
- self.debDir = os.path.abspath(globalConfig['debDir'])
- self.debName = globalConfig['debName']
- self.debEMail = globalConfig['debEMail']
- self.waitAfterConfig = globalConfig.get('waitAfterConfig', False)
- self.projectConfig = projectConfig
+ self.debFolder = os.path.abspath(config['debDir'])
+ self.config = config
self.vcs = vcs
def build(self, reconfigure=False): # reconfigure is ignored (we always do a reconfiguration)
# create auto-debuild configuration
autoDebuildConfig = {
self.vcs = vcs
def build(self, reconfigure=False): # reconfigure is ignored (we always do a reconfiguration)
# create auto-debuild configuration
autoDebuildConfig = {
- 'sourceName': self.
projectC
onfig['name'],
- 'buildSystem': self.
projectC
onfig['buildSystem'],
- 'debDir': self.deb
Di
r,
+ 'sourceName': self.
c
onfig['name'],
+ 'buildSystem': self.
c
onfig['buildSystem'],
+ 'debDir': self.deb
Folde
r,
'buildDir': self.buildFolder,
'buildDir': self.buildFolder,
- 'name': self.
debName
,
- 'email': self.
debEMail
,
- 'parallelJobs': self.
jobs
,
+ 'name': self.
config['debName']
,
+ 'email': self.
config['debEMail']
,
+ 'parallelJobs': self.
config['jobs']
,
'version': self.vcs.version(),
'version': self.vcs.version(),
- 'waitAfterConfig': self.waitAfterConfig,
}
if autoDebuildConfig['version'] is None:
raise Exception("VCS did not provide us with a proper version number, please fix this")
# copy some more optional configuration
}
if autoDebuildConfig['version'] is None:
raise Exception("VCS did not provide us with a proper version number, please fix this")
# copy some more optional configuration
- for option in ('dbgPackage', 'section', 'withPython2', 'binarySkipFiles', 'binaryInstallFiles',
+ for option in ('
waitAfterConfig', '
dbgPackage', 'section', 'withPython2', 'binarySkipFiles', 'binaryInstallFiles',
'buildDepends', 'binaryDepends', 'binaryRecommends', 'binaryProvides', 'binaryConflicts',
'buildDepends', 'binaryDepends', 'binaryRecommends', 'binaryProvides', 'binaryConflicts',
- 'cmakeParameters', 'automakeParameters'):
- if option in self.
projectC
onfig:
- autoDebuildConfig[option] = self.
projectC
onfig[option]
+ '
alternatives', '
cmakeParameters', 'automakeParameters'):
+ if option in self.
c
onfig:
+ autoDebuildConfig[option] = self.
c
onfig[option]
# create Debian files
os.chdir(self.sourceFolder)
if os.path.isdir('debian'): # clean previous build attempts
# create Debian files
os.chdir(self.sourceFolder)
if os.path.isdir('debian'): # clean previous build attempts
@@
-79,7
+68,8
@@
try:
# build package(s)
auto_debuild.buildDebianPackage(autoDebuildConfig)
# install package(s)
# build package(s)
auto_debuild.buildDebianPackage(autoDebuildConfig)
# install package(s)
- subprocess.check_call(['sudo', 'dpkg', '--install'] + files)
+ if self.config.get('debInstall', True):
+ subprocess.check_call(['sudo', 'dpkg', '--install'] + files)
except ImportError:
#print "auto_debuild not found, disabling auto-debuild system"
except ImportError:
#print "auto_debuild not found, disabling auto-debuild system"
diff --git
a/mass_build.py
b/mass_build.py
index ed47bacbf21bb3bbe0b004d5a3da8e5ef7853034..6bbba4c23d8429e9b48c618ac6c94fbc73246cd1 100755
(executable)
--- a/
mass_build.py
+++ b/
mass_build.py
@@
-5,24
+5,24
@@
from collections import OrderedDict
# an entire Project
class Project:
# an entire Project
class Project:
- def __init__(self, folder,
projectConfig, globalC
onfig):
+ def __init__(self, folder,
c
onfig):
self.folder = folder
self.folder = folder
- self.name =
projectC
onfig['name']
+ self.name =
c
onfig['name']
# VCS
# VCS
- vcsName =
projectC
onfig['vcs']
+ vcsName =
c
onfig['vcs']
if vcsName == 'git':
if vcsName == 'git':
- self.vcs = vcs.Git(self.sourceFolder(),
projectConfig['url'], projectC
onfig['version'])
+ self.vcs = vcs.Git(self.sourceFolder(),
config['url'], c
onfig['version'])
elif vcsName == 'svn':
elif vcsName == 'svn':
- self.vcs = vcs.SVN(self.sourceFolder(),
projectConfig['url'], projectC
onfig.get('versionName'))
+ self.vcs = vcs.SVN(self.sourceFolder(),
config['url'], c
onfig.get('versionName'))
else:
raise Exception("Unknown VCS type "+vcsName)
# build system
else:
raise Exception("Unknown VCS type "+vcsName)
# build system
- if
globalC
onfig.get('buildDeb', False):
- self.buildSystem = build_system.AutoDebuild(self.sourceFolder(), self.buildFolder(),
projectConfig, self.vcs, globalConfig
)
+ if
c
onfig.get('buildDeb', False):
+ self.buildSystem = build_system.AutoDebuild(self.sourceFolder(), self.buildFolder(),
config, self.vcs
)
else:
else:
- buildSystemName =
projectC
onfig['buildSystem']
+ buildSystemName =
c
onfig['buildSystem']
if buildSystemName == 'cmake':
if buildSystemName == 'cmake':
- self.buildSystem = build_system.CMake(self.sourceFolder(), self.buildFolder(),
projectConfig, globalC
onfig)
+ self.buildSystem = build_system.CMake(self.sourceFolder(), self.buildFolder(),
c
onfig)
else:
raise Exception("Unknown build system type "+buildSystemName)
else:
raise Exception("Unknown build system type "+buildSystemName)
@@
-70,16
+70,24
@@
def findInList(list, item):
return i
raise Exception("%s not found in list" % str(item))
return i
raise Exception("%s not found in list" % str(item))
+# copy all items which don't exist below, except for those in the exclude list
+def inherit(subConfig, superConfig, exclude = ('name', 'projects')):
+ for name in superConfig.keys():
+ if (not name in subConfig) and (not name in exclude):
+ subConfig[name] = superConfig[name]
+
# populate list of projects, return list of projects in that folder
# populate list of projects, return list of projects in that folder
-def loadProjects(
projects
, folder=''):
+def loadProjects(
config
, folder=''):
folderProjects = []
folderProjects = []
- for projectConfig in projects:
- if 'folder' in projectConfig: # a subpath
- folderProjects += loadProjects(projectConfig['projects'], os.path.join(folder, projectConfig['folder']))
+ for projectConfig in config['projects']:
+ assert 'name' in projectConfig # everything must have a name
+ inherit(projectConfig, config)
+ if 'projects' in projectConfig: # a subpath
+ folderProjects += loadProjects(projectConfig, os.path.join(folder, projectConfig['name']))
else: # a proper project
if projectConfig['name'] in allProjects:
else: # a proper project
if projectConfig['name'] in allProjects:
- raise Exception("Duplicate project name "+project['name'])
- project = Project(folder, projectConfig
, config
)
+ raise Exception("Duplicate project name "+project
Config
['name'])
+ project = Project(folder, projectConfig)
allProjects[projectConfig['name']] = project
folderProjects.append(project)
# store projects of this folder
allProjects[projectConfig['name']] = project
folderProjects.append(project)
# store projects of this folder
@@
-89,7
+97,7
@@
def loadProjects(projects, folder=''):
return folderProjects
# now check what we have to do
return folderProjects
# now check what we have to do
-loadProjects(config
['projects']
)
+loadProjects(config)
if args.projects:
if args.resume_from is not None:
raise Exception("Can not use --resume-from and manually specify projects")
if args.projects:
if args.resume_from is not None:
raise Exception("Can not use --resume-from and manually specify projects")
@@
-99,7
+107,7
@@
if args.projects:
elif name in allFolders:
workProjects += allFolders[name]
else:
elif name in allFolders:
workProjects += allFolders[name]
else:
- raise Exception("Project or folder
%s does not exist" % name)
+ raise Exception("Project or folder%s does not exist" % name)
elif args.resume_from is None:
workProjects = projects.values() # all the projects
else:
elif args.resume_from is None:
workProjects = projects.values() # all the projects
else: