Browse code

simplify release stuff, add travis

Nat! authored on 13/10/2016 15:12:34
Showing 6 changed files
... ...
@@ -5,6 +5,7 @@
5 5
 xcuserdata/
6 6
 project.xcworkspace/
7 7
 *.old
8
+*.exe
8 9
 .bootstrap.auto/
9 10
 .bootstrap.local/
10 11
 dependencies/
... ...
@@ -13,3 +14,5 @@ tmp/
13 13
 research/
14 14
 addictions/
15 15
 mulle-tests/
16
+tests/include/
17
+tests/lib/
16 18
new file mode 100644
... ...
@@ -0,0 +1,22 @@
0
+language: c
1
+
2
+dist: precise
3
+
4
+addons:
5
+  apt:
6
+    sources:
7
+      - george-edison55-precise-backports # cmake 3.2.3 / doxygen 1.8.3
8
+    packages:
9
+      - cmake
10
+      - cmake-data
11
+
12
+before_install:
13
+   - git clone https://github.com/Linuxbrew/brew.git ~/.linuxbrew
14
+   - PATH="$HOME/.linuxbrew/bin:$PATH"
15
+   - brew update
16
+   - brew tap mulle-kybernetik/software
17
+   - brew install mulle-build
18
+
19
+script:
20
+   - mulle-build
21
+   - mulle-test
... ...
@@ -1,36 +1,79 @@
1 1
 # mulle-vararg
2 2
 
3
-A variable argument passing scheme used written in C (C11).
3
+A variable argument passing scheme written in C (C11).
4
+
4 5
 
5 6
 ## How it works
6 7
 
7
-### Remember the C argument promotion rules
8
+**mulle-vararg** assumes that the arguments are not layed out in stack
9
+alignment fashion but like in a struct. The C promotion rules are still
10
+observed though.
8 11
 
9
-1. char and short to int/unsigned int
10
-2. float to double
12
+> Remember the C argument promotion rules are
13
+>
14
+> 1. char and short to int/unsigned int
15
+> 2. float to double
16
+>
11 17
 
12
-### The arguments are layed out struct-like
18
+Let's assume there is a compiler that does not use `<stdarg.h>` variable
19
+arguments but **mulle-vararg** instead. It collects all arguments and packs
20
+them into a struct, then passes this struct to the function.
13 21
 
14
-A method like `stringWithFormat:(NSString *) format, ...`
15
-which is called like this
22
+A **printf** function being being called like this:
16 23
 
17 24
 ```
18
-[NSString stringWithFormat:@"%d %f %lld", (char) 'x', (float) 0.2, 1848LL];
25
+printf( "%d %f %lld\n", (char) 'x', (float) 0.2, 1848LL;
19 26
 ```
20 27
 
21
-could access the arguments as if they were embedded in a struct like this
28
+would access the arguments, as if they were embedded in a struct like this
22 29
 
23 30
 ```
24 31
 struct
25 32
 {
26
-   NSString  *format;
33
+   char    *format;
27 34
    struct
28 35
    {
29
-      int         value1;
30
-      double      value2;
36
+      int         value1;     // standard char -> int promotion
37
+      double      value2;     // standard float -> double promotion
31 38
       long long   value3;
32 39
    } varargs;
33 40
 } _param;
34 41
 ```
35 42
 
