| @@ -0,0 +1,206 @@ | |||||
| #!/bin/bash | |||||
| # set -x #enable debug | |||||
| SCRIPTPATH=$(readlink -f $0) | |||||
| SCRIPTNAME=$(basename $SCRIPTPATH) | |||||
| SCRIPTDIR=$(dirname $SCRIPTPATH) | |||||
| git="git" | |||||
| HAS_GIT=true | |||||
| HEADER_DIR="$SCRIPTDIR/header" | |||||
| DOCU_DIR="$SCRIPTDIR/doc" | |||||
| INC_MAJOR=false | |||||
| INC_MINOR=false | |||||
| INC_BUGFIX=false | |||||
| function log() | |||||
| { | |||||
| echo "$@" >&2 | |||||
| } | |||||
| function cleaupAndExit() | |||||
| { | |||||
| if $HAS_GIT && [[ -n "$TAGNAME" ]] && [[ $1 -ne 0 ]]; then | |||||
| log "remove git tag $TAGNAME" | |||||
| $git tag -d $TAGNAME | |||||
| fi | |||||
| exit $1 | |||||
| } | |||||
| function printHelp() | |||||
| { | |||||
| printf "script to build libShaderFile release | |||||
| Usage: | |||||
| $SCRIPTNAME [parameter] | |||||
| [] optional parameters | |||||
| () required parameters | |||||
| Parameter: | |||||
| --major | -m | |||||
| increment major version and reset the minor version before creating git tag | |||||
| --minor | -n | |||||
| increment major version and reset the bugfix version before creating git tag | |||||
| --bufgix | -b | |||||
| increment bugfix version before creating git tag | |||||
| --help | -h | -? | |||||
| print this help | |||||
| " | |||||
| } | |||||
| function getLastVersion() | |||||
| { | |||||
| POS="HEAD" | |||||
| TAG=$($git describe --tags --abbrev=0 $POS 2>/dev/null) | |||||
| RET=$? | |||||
| while [[ $RET -eq 0 ]]; do | |||||
| if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |||||
| echo $(echo $TAG | egrep -o "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+") | |||||
| return 0 | |||||
| fi | |||||
| POS=$TAG"^" | |||||
| TAG=$($git describe --tags --abbrev=0 $POS 2>/dev/null) | |||||
| RET=$? | |||||
| done | |||||
| return 1 | |||||
| } | |||||
| function incVersion() | |||||
| { | |||||
| read -r -a PARTS <<< $(echo "$1" | tr "." " ") | |||||
| if $INC_MAJOR; then | |||||
| ((PARTS[0]++)) | |||||
| PARTS[1]=0 | |||||
| fi | |||||
| if $INC_MINOR; then | |||||
| ((PARTS[1]++)) | |||||
| PARTS[2]=0 | |||||
| fi | |||||
| if $INC_BUGFIX; then | |||||
| ((PARTS[2]++)) | |||||
| fi | |||||
| ((PARTS[3]++)) | |||||
| local tmp="${PARTS[@]}" | |||||
| echo "${tmp// /.}" | |||||
| } | |||||
| function addGitTag() | |||||
| { | |||||
| local INC_VERSION=true | |||||
| log "create git version tag" | |||||
| CURRENT=$(getLastVersion) | |||||
| if [ $? -ne 0 ]; then | |||||
| CURRENT="0.0.0.0" | |||||
| INC_VERSION=false | |||||
| fi | |||||
| local tmp="v$CURRENT" | |||||
| LINES=$($git log --pretty=oneline $tmp..HEAD) | |||||
| if [ $? -eq 0 ]; then | |||||
| DIFF=$(echo $LINES | wc -l) | |||||
| if [ $DIFF -eq 0 ] || [ -z "$LINES" ]; then | |||||
| log "current commit already has a version tag: $tmp" | |||||
| TAGNAME=$tmp | |||||
| return 0 | |||||
| fi | |||||
| fi | |||||
| if $INC_VERSION; then | |||||
| NEWVERSION=$(incVersion $CURRENT) | |||||
| else | |||||
| NEWVERSION="$CURRENT" | |||||
| fi | |||||
| log "current version: $CURRENT" | |||||
| log "new version: $NEWVERSION" | |||||
| local tmp="v$NEWVERSION" | |||||
| $git tag $tmp | |||||
| if [[ $? -ne 0 ]]; then | |||||
| log "unable to create version tag: exit" | |||||
| cleaupAndExit 100 | |||||
| fi | |||||
| TAGNAME=$tmp | |||||
| return 0 | |||||
| } | |||||
| function BuildConfig() | |||||
| { | |||||
| CONFIG=$1 | |||||
| POSTFIX=$2 | |||||
| FILEEXT=$3 | |||||
| printf "\n== build project $CONFIG ==\n" | |||||
| lazbuild --build-mode=$CONFIG --build-all --verbose $SCRIPTDIR/libTextSuite.lpi | |||||
| if [ $? -ne 0 ]; then | |||||
| echo "build failed! exit." | |||||
| cleaupAndExit 1 | |||||
| fi | |||||
| ZIPDIR="bin/$POSTFIX" | |||||
| BINDIR="$ZIPDIR" | |||||
| ZIPPATH="$SCRIPTDIR/libTextSuite-$POSTFIX.zip" | |||||
| if [ -n "$TAGNAME" ]; then | |||||
| mkdir -p "$SCRIPTDIR/$TAGNAME/" | |||||
| ZIPPATH="$SCRIPTDIR/$TAGNAME/libTextSuite-$POSTFIX.zip" | |||||
| fi | |||||
| BINNAME="libTextSuite-$POSTFIX$FILEEXT" | |||||
| if [ ! -f $BINNAME ]; then | |||||
| echo "file not found: $EXENAME" | |||||
| cleaupAndExit 2 | |||||
| fi | |||||
| mkdir -p $BINDIR | |||||
| mv "$BINNAME" "$BINDIR/" || { log "unable to copy linked binary"; cleaupAndExit 3; } | |||||
| # use this to copy data folder instead of data archive: cp -R --preserve=links data $BINDIR || { log "unable to copy data folder"; cleaupAndExit 4; } | |||||
| cp -r "$HEADER_DIR" "$BINDIR" || { log "unable to copy header files"; cleaupAndExit 4; } | |||||
| cp -r "$DOCU_DIR" "$BINDIR/docu" || { log "unable to copy documentation files"; cleaupAndExit 5; } | |||||
| pushd $ZIPDIR | |||||
| rm -rf $ZIPPATH | |||||
| zip -r $ZIPPATH ./* || { log "unable to create zip archive"; cleaupAndExit 6; } | |||||
| popd | |||||
| } | |||||
| while [[ $# -gt 0 ]]; do | |||||
| case $1 in | |||||
| "--major" | "-m") | |||||
| INC_MAJOR=true | |||||
| ;; | |||||
| "--minor" | "-n") | |||||
| INC_MINOR=true | |||||
| ;; | |||||
| "--bufgix" | "-b") | |||||
| INC_BUGFIX=true | |||||
| ;; | |||||
| "--help" | "-h" | "-?") | |||||
| printHelp | |||||
| cleaupAndExit 0 | |||||
| ;; | |||||
| *) | |||||
| echo "invalid parameter: $1" | |||||
| echo "use --help to get further information" | |||||
| ;; | |||||
| esac | |||||
| shift | |||||
| done | |||||
| if $HAS_GIT; then | |||||
| GIT_CHANGED=$($git status --untracked-files=all --verbose --porcelain) | |||||
| if [[ -n "$GIT_CHANGED" ]]; then | |||||
| log "git has uncommited changes. please commit before building a release" | |||||
| cleaupAndExit 101 | |||||
| fi | |||||
| addGitTag | |||||
| fi | |||||
| BuildConfig "Win32Release" "i386-win32" ".dll" | |||||
| BuildConfig "Win64Release" "x86_64-win64" ".dll" | |||||
| BuildConfig "Linux32Release" "i386-linux" ".so" | |||||
| BuildConfig "Linux64Release" "x86_64-linux" ".so" | |||||
| cleaupAndExit 0 | |||||
| @@ -231,7 +231,7 @@ | |||||
| </Other> | </Other> | ||||
| </CompilerOptions> | </CompilerOptions> | ||||
| </Item6> | </Item6> | ||||
| <Item7 Name="Linus32Release"> | |||||
| <Item7 Name="Linux32Release"> | |||||
| <CompilerOptions> | <CompilerOptions> | ||||
| <Version Value="11"/> | <Version Value="11"/> | ||||
| <PathDelim Value="\"/> | <PathDelim Value="\"/> | ||||
| @@ -367,57 +367,46 @@ | |||||
| <Unit1> | <Unit1> | ||||
| <Filename Value="ultsUtils.pas"/> | <Filename Value="ultsUtils.pas"/> | ||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <UnitName Value="ultsUtils"/> | |||||
| </Unit1> | </Unit1> | ||||
| <Unit2> | <Unit2> | ||||
| <Filename Value="ultsTypes.pas"/> | <Filename Value="ultsTypes.pas"/> | ||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <UnitName Value="ultsTypes"/> | |||||
| </Unit2> | </Unit2> | ||||
| <Unit3> | <Unit3> | ||||
| <Filename Value="ultsContext.pas"/> | <Filename Value="ultsContext.pas"/> | ||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <UnitName Value="ultsContext"/> | |||||
| </Unit3> | </Unit3> | ||||
| <Unit4> | <Unit4> | ||||
| <Filename Value="ultsRenderer.pas"/> | <Filename Value="ultsRenderer.pas"/> | ||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <UnitName Value="ultsRenderer"/> | |||||
| </Unit4> | </Unit4> | ||||
| <Unit5> | <Unit5> | ||||
| <Filename Value="ultsTextBlock.pas"/> | <Filename Value="ultsTextBlock.pas"/> | ||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <UnitName Value="ultsTextBlock"/> | |||||
| </Unit5> | </Unit5> | ||||
| <Unit6> | <Unit6> | ||||
| <Filename Value="ultsGeneral.pas"/> | <Filename Value="ultsGeneral.pas"/> | ||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <UnitName Value="ultsGeneral"/> | |||||
| </Unit6> | </Unit6> | ||||
| <Unit7> | <Unit7> | ||||
| <Filename Value="ultsFont.pas"/> | <Filename Value="ultsFont.pas"/> | ||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <UnitName Value="ultsFont"/> | |||||
| </Unit7> | </Unit7> | ||||
| <Unit8> | <Unit8> | ||||
| <Filename Value="ultsFontCreator.pas"/> | <Filename Value="ultsFontCreator.pas"/> | ||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <UnitName Value="ultsFontCreator"/> | |||||
| </Unit8> | </Unit8> | ||||
| <Unit9> | <Unit9> | ||||
| <Filename Value="ultsImage.pas"/> | <Filename Value="ultsImage.pas"/> | ||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <UnitName Value="ultsImage"/> | |||||
| </Unit9> | </Unit9> | ||||
| <Unit10> | <Unit10> | ||||
| <Filename Value="ultsPostProcessor.pas"/> | <Filename Value="ultsPostProcessor.pas"/> | ||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <UnitName Value="ultsPostProcessor"/> | |||||
| </Unit10> | </Unit10> | ||||
| <Unit11> | <Unit11> | ||||
| <Filename Value="ultsChar.pas"/> | <Filename Value="ultsChar.pas"/> | ||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <UnitName Value="ultsChar"/> | |||||
| </Unit11> | </Unit11> | ||||
| </Units> | </Units> | ||||
| </ProjectOptions> | </ProjectOptions> | ||||