backing out r1057

This commit is contained in:
Nick Bolton 2011-06-29 09:56:32 +00:00
parent ec34e4a4d1
commit 54588b3d6f
2 changed files with 166 additions and 183 deletions

View File

@ -1,5 +1,3 @@
import os
class Generator(object): class Generator(object):
def __init__(self, cmakeName, buildDir='build', sourceDir='..', binDir='bin'): def __init__(self, cmakeName, buildDir='build', sourceDir='..', binDir='bin'):
self.cmakeName = cmakeName self.cmakeName = cmakeName
@ -11,7 +9,7 @@ class Generator(object):
return self.buildDir return self.buildDir
def getBinDir(self, target=''): def getBinDir(self, target=''):
return os.path.abspath(os.path.join(self.binDir,target)) return self.binDir
def getSourceDir(self): def getSourceDir(self):
return self.sourceDir return self.sourceDir

View File

@ -47,13 +47,12 @@ class InternalCommands:
qtpro_filename = 'qsynergy.pro' qtpro_filename = 'qsynergy.pro'
doxygen_filename = 'doxygen.cfg' doxygen_filename = 'doxygen.cfg'
# this is supposed to be relative to the project directory
macZipFiles = [ macZipFiles = [
'bin/{target}/synergyc', '../../bin/synergyc',
'bin/{target}/synergys', '../../bin/synergys',
'bin/{target}/QSynergy.app', '../../bin/QSynergy.app',
'doc/synergy.conf.example', '../../doc/synergy.conf.example',
'doc/MacReadme.txt'] '../../doc/MacReadme.txt']
cmake_url = 'http://www.cmake.org/cmake/resources/software.html' cmake_url = 'http://www.cmake.org/cmake/resources/software.html'
@ -127,7 +126,7 @@ class InternalCommands:
def configureAll(self, targets): def configureAll(self, targets):
# if no mode specified, use default # if no mode specified, use default
if not targets: if len(targets) == 0:
targets += [self.defaultTarget,] targets += [self.defaultTarget,]
for target in targets: for target in targets:
@ -181,7 +180,7 @@ class InternalCommands:
self.restore_chdir() self.restore_chdir()
if err: if err != 0:
raise Exception('CMake encountered error: ' + str(err)) raise Exception('CMake encountered error: ' + str(err))
# allow user to skip qui compile # allow user to skip qui compile
@ -198,7 +197,7 @@ class InternalCommands:
err = os.system(qmake_cmd_string) err = os.system(qmake_cmd_string)
self.restore_chdir() self.restore_chdir()
if err: if err != 0:
raise Exception('QMake encountered error: ' + str(err)) raise Exception('QMake encountered error: ' + str(err))
self.setConfRun(target) self.setConfRun(target)
@ -208,7 +207,7 @@ class InternalCommands:
# code; we don't care about the version, since CMakeLists worrys about this for us. # code; we don't care about the version, since CMakeLists worrys about this for us.
err = os.system('%s --version' % self.cmake_cmd) err = os.system('%s --version' % self.cmake_cmd)
if err: if err != 0:
# if return code from cmake is not 0, then either something has # if return code from cmake is not 0, then either something has
# gone terribly wrong with --version, or it genuinely doesn't exist. # gone terribly wrong with --version, or it genuinely doesn't exist.
print ('Could not find `%s` in system path.\n' print ('Could not find `%s` in system path.\n'
@ -242,7 +241,7 @@ class InternalCommands:
raise Exception('Cannot continue without qmake.') raise Exception('Cannot continue without qmake.')
stdout, stderr = p.communicate() stdout, stderr = p.communicate()
if p.returncode: if p.returncode != 0:
raise Exception('Could not test for cmake: %s' % stderr) raise Exception('Could not test for cmake: %s' % stderr)
else: else:
m = re.search('.*Using Qt version (\d+\.\d+\.\d+).*', stdout) m = re.search('.*Using Qt version (\d+\.\d+\.\d+).*', stdout)
@ -270,7 +269,7 @@ class InternalCommands:
def build(self, targets=[], skipConfig=False): def build(self, targets=[], skipConfig=False):
# if no mode specified, use default # if no mode specified, use default
if not targets: if len(targets) == 0:
targets += [self.defaultTarget,] targets += [self.defaultTarget,]
self.ensure_setup_latest() self.ensure_setup_latest()
@ -302,13 +301,13 @@ class InternalCommands:
err = os.system(cmd) err = os.system(cmd)
self.restore_chdir() self.restore_chdir()
if err: if err != 0:
raise Exception(cmd + ' failed: ' + str(err)) raise Exception(cmd + ' failed: ' + str(err))
def clean(self, targets=[]): def clean(self, targets=[]):
# if no mode specified, use default # if no mode specified, use default
if not targets: if len(targets) == 0:
targets += [self.defaultTarget,] targets += [self.defaultTarget,]
generator = self.getGeneratorFromConfig().cmakeName generator = self.getGeneratorFromConfig().cmakeName
@ -325,6 +324,7 @@ class InternalCommands:
self.run_vcbuild(generator, target, '/clean') self.run_vcbuild(generator, target, '/clean')
else: else:
cmd = ''
if generator == "Unix Makefiles": if generator == "Unix Makefiles":
print 'Cleaning with GNU Make...' print 'Cleaning with GNU Make...'
cmd = self.make_cmd cmd = self.make_cmd
@ -339,7 +339,7 @@ class InternalCommands:
err = os.system(cmd + ' clean') err = os.system(cmd + ' clean')
self.restore_chdir() self.restore_chdir()
if err: if err != 0:
raise Exception('Clean failed: ' + str(err)) raise Exception('Clean failed: ' + str(err))
# allow user to skip qui compile # allow user to skip qui compile
@ -370,7 +370,7 @@ class InternalCommands:
err = os.system(gui_make_cmd + ' ' + target) err = os.system(gui_make_cmd + ' ' + target)
self.restore_chdir() self.restore_chdir()
if err: if err != 0:
raise Exception(gui_make_cmd + ' failed with error: ' + str(err)) raise Exception(gui_make_cmd + ' failed with error: ' + str(err))
else: else:
if sys.platform == 'darwin': if sys.platform == 'darwin':
@ -398,7 +398,7 @@ class InternalCommands:
def update(self): def update(self):
print "Running Subversion update..." print "Running Subversion update..."
err = os.system('svn update') err = os.system('svn update')
if err: if err != 0:
raise Exception('Could not update from repository with error code code: ' + str(err)) raise Exception('Could not update from repository with error code code: ' + str(err))
def revision(self): def revision(self):
@ -412,7 +412,7 @@ class InternalCommands:
p = subprocess.Popen(['svn', 'info'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) p = subprocess.Popen(['svn', 'info'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate() stdout, stderr = p.communicate()
if p.returncode: if p.returncode != 0:
raise Exception('Could not get revision - svn info failed with code: ' + str(p.returncode)) raise Exception('Could not get revision - svn info failed with code: ' + str(p.returncode))
m = re.search('.*Revision: (\d+).*', stdout) m = re.search('.*Revision: (\d+).*', stdout)
@ -434,7 +434,7 @@ class InternalCommands:
err = os.system('doxygen %s/%s' % (self.doc_dir, self.doxygen_filename)) err = os.system('doxygen %s/%s' % (self.doc_dir, self.doxygen_filename))
if err: if err != 0:
raise Exception('doxygen failed with error code: ' + str(err)) raise Exception('doxygen failed with error code: ' + str(err))
def dist(self, type, vcRedistDir, qtDir): def dist(self, type, vcRedistDir, qtDir):
@ -443,10 +443,7 @@ class InternalCommands:
package_unsupported = False package_unsupported = False
unixTarget = self.defaultTarget unixTarget = self.defaultTarget
if type == '' or type is None: if type == '' or type == None:
if sys.platform == 'darwin':
type = 'mac'
else:
raise Exception('No type specified.') raise Exception('No type specified.')
if type != 'win' and type != 'mac': if type != 'win' and type != 'mac':
@ -457,7 +454,7 @@ class InternalCommands:
moveExt = '' moveExt = ''
if type is None: if type == None:
self.dist_usage() self.dist_usage()
return return
@ -518,7 +515,7 @@ class InternalCommands:
print 'Exporting repository to: ' + exportPath print 'Exporting repository to: ' + exportPath
err = os.system('svn export . ' + exportPath) err = os.system('svn export . ' + exportPath)
if err: if err != 0:
raise Exception('Repository export failed: ' + str(err)) raise Exception('Repository export failed: ' + str(err))
packagePath = '../' + self.getGenerator().binDir + '/' + name + '.tar.gz' packagePath = '../' + self.getGenerator().binDir + '/' + name + '.tar.gz'
@ -527,7 +524,7 @@ class InternalCommands:
self.try_chdir(self.getGenerator().buildDir) self.try_chdir(self.getGenerator().buildDir)
print 'Packaging to: ' + packagePath print 'Packaging to: ' + packagePath
err = os.system('tar cfvz ' + packagePath + ' ' + name) err = os.system('tar cfvz ' + packagePath + ' ' + name)
if err: if err != 0:
raise Exception('Package failed: ' + str(err)) raise Exception('Package failed: ' + str(err))
finally: finally:
self.restore_chdir() self.restore_chdir()
@ -535,7 +532,7 @@ class InternalCommands:
def unixMove(self, source, dest): def unixMove(self, source, dest):
print 'Moving ' + source + ' to ' + dest print 'Moving ' + source + ' to ' + dest
err = os.system('mv ' + source + ' ' + dest) err = os.system('mv ' + source + ' ' + dest)
if err: if err != 0:
raise Exception('Package failed: ' + str(err)) raise Exception('Package failed: ' + str(err))
def distMac(self, unixTarget): def distMac(self, unixTarget):
@ -561,9 +558,6 @@ class InternalCommands:
os.makedirs(zipFile) os.makedirs(zipFile)
for f in self.macZipFiles: for f in self.macZipFiles:
f = f.replace('{target}', unixTarget)
f = os.path.abspath(os.path.join(os.path.dirname(__file__),"../../..",f))
print f
if not os.path.exists(f): if not os.path.exists(f):
raise Exception('File does not exist: ' + f) raise Exception('File does not exist: ' + f)
elif os.path.isdir(f): elif os.path.isdir(f):
@ -573,11 +567,11 @@ class InternalCommands:
else: else:
shutil.copy2(f, zipFile + '/') shutil.copy2(f, zipFile + '/')
zipCmd = ('zip -r ../../' + binDir + '/' + zipFile + '.zip ' + zipFile) zipCmd = ('zip -r ../../' + binDir + '/' + zipFile + '.zip ' + zipFile);
print 'Creating package: ' + zipCmd print 'Creating package: ' + zipCmd
err = os.system(zipCmd) err = os.system(zipCmd)
if err: if err != 0:
raise Exception('Zip failed, code: ' + err) raise Exception('Zip failed, code: ' + err)
finally: finally:
@ -619,7 +613,7 @@ class InternalCommands:
command = 'makensis ' + nsiPath command = 'makensis ' + nsiPath
print 'NSIS command: ' + command print 'NSIS command: ' + command
err = os.system(command) err = os.system(command)
if err: if err != 0:
raise Exception('Package failed: ' + str(err)) raise Exception('Package failed: ' + str(err))
def getVersionFromCmake(self): def getVersionFromCmake(self):
@ -718,7 +712,7 @@ class InternalCommands:
print 'CPack command: ' + command print 'CPack command: ' + command
err = os.system(command) err = os.system(command)
self.restore_chdir() self.restore_chdir()
if err: if err != 0:
raise Exception('Package failed: ' + str(err)) raise Exception('Package failed: ' + str(err))
def dist_usage(self): def dist_usage(self):
@ -775,14 +769,14 @@ class InternalCommands:
path = application + ' ' + path path = application + ' ' + path
err = os.system(path) err = os.system(path)
if err: if err != 0:
raise Exception('Could not open project with error code code: ' + str(err)) raise Exception('Could not open project with error code code: ' + str(err))
def setup(self, target=''): def setup(self, target=''):
print "Running setup..." print "Running setup..."
oldGenerator = self.findGeneratorFromConfig() oldGenerator = self.findGeneratorFromConfig()
if not oldGenerator is None: if not oldGenerator == None:
for target in ['debug', 'release']: for target in ['debug', 'release']:
buildDir = oldGenerator.getBuildDir(target) buildDir = oldGenerator.getBuildDir(target)
@ -913,16 +907,6 @@ class InternalCommands:
if conf: if conf:
return conf return conf
# generator not configured, will auto-configure it
generators = self.get_generators()
keys = generators.keys()
keys.sort()
for k in keys:
# print str(k) + ': ' + generators[k].cmakeName
if sys.platform == 'darwin' and generators[k].cmakeName == 'Xcode':
return generators[int(k)]
# TODO add auto-detection for other platforms, eventually by detecting what is available
raise Exception( raise Exception(
'Generator not specified, use -g arg ' + 'Generator not specified, use -g arg ' +
'(use `hm genlist` for a list of generators).') '(use `hm genlist` for a list of generators).')
@ -956,6 +940,7 @@ class InternalCommands:
key_name = r'SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' key_name = r'SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7'
else: else:
key_name = r'SOFTWARE\Microsoft\VisualStudio\SxS\VC7' key_name = r'SOFTWARE\Microsoft\VisualStudio\SxS\VC7'
try: try:
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key_name) key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key_name)
except: except:
@ -1027,7 +1012,7 @@ class InternalCommands:
file.close() file.close()
err = os.system(temp_bat) err = os.system(temp_bat)
if err: if err != 0:
raise Exception('Microsoft compiler failed with error code: ' + str(err)) raise Exception('Microsoft compiler failed with error code: ' + str(err))
def ensure_setup_latest(self): def ensure_setup_latest(self):
@ -1040,7 +1025,7 @@ class InternalCommands:
'--quiet --suffix=none --style=java --indent=force-tab=4 --recursive ' '--quiet --suffix=none --style=java --indent=force-tab=4 --recursive '
'lib/*.cpp lib/*.h cmd/*.cpp cmd/*.h') 'lib/*.cpp lib/*.h cmd/*.cpp cmd/*.h')
if err: if err != 0:
raise Exception('Reformat failed with error code: ' + str(err)) raise Exception('Reformat failed with error code: ' + str(err))
def printGeneratorList(self): def printGeneratorList(self):
@ -1062,7 +1047,7 @@ class InternalCommands:
# version is major and minor with no dots (e.g. 106) # version is major and minor with no dots (e.g. 106)
return ('MacOSX' + str(result.group(1)) + return ('MacOSX' + str(result.group(1)) +
str(result.group(2)) + '-Universal') str(result.group(2)) + '-Universal');
# the command handler should be called only from hm.py (i.e. directly # the command handler should be called only from hm.py (i.e. directly
# from the command prompt). the purpose of this class is so that we # from the command prompt). the purpose of this class is so that we