From cbd7a35b720864726f344d358d8312b0a7bb598c Mon Sep 17 00:00:00 2001 From: Owen Williams Date: Sat, 18 May 2013 09:58:51 -0400 Subject: [PATCH 1/3] Add git to build system -- it should pick bzr or git, whichever is appropriate --- mixxx/build/nsis/Mixxx-garth.nsi | 4 +- mixxx/build/nsis/Mixxx.nsi | 26 ++++++------ mixxx/build/qtcreator/mixxx.pro | 39 ++++++++++++------ mixxx/build/util.py | 68 +++++++++++++++++++++++++++----- mixxx/src/SConscript | 43 +++++++++++--------- 5 files changed, 124 insertions(+), 56 deletions(-) diff --git a/mixxx/build/nsis/Mixxx-garth.nsi b/mixxx/build/nsis/Mixxx-garth.nsi index cc83a497792..d6c33783cf5 100644 --- a/mixxx/build/nsis/Mixxx-garth.nsi +++ b/mixxx/build/nsis/Mixxx-garth.nsi @@ -115,7 +115,7 @@ Section "Mixxx (required)" SecMixxx File "COPYING" SetOutPath $INSTDIR\midi - File /r /x ".svn" /x ".bzr" dist\midi\*.* + File /r /x ".svn" /x ".bzr" /x "*.git" dist\midi\*.* ;Disabled for initial 1.6.0 release ;SetOutPath $INSTDIR\promo @@ -126,7 +126,7 @@ Section "Mixxx (required)" SecMixxx File "dist\keyboard\Old.kbd.cfg" SetOutPath "$INSTDIR\skins" - File /r /x ".svn" /x ".bzr" dist\skins\*.* + File /r /x ".svn" /x ".bzr" /x "*.git" dist\skins\*.* ; Write the installation path into the registry ;WriteRegStr HKLM SOFTWARE\NSIS_Mixxx "Install_Dir" "$INSTDIR" diff --git a/mixxx/build/nsis/Mixxx.nsi b/mixxx/build/nsis/Mixxx.nsi index df941073b46..961db17daf6 100644 --- a/mixxx/build/nsis/Mixxx.nsi +++ b/mixxx/build/nsis/Mixxx.nsi @@ -232,16 +232,16 @@ Section "Mixxx (required)" SecMixxx ; HID/MIDI mapping tools (mappings are below) & common script file SetOutPath $INSTDIR\controllers - File /r /x ".svn" /x ".bzr" /x "*.xml" /x "*.js" ${BASE_BUILD_DIR}\dist${BITWIDTH}\controllers\*.* + File /r /x ".svn" /x ".bzr" /x "*.git" /x "*.xml" /x "*.js" ${BASE_BUILD_DIR}\dist${BITWIDTH}\controllers\*.* File ${BASE_BUILD_DIR}\dist${BITWIDTH}\controllers\common-controller-scripts.js ; Common skin files SetOutPath "$INSTDIR\skins" - File /x ".svn" /x ".bzr" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*.* + File /x ".svn" /x ".bzr" /x "*.git" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*.* ; Just the default skin SetOutPath "$INSTDIR\skins\${DEFAULT_SKIN}" - File /r /x ".svn" /x ".bzr" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\${DEFAULT_SKIN}\*.* + File /r /x ".svn" /x ".bzr" /x "*.git" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\${DEFAULT_SKIN}\*.* ; Write the installation path into the registry WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\Mixxx.exe" @@ -350,52 +350,52 @@ SectionGroup "Additional Skins" SecAddlSkins Section "Minimalist skins" SecBasicSkins SetOutPath "$INSTDIR\skins" - File /r /x ".svn" /x ".bzr" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\Outline* + File /r /x ".svn" /x ".bzr" /x "*.git" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\Outline* SectionEnd Section "Netbook-size (1024x600)" SecNetbookSkins SetOutPath "$INSTDIR\skins" - File /r /x ".svn" /x ".bzr" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-Netbook + File /r /x ".svn" /x ".bzr" /x "*.git" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-Netbook SectionEnd Section "XGA-size (1024x768)" SecXGASkins SetOutPath "$INSTDIR\skins" - File /r /x ".svn" /x ".bzr" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-XGA + File /r /x ".svn" /x ".bzr" /x "*.git" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-XGA SectionEnd Section "SXGA-size (1280x1024)" SecSXGASkins SetOutPath "$INSTDIR\skins" - File /r /x ".svn" /x ".bzr" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-SXGA + File /r /x ".svn" /x ".bzr" /x "*.git" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-SXGA SectionEnd Section "WXGA-size (1280x800)" SecWXGASkins SetOutPath "$INSTDIR\skins" - File /r /x ".svn" /x ".bzr" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-WXGA + File /r /x ".svn" /x ".bzr" /x "*.git" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-WXGA SectionEnd Section "WXGA+-size (1440x900)" SecWXGAPlusSkins SetOutPath "$INSTDIR\skins" - File /r /x ".svn" /x ".bzr" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-WXGA+ + File /r /x ".svn" /x ".bzr" /x "*.git" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-WXGA+ SectionEnd Section "WSXGA-size (1680x1050)" SecWSXGASkins SetOutPath "$INSTDIR\skins" - File /r /x ".svn" /x ".bzr" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-WSXGA + File /r /x ".svn" /x ".bzr" /x "*.git" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-WSXGA SectionEnd Section "UXGA-size (1600x1200)" SecUXGASkins SetOutPath "$INSTDIR\skins" - File /r /x ".svn" /x ".bzr" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-UXGA + File /r /x ".svn" /x ".bzr" /x "*.git" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-UXGA SectionEnd Section "Full HD-size (1920x1080)" SecFullHDSkins SetOutPath "$INSTDIR\skins" - File /r /x ".svn" /x ".bzr" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-FullHD + File /r /x ".svn" /x ".bzr" /x "*.git" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-FullHD SectionEnd Section "WUXGA-size (1920x1200)" SecWUXGASkins SetOutPath "$INSTDIR\skins" - File /r /x ".svn" /x ".bzr" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-WUXGA + File /r /x ".svn" /x ".bzr" /x "*.git" /x "Outline*" /x "${DEFAULT_SKIN}" ${BASE_BUILD_DIR}\dist${BITWIDTH}\skins\*-WUXGA SectionEnd SectionGroupEnd diff --git a/mixxx/build/qtcreator/mixxx.pro b/mixxx/build/qtcreator/mixxx.pro index 423d1ae36d2..834d8e7175b 100644 --- a/mixxx/build/qtcreator/mixxx.pro +++ b/mixxx/build/qtcreator/mixxx.pro @@ -903,17 +903,32 @@ win32 { system( echo $$TARGET --resourcePath \"$$replace(PWD, /,$${DIR_SEPARATOR})$${DIR_SEPARATOR}res\">\"$${PWD}$${DIR_SEPARATOR}$$replace(DESTDIR, /,$${DIR_SEPARATOR})$${DIR_SEPARATOR}testrun-$${TARGET}.cmd\" ) } -# Get info from BZR about the current branch -BZR_REVNO = $$system( bzr revno ) -BZR_INFO = $$system( bzr info ) -for(BZR_INFO_BITS, BZR_INFO) { - BZR_BRANCH_URL = $${BZR_INFO_BITS} +exists( .bzr ) { + # Get info from BZR about the current branch + BZR_REVNO = $$system( bzr revno ) + BZR_INFO = $$system( bzr info ) + for(BZR_INFO_BITS, BZR_INFO) { + BZR_BRANCH_URL = $${BZR_INFO_BITS} + } + BZR_BRANCH_NAME = $$dirname(BZR_BRANCH_URL) + BZR_BRANCH_NAME = $$basename(BZR_BRANCH_NAME) + message(BRANCH_NAME is $$BZR_BRANCH_NAME) + message(REVISION is $$BZR_REVNO) + message(BRANCH_URL is $$BZR_BRANCH_URL) + VCS_BRANCH_NAME = $${BZR_BRANCH_NAME} + VCS_REVNO = $${BZR_REVNO} +} + +system (git status) { + # Get info from git about the current branch + GIT_REVNO = $$system( git log --pretty=oneline --first-parent | wc -l ) + GIT_BRANCH_NAME = $$system( git branch | grep \* | sed -e "s/\* //;" ) + message(BRANCH_NAME is $$GIT_BRANCH_NAME) + message(REVISION is $$GIT_REVNO) + VCS_BRANCH_NAME = $${GIT_BRANCH_NAME} + VCS_REVNO = $${GIT_REVNO} + error("this is ok") } -BZR_BRANCH_NAME = $$dirname(BZR_BRANCH_URL) -BZR_BRANCH_NAME = $$basename(BZR_BRANCH_NAME) -message(BRANCH_NAME is $$BZR_BRANCH_NAME) -message(REVISION is $$BZR_REVNO) -message(BRANCH_URL is $$BZR_BRANCH_URL) win32 { # Makefile target to build an NSIS Installer... @@ -922,13 +937,13 @@ win32 { # SH Usage: make -f Makefile.Debug nsis nsis.target = nsis exists($$BUILDDIR/gdb.exe):INCLUDE_GDB = -DINCLUDE_GDB - nsis.commands = \"$$(PROGRAMFILES)\NSIS\makensis.exe\" -NOCD -DGCC -DBINDIR=\"$$BUILDDIR\" -DBUILD_REV=\"$$BZR_BRANCH_NAME-$$BZR_REVNO\" $$INCLUDE_GDB build\\\\nsis\\\\Mixxx.nsi + nsis.commands = \"$$(PROGRAMFILES)\NSIS\makensis.exe\" -NOCD -DGCC -DBINDIR=\"$$BUILDDIR\" -DBUILD_REV=\"$$VCS_BRANCH_NAME-$$VCS_REVNO\" $$INCLUDE_GDB build\\\\nsis\\\\Mixxx.nsi # nsis.depends = QMAKE_EXTRA_UNIX_TARGETS += nsis } # build.h -BUILD_REV = $${BZR_BRANCH_NAME} : $${BZR_REVNO} +BUILD_REV = $${VCS_BRANCH_NAME} : $${VCS_REVNO} isEmpty( BUILD_REV ):BUILD_REV = Killroy was here BUILD_REV += - built via qmake/Qt Creator message( Generating src$${DIR_SEPARATOR}build.h with contents: $${LITERAL_HASH}define BUILD_REV '"'$$BUILD_REV'"' ) diff --git a/mixxx/build/util.py b/mixxx/build/util.py index 052c2497bd6..47a3c9ad9e5 100644 --- a/mixxx/build/util.py +++ b/mixxx/build/util.py @@ -2,6 +2,41 @@ import os, sys, platform import re +def on_bzr(): + try: + os.stat(".bzr") + return True + except: + return False + +def on_git(): + try: + os.popen("git status") + return True + except: + return False + +def get_git_revision(): + return len(os.popen("git log --pretty=oneline --first-parent").read().splitlines()) + +def get_git_modified(): + modified_matcher = re.compile("^#.*modified: (?P.*?)$") + modified_files = [] + for line in os.popen("git status").read().splitlines(): + match = modified_matcher.match(line) + if match: + match = match.groupdict() + modified_files.append(match['filename'].strip()) + return "\n".join(modified_files) + +def get_git_branch_name(): + branch_matcher = re.compile("\* (?P.*?)$") + for line in os.popen("git branch").read().splitlines(): + match = branch_matcher.match(line) + if match: + match = match.groupdict() + return match['branch'].strip() + def get_bzr_revision(): return os.popen("bzr revno").readline().strip() @@ -116,13 +151,26 @@ def CheckForPKG( context, name, version="" ): def write_build_header(path): f = open(path, 'w') - try: - branch_name = get_bzr_branch_name() - modified = get_bzr_modified() > 0 - # Do not emit BUILD_BRANCH on release branches. - if not branch_name.startswith('release'): - f.write('#define BUILD_BRANCH "%s"\n' % branch_name) - f.write('#define BUILD_REV "%s%s"\n' % (get_bzr_revision(), - '+' if modified else '')) - finally: - f.close() + if on_bzr(): + try: + branch_name = get_bzr_branch_name() + modified = get_bzr_modified() > 0 + # Do not emit BUILD_BRANCH on release branches. + if not branch_name.startswith('release'): + f.write('#define BUILD_BRANCH "%s"\n' % branch_name) + f.write('#define BUILD_REV "%s%s"\n' % (get_bzr_revision(), + '+' if modified else '')) + finally: + f.close() + elif on_git(): + try: + branch_name = get_git_branch_name() + modified = get_git_modified() > 0 + # Do not emit BUILD_BRANCH on release branches. + if not branch_name.startswith('release'): + f.write('#define BUILD_BRANCH "%s"\n' % branch_name) + f.write('#define BUILD_REV "%s%s"\n' % (get_git_revision(), + '+' if modified else '')) + finally: + f.close() + diff --git a/mixxx/src/SConscript b/mixxx/src/SConscript index 22e3a4ce928..844a8192061 100644 --- a/mixxx/src/SConscript +++ b/mixxx/src/SConscript @@ -12,9 +12,14 @@ import SCons.Script as SCons from build import util, depends mixxx_version = util.get_mixxx_version() -branch_name = util.get_bzr_branch_name() -bazaar_revision = util.get_bzr_revision() +if util.on_bzr(): + branch_name = util.get_bzr_branch_name() + vcs_revision = util.get_bzr_revision() +elif util.on_git(): + branch_name = util.get_git_branch_name() + vcs_revision = util.get_git_revision() print "WE ARE IN:", os.getcwd() +print "Building ", branch_name, " - rev.", vcs_revision plugins = [] @@ -38,11 +43,11 @@ if build.platform_is_windows: str_list.append('#define VER_FILEVERSION ') # Remove anything after ~ or - in the version number and replace the dots with commas str_list.append(mixxx_version.partition('~')[0].partition('-')[0].replace('.',',')) - str_list.append(','+str(bazaar_revision)+'\n') + str_list.append(','+str(vcs_revision)+'\n') str_list.append('#define VER_PRODUCTVERSION ') str_list.append(mixxx_version.partition('~')[0].partition('-')[0].replace('.',',')) - str_list.append(','+str(bazaar_revision)+'\n') + str_list.append(','+str(vcs_revision)+'\n') import datetime now = datetime.datetime.now() @@ -97,34 +102,34 @@ if 'test' in BUILD_TARGETS: print "Running tests." run_tests() -def osx_construct_version(build, mixxx_version, branch_name, bazaar_revision): +def osx_construct_version(build, mixxx_version, branch_name, vcs_revision): # In release mode, we only use the version. if build.build_is_release: return mixxx_version elif branch_name.startswith('release-'): - return '%s-bzr%s' % (mixxx_version, bazaar_revision) + return '%s-bzr%s' % (mixxx_version, vcs_revision) # In a debug build, include the branch name and revision number - return "%s-%s-bzr%s" % (mixxx_version, branch_name, bazaar_revision) + return "%s-%s-bzr%s" % (mixxx_version, branch_name, vcs_revision) -def ubuntu_construct_version(build, mixxx_version, branch_name, bazaar_revision, +def ubuntu_construct_version(build, mixxx_version, branch_name, vcs_revision, ubuntu_version): # In release mode, we only use the version and ubuntu_version if build.build_is_release: return "%s-%s" % (mixxx_version, ubuntu_version) elif branch_name.startswith('release-'): - return "%s-bzr%s" % (mixxx_version, bazaar_revision) + return "%s-bzr%s" % (mixxx_version, vcs_revision) # In a debug build, include the branch name and revision number return "%s-%s~%s~bzr%s" % (mixxx_version, ubuntu_version, - branch_name, bazaar_revision) + branch_name, vcs_revision) -def windows_construct_version(build, mixxx_version, branch_name, bazaar_revision): +def windows_construct_version(build, mixxx_version, branch_name, vcs_revision): # In release mode, we only use the version if build.build_is_release: return mixxx_version elif branch_name.startswith('release-'): - return '%s-bzr%s' % (mixxx_version, bazaar_revision) + return '%s-bzr%s' % (mixxx_version, vcs_revision) # In a debug build, include the branch name and revision number - return "%s-%s-bzr%s" % (mixxx_version, branch_name, bazaar_revision) + return "%s-%s-bzr%s" % (mixxx_version, branch_name, vcs_revision) #Set up the install target #========================= @@ -412,7 +417,7 @@ if build.platform_is_osx and 'bundle' in COMMAND_LINE_TARGETS: env.Alias('sign', codesign) package_name = 'mixxx' - package_version = osx_construct_version(build, mixxx_version, branch_name, bazaar_revision) + package_version = osx_construct_version(build, mixxx_version, branch_name, vcs_revision) dmg_name = '%s-%s-%s' % (package_name, package_version, ARCH) dmg = env.Dmg(dmg_name, [bundle, ] + docs_files, VOLNAME=VOLNAME, ICON = DMG_ICON) env.Alias('package', dmg) @@ -503,7 +508,7 @@ def BuildRelease(target, source, env): package_name = 'mixxx' package_version = windows_construct_version( - build, mixxx_version, branch_name, bazaar_revision) + build, mixxx_version, branch_name, vcs_revision) arch = "x64" if build.machine_is_64bit else "x86" exe_name = '%s-%s-%s.exe' % (package_name, package_version, arch) print exe_name @@ -660,7 +665,7 @@ def BuildUbuntuPackage(target, source, env): # package version is always changing otherwise it will reject our orig # source tarball. if ubuntu_ppa is not None: - mixxx_version = '%s-bzr%s' % (mixxx_version, bazaar_revision) + mixxx_version = '%s-bzr%s' % (mixxx_version, vcs_revision) # Destroy ubuntu/ and create it ubuntu_cleanup() @@ -688,7 +693,7 @@ def BuildUbuntuPackage(target, source, env): # TODO: make a get flags arg to accept a revision which can override this and checkout of a specific SVN rev for the package # Export the source folder - print "* Exporting source folder from current workspace (bzr rev: %s)" % bazaar_revision + print "* Exporting source folder from current workspace (bzr rev: %s)" % vcs_revision print os.system('bzr export %s .' % build_dir) @@ -724,12 +729,12 @@ def BuildUbuntuPackage(target, source, env): # TODO(rryan) currently can only have version 1 within a distro ubuntu_distro_version = '%s~%s1' % (ubuntu_version, ubuntu_distro) package_version = ubuntu_construct_version(build, mixxx_version, - branch_name, bazaar_revision, + branch_name, vcs_revision, ubuntu_distro_version) # Add a changelog record for this package if build.build_is_debug: - description = " * Experimental build of branch '%s' at Bazaar revision %s" % (branch_name, bazaar_revision) + description = " * Experimental build of branch '%s' at Bazaar revision %s" % (branch_name, vcs_revision) ubuntu_append_changelog('debian', package_name, package_version, description, distro=ubuntu_distro) else: From ffa55391f8e2311f08392c7a58313358f1c8cfdd Mon Sep 17 00:00:00 2001 From: Owen Williams Date: Sun, 19 May 2013 19:07:03 -0400 Subject: [PATCH 2/3] Hide some complexity in util.py --- mixxx/build/qtcreator/mixxx.pro | 1 - mixxx/build/util.py | 55 +++++++++++++++++++-------------- mixxx/src/SConscript | 8 ++--- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/mixxx/build/qtcreator/mixxx.pro b/mixxx/build/qtcreator/mixxx.pro index 834d8e7175b..37d6cdaefc5 100644 --- a/mixxx/build/qtcreator/mixxx.pro +++ b/mixxx/build/qtcreator/mixxx.pro @@ -927,7 +927,6 @@ system (git status) { message(REVISION is $$GIT_REVNO) VCS_BRANCH_NAME = $${GIT_BRANCH_NAME} VCS_REVNO = $${GIT_REVNO} - error("this is ok") } win32 { diff --git a/mixxx/build/util.py b/mixxx/build/util.py index 47a3c9ad9e5..7a3238f889f 100644 --- a/mixxx/build/util.py +++ b/mixxx/build/util.py @@ -16,6 +16,27 @@ def on_git(): except: return False +def get_revision(): + if on_bzr(): + return get_bzr_revision() + if on_git(): + return get_git_revision() + return None + +def get_modified(): + if on_bzr(): + return get_bzr_modified() + if on_git(): + return get_git_modified() + return None + +def get_branch_name(): + if on_bzr(): + return get_bzr_branch_name() + if on_git(): + return get_git_branch_name() + return None + def get_git_revision(): return len(os.popen("git log --pretty=oneline --first-parent").read().splitlines()) @@ -36,6 +57,7 @@ def get_git_branch_name(): if match: match = match.groupdict() return match['branch'].strip() + return None def get_bzr_revision(): return os.popen("bzr revno").readline().strip() @@ -151,26 +173,13 @@ def CheckForPKG( context, name, version="" ): def write_build_header(path): f = open(path, 'w') - if on_bzr(): - try: - branch_name = get_bzr_branch_name() - modified = get_bzr_modified() > 0 - # Do not emit BUILD_BRANCH on release branches. - if not branch_name.startswith('release'): - f.write('#define BUILD_BRANCH "%s"\n' % branch_name) - f.write('#define BUILD_REV "%s%s"\n' % (get_bzr_revision(), - '+' if modified else '')) - finally: - f.close() - elif on_git(): - try: - branch_name = get_git_branch_name() - modified = get_git_modified() > 0 - # Do not emit BUILD_BRANCH on release branches. - if not branch_name.startswith('release'): - f.write('#define BUILD_BRANCH "%s"\n' % branch_name) - f.write('#define BUILD_REV "%s%s"\n' % (get_git_revision(), - '+' if modified else '')) - finally: - f.close() - + try: + branch_name = get_branch_name() + modified = get_modified() > 0 + # Do not emit BUILD_BRANCH on release branches. + if not branch_name.startswith('release'): + f.write('#define BUILD_BRANCH "%s"\n' % branch_name) + f.write('#define BUILD_REV "%s%s"\n' % (get_revision(), + '+' if modified else '')) + finally: + f.close() diff --git a/mixxx/src/SConscript b/mixxx/src/SConscript index 844a8192061..f8608d1d444 100644 --- a/mixxx/src/SConscript +++ b/mixxx/src/SConscript @@ -12,12 +12,8 @@ import SCons.Script as SCons from build import util, depends mixxx_version = util.get_mixxx_version() -if util.on_bzr(): - branch_name = util.get_bzr_branch_name() - vcs_revision = util.get_bzr_revision() -elif util.on_git(): - branch_name = util.get_git_branch_name() - vcs_revision = util.get_git_revision() +branch_name = util.get_branch_name() +vcs_revision = util.get_revision() print "WE ARE IN:", os.getcwd() print "Building ", branch_name, " - rev.", vcs_revision From b77778808b9b6303edf4f9e75bfd32dcde4bf35b Mon Sep 17 00:00:00 2001 From: Owen Williams Date: Sun, 19 May 2013 22:15:36 -0400 Subject: [PATCH 3/3] Walk of the tree looking for git or bzr instead of assuming cwd. --- mixxx/build/qtcreator/mixxx.pro | 4 +-- mixxx/build/util.py | 63 ++++++++++++++++++++++++--------- 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/mixxx/build/qtcreator/mixxx.pro b/mixxx/build/qtcreator/mixxx.pro index 37d6cdaefc5..55804a96953 100644 --- a/mixxx/build/qtcreator/mixxx.pro +++ b/mixxx/build/qtcreator/mixxx.pro @@ -908,7 +908,7 @@ exists( .bzr ) { BZR_REVNO = $$system( bzr revno ) BZR_INFO = $$system( bzr info ) for(BZR_INFO_BITS, BZR_INFO) { - BZR_BRANCH_URL = $${BZR_INFO_BITS} + BZR_BRANCH_URL = $${BZR_INFO_BITS} } BZR_BRANCH_NAME = $$dirname(BZR_BRANCH_URL) BZR_BRANCH_NAME = $$basename(BZR_BRANCH_NAME) @@ -919,7 +919,7 @@ exists( .bzr ) { VCS_REVNO = $${BZR_REVNO} } -system (git status) { +exists ( .git ) { # Get info from git about the current branch GIT_REVNO = $$system( git log --pretty=oneline --first-parent | wc -l ) GIT_BRANCH_NAME = $$system( git branch | grep \* | sed -e "s/\* //;" ) diff --git a/mixxx/build/util.py b/mixxx/build/util.py index 7a3238f889f..eed0aed0981 100644 --- a/mixxx/build/util.py +++ b/mixxx/build/util.py @@ -1,39 +1,68 @@ from SCons import Script -import os, sys, platform +import os, os.path, sys, platform import re +CURRENT_VCS = None + +def get_current_vcs(): + if on_git(): + return "git" + if on_bzr(): + return "bzr" + print os.getcwd() + raise Exception("Couldn't identify version control system") + def on_bzr(): - try: - os.stat(".bzr") - return True - except: - return False + cwd = os.getcwd() + basename = " " + while len(basename) > 0: + try: + os.stat(os.path.join(cwd,".bzr")) + return True + except: + pass + cwd,basename = os.path.split(cwd) + return False def on_git(): - try: - os.popen("git status") - return True - except: - return False + cwd = os.getcwd() + basename = " " + while len(basename) > 0: + try: + os.stat(os.path.join(cwd,".git")) + return True + except: + pass + cwd,basename = os.path.split(cwd) + return False def get_revision(): - if on_bzr(): + global CURRENT_VCS + if CURRENT_VCS is None: + CURRENT_VCS = get_current_vcs() + if CURRENT_VCS == "bzr": return get_bzr_revision() - if on_git(): + if CURRENT_VCS == "git": return get_git_revision() return None def get_modified(): - if on_bzr(): + global CURRENT_VCS + if CURRENT_VCS is None: + CURRENT_VCS = get_current_vcs() + if CURRENT_VCS == "bzr": return get_bzr_modified() - if on_git(): + if CURRENT_VCS == "git": return get_git_modified() return None def get_branch_name(): - if on_bzr(): + global CURRENT_VCS + if CURRENT_VCS is None: + CURRENT_VCS = get_current_vcs() + if CURRENT_VCS == "bzr": return get_bzr_branch_name() - if on_git(): + if CURRENT_VCS == "git": return get_git_branch_name() return None