Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add git to build system #3

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mixxx/build/nsis/Mixxx-garth.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
26 changes: 13 additions & 13 deletions mixxx/build/nsis/Mixxx.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
38 changes: 26 additions & 12 deletions mixxx/build/qtcreator/mixxx.pro
Original file line number Diff line number Diff line change
Expand Up @@ -903,17 +903,31 @@ 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}
}
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...
Expand All @@ -922,13 +936,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'"' )
Expand Down
63 changes: 60 additions & 3 deletions mixxx/build/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,63 @@
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_revision():
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Ugly But Easy Way

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())

def get_git_modified():
modified_matcher = re.compile("^#.*modified: (?P<filename>.*?)$")
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<branch>.*?)$")
for line in os.popen("git branch").read().splitlines():
match = branch_matcher.match(line)
if match:
match = match.groupdict()
return match['branch'].strip()
return None

def get_bzr_revision():
return os.popen("bzr revno").readline().strip()

Expand Down Expand Up @@ -117,12 +174,12 @@ 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
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_bzr_revision(),
f.write('#define BUILD_REV "%s%s"\n' % (get_revision(),
'+' if modified else ''))
finally:
f.close()
39 changes: 20 additions & 19 deletions mixxx/src/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ 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()
branch_name = util.get_branch_name()
vcs_revision = util.get_revision()
print "WE ARE IN:", os.getcwd()
print "Building ", branch_name, " - rev.", vcs_revision

plugins = []

Expand All @@ -38,11 +39,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()
Expand Down Expand Up @@ -97,34 +98,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
#=========================
Expand Down Expand Up @@ -412,7 +413,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)
Expand Down Expand Up @@ -503,7 +504,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
Expand Down Expand Up @@ -660,7 +661,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()
Expand Down Expand Up @@ -688,7 +689,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)

Expand Down Expand Up @@ -724,12 +725,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:
Expand Down