1- #! /bin/sh -e
1+ #! /bin/sh -e
22
33# -----------------------------------------------------------------------------
44# Bundle release
@@ -40,7 +40,23 @@ on_path() {
4040
4141
4242# ---------------------------------------------------------
43- # Detect OS and cpu architecture
43+ # Detect git tag and commit
44+ # ---------------------------------------------------------
45+
46+ detect_git_tag () {
47+ if [ -z " $MI_COMMIT " ] ; then
48+ MI_COMMIT=` git rev-parse HEAD`
49+ fi
50+ if [ -z " $MI_TAG " ] ; then
51+ MI_TAG=` git describe --tag`
52+ fi
53+ info " Tag : $MI_TAG "
54+ info " Commit : $MI_COMMIT "
55+ }
56+
57+
58+ # ---------------------------------------------------------
59+ # Detect OS and cpu architecture
4460# ---------------------------------------------------------
4561
4662contains () {
@@ -99,8 +115,6 @@ detect_osarch() {
99115 fi
100116}
101117
102-
103-
104118# ---------------------------------------------------------
105119# Command line options
106120# ---------------------------------------------------------
@@ -121,10 +135,6 @@ process_options() {
121135 PREFIX=" $1 " ;;
122136 -p=* |--prefix=* )
123137 PREFIX=` eval echo $flag_arg ` ;; # no quotes so ~ gets expanded (issue #412)
124- -t) shift
125- MI_TAG=" $1 " ;;
126- -t=* |--tag=* )
127- MI_TAG=" $flag_arg " ;;
128138 -h|--help|-\? |help|\? )
129139 MODE=" help" ;;
130140 * ) case " $flag " in
@@ -133,26 +143,15 @@ process_options() {
133143 esac
134144 shift
135145 done
136-
137- if [ -z " $MI_COMMIT " ] ; then
138- MI_COMMIT=` git log -n 1 --pretty=format:" %H" `
139- fi
140- if [ -z " $MI_TAG " ] ; then
141- MI_TAG=` git describe --tag`
142- fi
143- info " Tag : $MI_TAG "
144- info " Commit : $MI_COMMIT "
145146}
146147
147-
148-
149148# ---------------------------------------------------------
150- # Download
149+ # Download
151150# ---------------------------------------------------------
152151
153152download_failed () { # <program> <url>
154153 warn " "
155- warn " unable to download: $2 "
154+ warn " unable to download: $2 "
156155 stop " "
157156}
158157
@@ -180,25 +179,9 @@ download_file() { # <url|file> <destination file>
180179 esac
181180}
182181
183- download_available () { # <url|file>
184- case " $1 " in
185- ftp://* |http://* |https://* )
186- if has_cmd curl ; then
187- if ! curl -sS --proto =https --tlsv1.2 -L -I " $1 " | grep -E " ^HTTP/2 200" ; then # -I is headers only
188- return 1
189- fi
190- fi ;;
191- * )
192- if ! [ -f " $1 " ] ; then
193- return 1
194- fi ;;
195- esac
196- return 0
197- }
198-
199- download_source_at_tag () { # <tag> <output file>
200- download_file " https://github.com/microsoft/mimalloc/archive/refs/tags/$1 .tar.gz" " $2 "
201- }
182+ # ---------------------------------------------------------
183+ # Bundle
184+ # ---------------------------------------------------------
202185
203186download_source_at_commit () { # <commit> <output file>
204187 download_file " https://github.com/microsoft/mimalloc/archive/$1 .tar.gz" " $2 "
@@ -210,24 +193,15 @@ build_test_install() { # <type> <bundledir> <prefix> <cmake args>
210193 mkdir -p " $build_dir "
211194 cmake . -B " $build_dir " $4
212195 cmake --build " $build_dir "
213- ctest --test-dir " $build_dir "
196+ ctest --test-dir " $build_dir "
214197 cmake --install " $build_dir " --prefix " $3 "
215198}
216-
217- # ---------------------------------------------------------
218- # Main
219- # ---------------------------------------------------------
220199
221200main_bundle () {
222201 # config
223202 bundle_dir=" out/bundle"
224203 mkdir -p " $bundle_dir "
225204
226- # source archive
227- info " Download source archive for $MI_TAG "
228- source_archive=" $bundle_dir /mimalloc-$MI_TAG -source.tar.gz"
229- download_source_at_commit " $MI_COMMIT " " $source_archive "
230-
231205 # build
232206 prefix_dir=" $bundle_dir /prefix"
233207 build_test_install " debug" " $bundle_dir " " $prefix_dir " " -DCMAKE_BUILD_TYPE=Debug"
@@ -237,20 +211,28 @@ main_bundle() {
237211 # archive binaries
238212 binary_archive_name=" mimalloc-$MI_TAG -$OSARCH .tar.gz"
239213 binary_archive=" $bundle_dir /$binary_archive_name "
240- info " Create binary archive: $binary_archive_name "
241- pushd $bundle_dir
242- tar -czvf " $binary_archive_name " prefix
214+ info " Create binary archive: $binary_archive_name "
215+ pushd " $prefix_dir "
216+ tar -czvf " ../ $binary_archive_name " .
243217 popd
244218
219+ # source archive
220+ info " Download source archive for $MI_TAG "
221+ source_archive=" $bundle_dir /mimalloc-$MI_TAG -source.tar.gz"
222+ download_source_at_commit " $MI_COMMIT " " $source_archive "
223+
245224 # done
246225 info " "
247- info " Created:"
226+ info " Created:"
248227 info " - $binary_archive "
249228 info " - $source_archive "
250229 info " "
251- info " Done."
230+ info " Done."
252231}
253232
233+ # ---------------------------------------------------------
234+ # Main
235+ # ---------------------------------------------------------
254236
255237main_help () {
256238 info " command:"
0 commit comments