/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
116.1.2 by Gustav Hartvigsson
* added a build (build.sh)script that later can be used for other things.
1
#!/usr/bin/env bash
2
124 by Gustav Hartvigsson
* added branch commad to the ./build.sh script.
3
ARGV=("$@")
4
5
116.1.2 by Gustav Hartvigsson
* added a build (build.sh)script that later can be used for other things.
6
###
7
# http://stackoverflow.com/a/23342259
8
###
9
exe() { echo "\$ $@" ; "$@" ; }
10
158 by Gustav Hartvigsson
removed CMake stuff
11
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
12
cd $CWD
13
116.1.2 by Gustav Hartvigsson
* added a build (build.sh)script that later can be used for other things.
14
show_usage () {
15
  echo ""
16
  echo "Set up the building of libssts and clean up too."
158 by Gustav Hartvigsson
removed CMake stuff
17
  echo "  This is not ment as a replacment for bazaar or for meson, just a"
125.1.1 by Gustav Hartvigsson
* Added merge-trunk command to ./build.sh
18
  echo "  \"kick-start\" for new developers... and makes branching easier."
19
  echo ""
123 by Gustav Hartvigsson
* added clean-tree to build.sh
20
  echo "  ./build.sh clean      -  Clean up the project and build files."
125 by Gustav Hartvigsson
* Added aliases to ./build.sh
21
  echo "             cl"
123 by Gustav Hartvigsson
* added clean-tree to build.sh
22
  echo ""
23
  echo "  ./build.sh build      -  Create the build directory, run CMake (if"
125 by Gustav Hartvigsson
* Added aliases to ./build.sh
24
  echo "             bl            needed) and build libssts."
123 by Gustav Hartvigsson
* added clean-tree to build.sh
25
  echo ""
26
  echo "  ./build.sh help       -  Show this helpful help text."
125 by Gustav Hartvigsson
* Added aliases to ./build.sh
27
  echo "             -h"
123 by Gustav Hartvigsson
* added clean-tree to build.sh
28
  echo ""
29
  echo "  ./build.sh clean-tree -  clean the bzr three. reverting all and any"
125 by Gustav Hartvigsson
* Added aliases to ./build.sh
30
  echo "             ct            changes made to the file tree since the last"
123 by Gustav Hartvigsson
* added clean-tree to build.sh
31
  echo "                           commit."
124 by Gustav Hartvigsson
* added branch commad to the ./build.sh script.
32
  echo ""
33
  echo "  ./build.sh commit     -  commit changes."
125 by Gustav Hartvigsson
* Added aliases to ./build.sh
34
  echo "             cm"
124 by Gustav Hartvigsson
* added branch commad to the ./build.sh script.
35
  echo ""
36
  echo "  ./build.sh branch <name> - create a branch. This will cd up one level"
125 by Gustav Hartvigsson
* Added aliases to ./build.sh
37
  echo "             br              and then do a branch. The name of the"
124 by Gustav Hartvigsson
* added branch commad to the ./build.sh script.
38
  echo "                             branch will be \"simpletypesystem_<name>\"."
125 by Gustav Hartvigsson
* Added aliases to ./build.sh
39
  echo ""
125.1.2 by Gustav Hartvigsson
* deerrr.
40
  echo "  ./build.sh merge-trunk   - Commits your current changes and then pull"
125 by Gustav Hartvigsson
* Added aliases to ./build.sh
41
  echo "             mt             merge from trunk. If the merge went smoothly"
42
  echo "                            it will procide to commit the merge with"
43
  echo "                            message \"* Merged trunk.\""
125.1.1 by Gustav Hartvigsson
* Added merge-trunk command to ./build.sh
44
  echo ""
125.1.2 by Gustav Hartvigsson
* deerrr.
45
  echo " ./build.sh propose-merge  - Propese merge of current branch."
125.1.1 by Gustav Hartvigsson
* Added merge-trunk command to ./build.sh
46
  echo "            pm"
116.1.2 by Gustav Hartvigsson
* added a build (build.sh)script that later can be used for other things.
47
}
48
49
do_build () {
158 by Gustav Hartvigsson
removed CMake stuff
50
  cd $CWD
116.1.2 by Gustav Hartvigsson
* added a build (build.sh)script that later can be used for other things.
51
  if ( ! -d "./build" )
52
  then
53
    exe mkdir ./build
54
  fi
55
  
56
  cd ./build
57
  
158 by Gustav Hartvigsson
removed CMake stuff
58
  if [ ! -f "build.ninja" ]
59
  then
60
    exe meson ..
61
  fi
62
  
63
  ninja
64
}
65
66
do_test () {
67
  if ( ! -d "./build" )
68
  then
69
    do_build
70
  fi
71
  
72
  cd $__CWD/build
73
  
74
  exe ninja test
75
  
116.1.2 by Gustav Hartvigsson
* added a build (build.sh)script that later can be used for other things.
76
}
77
78
do_clean () {
79
  if [ -d "./build" ]
80
  then
81
    exe rm -R ./build
82
  fi
83
}
84
123 by Gustav Hartvigsson
* added clean-tree to build.sh
85
do_clean_tree () {
158 by Gustav Hartvigsson
removed CMake stuff
86
  exe brz revert
87
  exe brz clean-tree 
123 by Gustav Hartvigsson
* added clean-tree to build.sh
88
}
89
124 by Gustav Hartvigsson
* added branch commad to the ./build.sh script.
90
do_commit () {
158 by Gustav Hartvigsson
removed CMake stuff
91
  exe brz commit
124 by Gustav Hartvigsson
* added branch commad to the ./build.sh script.
92
}
93
125 by Gustav Hartvigsson
* Added aliases to ./build.sh
94
124 by Gustav Hartvigsson
* added branch commad to the ./build.sh script.
95
do_branch () {
96
  echo ${ARGV[1]}
97
  if [[ -z ${ARGV[1]} ]]
98
  then
99
    echo "Missing branch name."
100
    show_usage
101
    exit
102
  else
103
    #build up the branch name.
104
    NEW_BRANCH_NAME="simpletypesystem_"${ARGV[1]}
105
    CURRENT_WD=$(pwd)
106
    exe cd ..
107
    PARENT_WD=$(pwd)
108
    exe bzr branch $CURRENT_WD $PARENT_WD/$NEW_BRANCH_NAME
125.1.1 by Gustav Hartvigsson
* Added merge-trunk command to ./build.sh
109
    if [[ -z $? ]]
124 by Gustav Hartvigsson
* added branch commad to the ./build.sh script.
110
    then
111
      echo ""
112
      echo "Something went wrong when trying to branch..."
113
    else
114
      echo ""
115
      echo "The directory $PARENT_WD/$NEW_BRANCH_NAME is ready. To go to that"
116
      echo "branch cd to it."
117
      echo ""
118
      echo "Remember to commit often and run"
119
      echo "$ bzr push --remember lp:~<lp-username>/simpletypesystem/${ARGV[1]}"
120
      echo "before you start hacking."
121
    fi
122
  fi
123
}
124
125 by Gustav Hartvigsson
* Added aliases to ./build.sh
125
do_merge_trunk () {
158 by Gustav Hartvigsson
removed CMake stuff
126
  exe brz commit
127
  exe brz merge lp:simpletypesystem
125.1.1 by Gustav Hartvigsson
* Added merge-trunk command to ./build.sh
128
  if [[ -z $? ]]
125 by Gustav Hartvigsson
* Added aliases to ./build.sh
129
  then
130
    echo "Something went wrong with the merge! Plese solve these problems"
131
    echo "before you procide to commit again!"
132
  else
133
    exe commit -m "* Merged with trunk."
134
  fi
135
}
136
125.1.1 by Gustav Hartvigsson
* Added merge-trunk command to ./build.sh
137
do_propose_merge () {
158 by Gustav Hartvigsson
removed CMake stuff
138
  exe brz lp-propose-merge
125.1.1 by Gustav Hartvigsson
* Added merge-trunk command to ./build.sh
139
}
140
124 by Gustav Hartvigsson
* added branch commad to the ./build.sh script.
141
case ${ARGV[0]} in
116.1.2 by Gustav Hartvigsson
* added a build (build.sh)script that later can be used for other things.
142
     "help"|"-h") show_usage ;;
125 by Gustav Hartvigsson
* Added aliases to ./build.sh
143
     "clean"|"cl") do_clean ;;
144
     "build"|"bl") do_build ;;
158 by Gustav Hartvigsson
removed CMake stuff
145
     "test"|"tt") do_test ;;
125 by Gustav Hartvigsson
* Added aliases to ./build.sh
146
     "clean-tree"|"ct") do_clean_tree ;;
147
     "commit"|"cm") do_commit ;;
148
     "branch"|"br") do_branch ;;
149
     "merge-trunk"|"mt") do_merge_trunk ;;
125.1.2 by Gustav Hartvigsson
* deerrr.
150
     "propose-merge"|"pm") do_propose_merge ;;
116.1.2 by Gustav Hartvigsson
* added a build (build.sh)script that later can be used for other things.
151
     *) show_usage ;;
152
esac
153
158 by Gustav Hartvigsson
removed CMake stuff
154
cd $CWD
116.1.2 by Gustav Hartvigsson
* added a build (build.sh)script that later can be used for other things.
155