From 28b4932b86ba3bb7a97d563292beda8bdd56b032 Mon Sep 17 00:00:00 2001 From: Asher Baker Date: Thu, 22 Oct 2015 12:09:46 +0100 Subject: [PATCH] Complete switch to git --- .gitignore | 6 ++ .travis.yml | 25 ++++++++ buildbot/BreakpadSymbols | 6 +- buildbot/Versioning | 11 ++-- buildbot/pushbuild.txt | 1 - extension/AMBuilder | 20 +++--- product.version | 2 +- upload.py | 135 +++++++++++++++++++-------------------- 8 files changed, 117 insertions(+), 89 deletions(-) create mode 100644 .travis.yml diff --git a/.gitignore b/.gitignore index 0587f49..1dc1817 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,8 @@ +# Build output /build /extension/version_auto.h + +# Breakpad stuff, it apparently has to be called src +/src +/.gclient +/.gclient_entries diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e402e01 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,25 @@ +sudo: false +language: cpp +addons: + apt: + packages: + - g++-multilib +compiler: + - clang +before_script: + - cd .. + - git clone --depth=1 --branch=master https://chromium.googlesource.com/chromium/tools/depot_tools.git + - git clone --depth=1 --branch=1.7-dev https://github.com/alliedmodders/sourcemod sourcemod-1.5 + - git clone --depth=1 --branch=master https://github.com/alliedmodders/ambuild + - cd ambuild + - python setup.py install --user + - cd $TRAVIS_BUILD_DIR + - git fetch --unshallow + - ../depot_tools/fetch breakpad +script: + - mkdir build + - cd build + - python ../configure.py --enable-optimize + - python ./build.py +after_success: + - python ../upload.py diff --git a/buildbot/BreakpadSymbols b/buildbot/BreakpadSymbols index 7d40e8e..2595a2b 100644 --- a/buildbot/BreakpadSymbols +++ b/buildbot/BreakpadSymbols @@ -1,9 +1,13 @@ # vim: set ts=2 sw=2 tw=99 noet ft=python: import os -import urllib.request from ambuild.command import Command from ambuild.command import ShellCommand +try: + import urllib.request as urllib +except ImportError: + import urllib2 as urllib + class IterateDebugInfoCommand(Command): def run(self, master, job): pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'rt') diff --git a/buildbot/Versioning b/buildbot/Versioning index c5c731b..6b9766e 100644 --- a/buildbot/Versioning +++ b/buildbot/Versioning @@ -7,12 +7,13 @@ import ambuild.command as command #Quickly try to ascertain the current repository revision def GetVersion(): - args = ['hg', 'parent', '-R', AMBuild.sourceFolder] - p = command.RunDirectCommand(AMBuild, args) - m = re.match('changeset:\s+(\d+):(.+)', p.stdoutText) - if m == None: + rev = command.RunDirectCommand(AMBuild, ['git', 'rev-list', '--count', 'HEAD']).stdoutText.strip() + cset = command.RunDirectCommand(AMBuild, ['git', 'log', '--pretty=format:%h', '-n', '1']).stdoutText.strip() + + if not rev or not cset: raise Exception('Could not determine repository version') - return m.groups() + + return (rev, cset) def PerformReversioning(): rev, cset = GetVersion() diff --git a/buildbot/pushbuild.txt b/buildbot/pushbuild.txt index 87e1ac9..e69de29 100644 --- a/buildbot/pushbuild.txt +++ b/buildbot/pushbuild.txt @@ -1 +0,0 @@ -Lemons. diff --git a/extension/AMBuilder b/extension/AMBuilder index 7f4569e..a7d19d6 100644 --- a/extension/AMBuilder +++ b/extension/AMBuilder @@ -13,24 +13,24 @@ def BuildEverything(): BuildExtension(); def BuildBreakpad(): - breakpad = AMBuild.AddJob('google-breakpad') + breakpad = AMBuild.AddJob('breakpad') if AMBuild.target['platform'] in ['linux']: - if osutil.FileExists(os.path.join(AMBuild.outputFolder, 'google-breakpad', 'src', 'client', 'linux', 'libbreakpad_client.a')): + if osutil.FileExists(os.path.join(AMBuild.outputFolder, 'src', 'src', 'client', 'linux', 'libbreakpad_client.a')): return - breakpad.AddCommand(ShellCommand('CXXFLAGS=-m32 CFLAGS=-m32 CPPFLAGS=-m32 ' + os.path.join(AMBuild.sourceFolder, 'google-breakpad', 'configure'))) + breakpad.AddCommand(ShellCommand('CXXFLAGS=-m32 CFLAGS=-m32 CPPFLAGS=-m32 ' + os.path.join(AMBuild.sourceFolder, 'src', 'configure'))) breakpad.AddCommand(ShellCommand('make src/client/linux/libbreakpad_client.a')) elif AMBuild.target['platform'] in ['windows']: - if osutil.FileExists(os.path.join(AMBuild.sourceFolder, 'google-breakpad', 'src', 'client', 'windows', 'handler', 'Release', 'lib', 'exception_handler.lib')): + if osutil.FileExists(os.path.join(AMBuild.sourceFolder, 'src', 'src', 'client', 'windows', 'handler', 'Release', 'lib', 'exception_handler.lib')): return - gyp = os.path.join(AMBuild.sourceFolder, 'google-breakpad', 'src', 'tools', 'gyp', 'gyp.bat') - gyppath = os.path.join(AMBuild.sourceFolder, 'google-breakpad', 'src', 'client', 'windows', 'handler', 'exception_handler.gyp') + gyp = os.path.join(AMBuild.sourceFolder, 'src', 'src', 'tools', 'gyp', 'gyp.bat') + gyppath = os.path.join(AMBuild.sourceFolder, 'src', 'src', 'client', 'windows', 'handler', 'exception_handler.gyp') breakpad.AddCommand(DirectCommand([gyp, gyppath])) - slnpath = os.path.join(AMBuild.sourceFolder, 'google-breakpad', 'src', 'client', 'windows', 'handler', 'exception_handler.sln') + slnpath = os.path.join(AMBuild.sourceFolder, 'src', 'src', 'client', 'windows', 'handler', 'exception_handler.sln') breakpad.AddCommand(DirectCommand(['msbuild', slnpath, '/p:Configuration=Release'])) def BuildExtension(): @@ -43,7 +43,7 @@ def BuildExtension(): compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache['SOURCEMOD15'], 'public', 'extensions')) compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache['SOURCEMOD15'], 'public', 'sourcepawn')) - compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'google-breakpad', 'src')) + compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'src', 'src')) if AMBuild.target['platform'] in ['linux']: compiler['POSTLINKFLAGS'].append('-lstdc++') @@ -61,7 +61,7 @@ def BuildExtension(): if AMBuild.target['platform'] in ['linux']: link = os.path.join(AMBuild.outputFolder, extension.workFolder, 'libbreakpad_client.a') - target = os.path.join(AMBuild.outputFolder, 'google-breakpad', 'src', 'client', 'linux', 'libbreakpad_client.a') + target = os.path.join(AMBuild.outputFolder, 'breakpad', 'src', 'client', 'linux', 'libbreakpad_client.a') try: os.lstat(link) except: @@ -71,7 +71,7 @@ def BuildExtension(): elif AMBuild.target['platform'] in ['windows']: libs = ['exception_handler', 'common', 'crash_generation_client'] for lib in libs: - path = os.path.join(AMBuild.sourceFolder, 'google-breakpad', 'src', 'client', 'windows', 'handler', 'Release', 'lib', lib + '.lib') + path = os.path.join(AMBuild.sourceFolder, 'breakpad', 'src', 'client', 'windows', 'handler', 'Release', 'lib', lib + '.lib') if os.path.isfile(path): binary.RelinkIfNewer(path) binary['POSTLINKFLAGS'].extend([path]) diff --git a/product.version b/product.version index 38f77a6..7ec1d6d 100644 --- a/product.version +++ b/product.version @@ -1 +1 @@ -2.0.1 +2.1.0 diff --git a/upload.py b/upload.py index a9f9e29..eb2cd3e 100644 --- a/upload.py +++ b/upload.py @@ -1,71 +1,64 @@ -import re, os, sys -import subprocess - -import zipfile -import ftplib - -platform = 'unknown' -if sys.platform.startswith('linux'): - platform = 'linux' -elif sys.platform.startswith('win32'): - platform = 'windows' -elif sys.platform.startswith('darwin'): - platform = 'mac' - -def HGVersion(): - p = subprocess.Popen(['hg', 'identify', '-n'], stdout = subprocess.PIPE, stderr = subprocess.PIPE) - (stdout, stderr) = p.communicate() - stdout = stdout.decode('UTF-8') - - return stdout.rstrip('+\r\n') - -def ReleaseVersion(): - productFile = open('product.version', 'r') - productContents = productFile.read() - productFile.close() - - m = re.match('(\d+)\.(\d+)\.(\d+)(.*)', productContents) - if m == None: - raise Exception('Could not detremine product version') - - major, minor, release, tag = m.groups() - return '.'.join([major, minor, release]) - -filename = '-'.join([os.environ.get('project', 'accelerator'), ReleaseVersion(), 'hg' + HGVersion(), platform]) - -debug_build = os.environ.get('is_debug_build', False) == "1" - -if debug_build: - filename += '-debug' - -filename += '.zip' - -zip = zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED) - -for base, dirs, files in os.walk('package'): - for file in files: - fn = os.path.join(base, file) - fns = fn[(len('package') + 1):] - - zip.write(fn, fns) - -print("%-33s %-10s %21s %12s" % ("File Name", "CRC32", "Modified ", "Size")) -for zinfo in zip.infolist(): - date = "%d-%02d-%02d %02d:%02d:%02d" % zinfo.date_time[:6] - print("%-33s %-10d %21s %12d" % (zinfo.filename, zinfo.CRC, date, zinfo.file_size)) - -zip.close() - -if 'ftp_hostname' in os.environ: - print('') - - ftp = ftplib.FTP(os.environ['ftp_hostname'], os.environ['ftp_username'], os.environ['ftp_password']) - print('Connected to server, uploading build...') - ftp.cwd(os.environ['ftp_directory']) - print(ftp.storbinary('STOR ' + filename, open(filename, 'rb'))) - ftp.quit() - - print('Uploaded as \'' + filename + '\'') - - os.unlink(filename) - +import re, os, sys +import subprocess + +import zipfile +import ftplib + +platform = 'unknown' +if sys.platform.startswith('linux'): + platform = 'linux' +elif sys.platform.startswith('win32'): + platform = 'windows' +elif sys.platform.startswith('darwin'): + platform = 'mac' + +def GITHash(): + p = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], stdout = subprocess.PIPE, stderr = subprocess.PIPE) + (stdout, stderr) = p.communicate() + stdout = stdout.decode('UTF-8') + return stdout.rstrip('\r\n') + +def GITVersion(): + p = subprocess.Popen(['git', 'rev-list', '--count', '--first-parent', 'HEAD'], stdout = subprocess.PIPE, stderr = subprocess.PIPE) + (stdout, stderr) = p.communicate() + stdout = stdout.decode('UTF-8') + return stdout.rstrip('\r\n') + +filename = '-'.join(['accelerator', 'git' + GITVersion(), GITHash(), platform]) + +debug_build = os.environ.get('is_debug_build', False) == "1" + +if debug_build: + filename += '-debug' + +filename += '.zip' + +zip = zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED) + +for base, dirs, files in os.walk('package'): + for file in files: + fn = os.path.join(base, file) + fns = fn[(len('package') + 1):] + + zip.write(fn, fns) + +print("%-33s %-10s %21s %12s" % ("File Name", "CRC32", "Modified ", "Size")) +for zinfo in zip.infolist(): + date = "%d-%02d-%02d %02d:%02d:%02d" % zinfo.date_time[:6] + print("%-33s %-10d %21s %12d" % (zinfo.filename, zinfo.CRC, date, zinfo.file_size)) + +zip.close() + +if 'ftp_hostname' in os.environ: + print('') + + ftp = ftplib.FTP(os.environ['ftp_hostname'], os.environ['ftp_username'], os.environ['ftp_password']) + print('Connected to server, uploading build...') + ftp.cwd(os.environ['ftp_directory']) + print(ftp.storbinary('STOR ' + filename, open(filename, 'rb'))) + ftp.quit() + + print('Uploaded as \'' + filename + '\'') + + os.unlink(filename) +