36
-But accessing those values, that's what mulle-vararg does for you.
43
+**mulle-vararg** provides the necessary functions to read such a struct. It has
44
+no code to create it.
45
+
46
+
47
+## Install
48
+
49
+On OS X and Linux you can use [homebrew](//brew.sh), respectively
50
+[linuxbrew](//linuxbrew.sh) to install the library:
51
+
52
+```
53
+brew tap mulle-kybernetik/software
54
+brew install mulle-vararg
55
+```
56
+
57
+On other platforms you can use **mulle-install** from
58
+[mulle-build](//www.mulle-kybernetik.com/software/git/mulle-build) to install the library:
59
+
60
+```
61
+mulle-install --prefix /usr/local --branch release https://www.mulle-kybernetik.com/repositories/mulle-vararg
62
+```
63
+
64
+
65
+Otherwise read:
66
+
67
+* [How to Build](dox/BUILD.md)
68
+
69
+
70
+## API
71
+
72
+* [Vararg](dox/API_VARARG.md)
73
+
74
+
75
+### Platforms and Compilers
76
+
77
+All platforms and compilers supported by
78
+[mulle-c11](//www.mulle-kybernetik.com/software/git/mulle-c11/)
79
+
37 80
deleted file mode 100755
... ...
@@ -1,68 +0,0 @@
1
-#! /bin/sh
2
-#
3
-# Generate a formula for mulle-thread
4
-#
5
-PROJECT=MulleVararg  # ruby requires camel-case
6
-TARGET=mulle-vararg
7
-HOMEPAGE="http://www.mulle-kybernetik.com/software/git/${TARGET}"
8
-DESC="Variable arguments using offset() and sizeof()"
9
-
10
-VERSION="$1"
11
-[ $# -eq 0 ] || shift
12
-ARCHIVEURL="${1:-http://www.mulle-kybernetik.com/software/git/${TARGET}/tarball/$VERSION}"
13
-[ $# -eq 0 ] || shift
14
-
15
-set -e
16
-
17
-[ "$VERSION" = "" ] && exit 1
18
-[ "$ARCHIVEURL" = "" ] && exit 1
19
-
20
-
21
-TMPARCHIVE="/tmp/${TARGET}-${VERSION}-archive"
22
-
23
-if [ ! -f "${TMPARCHIVE}" ]
24
-then
25
-   curl -L -o "${TMPARCHIVE}" "${ARCHIVEURL}"
26
-   if [ $? -ne 0 -o ! -f "${TMPARCHIVE}" ]
27
-   then
28
-      echo "Download failed" >&2
29
-      exit 1
30
-   fi
31
-else
32
-   echo "using cached file ${TMPARCHIVE} instead of downloading again" >&2
33
-fi
34
-
35
-#
36
-# anything less than 17 KB is wrong
37
-#
38
-size="`du -k "${TMPARCHIVE}" | awk '{ print $ 1}'`"
39
-if [ $size -lt 17 ]
40
-then
41
-   echo "Archive truncated or missing" >&2
42
-   cat "${TMPARCHIVE}" >&2
43
-   rm "${TMPARCHIVE}"
44
-   exit 1
45
-fi
46
-
47
-HASH="`shasum -p -a 256 "${TMPARCHIVE}" | awk '{ print $1 }'`"
48
-
49
-cat <<EOF
50
-class ${PROJECT} < Formula
51
-  homepage "${HOMEPAGE}"
52
-  desc "${DESC}"
53
-  url "${ARCHIVEURL}"
54
-  version "${VERSION}"
55
-  sha256 "${HASH}"
56
-
57
-  depends_on 'mulle-c11'
58
-  depends_on 'mulle-build' => :build
59
-
60
-  def install
61
-     system "mulle-install", "-e", "--prefix", "#{prefix}"
62
-  end
63
-
64
-  test do
65
-  end
66
-end
67
-# FORMULA ${TARGET}.rb
68
-EOF
69 1
new file mode 100755
... ...
@@ -0,0 +1,231 @@
0
+#! /bin/sh
1
+#
2
+#
3
+#
4
+
5
+generate_brew_formula()
6
+{
7
+   local project
8
+   local target
9
+   local homepage
10
+   local desc
11
+   local version
12
+   local archiveurl
13
+   local dependencies
14
+
15
+   project="$1"
16
+   shift
17
+   target="$1"
18
+   shift
19
+   homepage="$1"
20
+   shift
21
+   desc="$1"
22
+   shift
23
+   version="$1"
24
+   shift
25
+   archiveurl="$1"
26
+   shift
27
+   dependencies="$1"
28
+   shift
29
+
30
+   [ -z "${version}" ] && exit 1
31
+   [ -z "${archiveurl}" ] && exit 1
32
+
33
+   local tmparchive
34
+
35
+   tmparchive="/tmp/${target}-${version}-archive"
36
+
37
+   if [ ! -f "${tmparchive}" ]
38
+   then
39
+      exekutor curl -L -o "${tmparchive}" "${archiveurl}"
40
+      if [ $? -ne 0 -o ! -f "${tmparchive}" ]
41
+      then
42
+         echo "Download failed" >&2
43
+         exit 1
44
+      fi
45
+   else
46
+      echo "using cached file ${tmparchive} instead of downloading again" >&2
47
+   fi
48
+
49
+   #
50
+   # anything less than 17 KB is wrong
51
+   #
52
+   size="`exekutor du -k "${tmparchive}" | exekutor awk '{ print $ 1}'`"
53
+   if [ $size -lt 17 ]
54
+   then
55
+      echo "Archive truncated or missing" >&2
56
+      cat "${tmparchive}" >&2
57
+      rm "${tmparchive}"
58
+      exit 1
59
+   fi
60
+
61
+   local hash
62
+
63
+   hash="`exekutor shasum -p -a 256 "${tmparchive}" | exekutor awk '{ print $1 }'`"
64
+
65
+   exekutor cat <<EOF
66
+class ${project} < Formula
67
+   homepage "${homepage}"
68
+   desc "${desc}"
69
+   url "${archiveurl}"
70
+   version "${version}"
71
+   sha256 "${hash}"
72
+
73
+EOF
74
+
75
+IFS="
76
+"
77
+   for dependency in ${dependencies}
78
+   do
79
+      exekutor echo "   depends_on '${dependency}'"
80
+      shift
81
+   done
82
+   IFS="${DEFAULT_IFS}"
83
+
84
+   exekutor cat <<EOF
85
+   depends_on 'mulle-build' => :build
86
+
87
+   def install
88
+      system "mulle-install", "-e", "--prefix", "#{prefix}"
89
+   end
90
+
91
+   test do
92
+      system "mulle-test"
93
+   end
94
+end
95
+# FORMULA ${TARGET}.rb
96
+EOF
97
+}
98
+
99
+
100
+#
101
+# Boiler plate code from here on. Could put this into a convenient
102
+# location somewhere (mulle-homebrew ?)
103
+# From now on need:
104
+#    TAG
105
+#    HOMEBREWTAP
106
+#    RBFILE
107
+#    ORIGIN
108
+get_header_version()
109
+{
110
+   local filename
111
+
112
+   filename="$1"
113
+   fgrep "${VERSIONNAME}" "${filename}" | \
114
+   sed 's|(\([0-9]*\) \<\< [0-9]*)|\1|g' | \
115
+   sed 's|^.*(\(.*\))|\1|' | \
116
+   sed 's/ | /./g'
117
+}
118
+
119
+
120
+git_must_be_clean()
121
+{
122
+   local name
123
+   local clean
124
+
125
+   name="${1:-${PWD}}"
126
+
127
+   if [ ! -d .git ]
128
+   then
129
+      fail "\"${name}\" is not a git repository"
130
+   fi
131
+
132
+   clean=`git status -s --untracked-files=no`
133
+   if [ "${clean}" != "" ]
134
+   then
135
+      fail "repository \"${name}\" is tainted"
136
+   fi
137
+}
138
+
139
+
140
+# Parameters!
141
+#
142
+# ORIGIN
143
+# TAG
144
+#
145
+git_main()
146
+{
147
+   local origin
148
+   local tag
149
+
150
+   origin="$1"
151
+   shift
152
+   tag="$1"
153
+   shift
154
+
155
+   exekutor git_must_be_clean || exit 1
156
+
157
+   local branch
158
+
159
+   branch="`exekutor git rev-parse --abbrev-ref HEAD`"
160
+
161
+   #
162
+   # make it a release
163
+   #
164
+   exekutor git checkout -B release  || exit 1
165
+   exekutor git rebase "${branch}"   || exit 1
166
+
167
+   # if rebase fails, we shouldn't be hitting tag now
168
+   exekutor git tag "${tag}"         || exit 1
169
+
170
+   exekutor git push "${origin}" release --tags  || exit 1
171
+   exekutor git push github release --tags       || exit 1
172
+
173
+   exekutor git checkout "${branch}"          || exit 1
174
+   exekutor git push "${origin}" "${branch}"  || exit 1
175
+}
176
+
177
+
178
+#
179
+# Expected environment!
180
+# PROJECT
181
+# NAME
182
+# VERSION
183
+# HOMEPAGE
184
+# DESC
185
+# DEPENDENCIES
186
+# HOMEBREWTAP
187
+# RBFILE
188
+#
189
+homebrew_main()
190
+{
191
+   ARCHIVEURL="`eval echo "${ARCHIVEURL}"`"
192
+
193
+   redirect_exekutor "${HOMEBREWTAP}/${RBFILE}" \
194
+      generate_brew_formula "${PROJECT}" \
195
+                            "${NAME}" \
196
+                            "${HOMEPAGE}" \
197
+                            "${DESC}" \
198
+                            "${VERSION}" \
199
+                            "${ARCHIVEURL}" \
200
+                            "${DEPENDENCIES}" || exit 1
201
+   (
202
+      exekutor cd "${HOMEBREWTAP}" ;
203
+      exekutor git add "${RBFILE}" ;
204
+      exekutor git commit -m "${VERSION} release of ${NAME}" "${RBFILE}" ;
205
+      exekutor git push origin master
206
+   )  || exit 1
207
+}
208
+
209
+
210
+homebrew_initialize()
211
+{
212
+   local directory
213
+
214
+   if [ -z "${DEFAULT_IFS}" ]
215
+   then
216
+      DEFAULT_IFS="${IFS}"
217
+   fi
218
+
219
+   directory="`mulle-bootstrap library-path 2> /dev/null`"
220
+   [ ! -d "${directory}" ] && echo "failed to locate mulle-bootstrap library" >&2 && exit 1
221
+   PATH="${directory}:$PATH"
222
+
223
+   . "mulle-bootstrap-logging.sh"
224
+   . "mulle-bootstrap-functions.sh"
225
+
226
+   [ ! -d "${HOMEBREWTAP}" ] && fail "failed to locate \"${HOMEBREWTAP}\""
227
+}
228
+
229
+homebrew_initialize
230
+
... ...
@@ -1,79 +1,41 @@
1
-#! /bin/sh
1
+#! /bin/sh -x
2 2
 
3
+#
4
+# These variables have to be configured on a by project basis
5
+#
3 6
 NAME="mulle-vararg"  # not the ruby name
7
+DESC="Access variable arguments in struct layout fashion"
8
+PROJECT=MulleVararg  # ruby requires camel-case
4 9
 HEADER="src/mulle_vararg.h"
5 10
 VERSIONNAME="MULLE_VARARG_VERSION"
6 11
 ORIGIN=public
12
+DEPENDENCIES=
7 13
 
14
+HOMEPAGE="https://www.mulle-kybernetik.com/software/git/${NAME}"
8 15
 RBFILE="${NAME}.rb"
9 16
 HOMEBREWTAP="../homebrew-software"
10 17
 
11
-
12
-get_version()
13
-{
14
-   local filename
15
-
16
-   filename="$1"
17
-   fgrep "${VERSIONNAME}" "${filename}" | \
18
-   sed 's|(\([0-9]*\) \<\< [0-9]*)|\1|g' | \
19
-   sed 's|^.*(\(.*\))|\1|' | \
20
-   sed 's/ | /./g'
21
-}
22
-
23
-VERSION="`get_version ${HEADER}`"
24
-TAG="${1:-${VERSION}}"
25
-
26
-
27
-directory="`mulle-bootstrap library-path 2> /dev/null`"
28
-[ ! -d "${directory}" ] && echo "failed to locate mulle-bootstrap library" >&2 && exit 1
29
-
30
-PATH="${directory}:$PATH"
31
-
32
-. "mulle-bootstrap-logging.sh"
18
+# ARCHIVEURL will be evaled later! keep it in single quotes
19
+ARCHIVEURL='https://www.mulle-kybernetik.com/software/git/${NAME}/tarball/${VERSION}'
33 20
 
34 21
 
35
-git_must_be_clean()
22
+main()
36 23
 {
37
-   local name
38
-   local clean
24
+   # source it
25
+   . ./bin/mulle-homebrew/mulle-homebrew.sh
39 26
 
40
-   name="${1:-${PWD}}"
27
+   local VERSION  #  upper case for consistency in eval
28
+   local TAG
41 29
 
42
-   if [ ! -d .git ]
43
-   then
44
-      fail "\"${name}\" is not a git repository"
45
-   fi
30
+   #
31
+   # Version has to be figured out on a per project basis
32
+   # get_header_version grabs the version from a header
33
+   #
34
+   VERSION="`get_header_version ${HEADER}`"
35
+   TAG="${1:-${VERSION}}"
46 36
 
47
-   clean=`git status -s --untracked-files=no`
48
-   if [ "${clean}" != "" ]
49
-   then
50
-      fail "repository \"${name}\" is tainted"
51
-   fi
37
+   git_main "${ORIGIN}" "${TAG}" || exit 1
38
+   homebrew_main || exit 1
52 39
 }
53 40
 
54
-
55
-[ ! -d "${HOMEBREWTAP}" ] && fail "failed to locate \"${HOMEBREWTAP}\""
56
-
57
-set -e
58
-
59
-git_must_be_clean
60
-
61
-branch="`git rev-parse --abbrev-ref HEAD`"
62
-
63
-git push "${ORIGIN}" "${branch}"
64
-
65
-# seperate step, as it's tedious to remove tag when
66
-# previous push fails
67
-
68
-git tag "${TAG}"
69
-git push "${ORIGIN}" "${branch}" --tags
70
-
71
-./bin/generate-brew-formula.sh "${VERSION}" > "${HOMEBREWTAP}/${RBFILE}"
72
-(
73
-   cd "${HOMEBREWTAP}" ;
74
-   git add "${RBFILE}" ;
75
-   git commit -m "${TAG} release of ${NAME}" "${RBFILE}" ;
76
-   git push origin master
77
-)
78
-
79
-git checkout "${branch}"
41
+main "$@"