44# Bundle release
55# -----------------------------------------------------------------------------
66
7- QUIET=" "
8- FORCE=" "
97OSARCH=" "
108OSNAME=" "
119MI_TAG=" "
@@ -34,10 +32,6 @@ has_cmd() {
3432 command -v " $1 " > /dev/null 2>&1
3533}
3634
37- on_path () {
38- echo " :$PATH :" | grep -q :" $1 " :
39- }
40-
4135
4236# ---------------------------------------------------------
4337# Detect git tag and commit
@@ -59,14 +53,6 @@ detect_git_tag() {
5953# Detect OS and cpu architecture
6054# ---------------------------------------------------------
6155
62- contains () {
63- if echo " $1 " | grep -i -E " $2 " > /dev/null; then
64- return 0
65- else
66- return 1
67- fi
68- }
69-
7056detect_osarch () {
7157 arch=" $( uname -m) "
7258 case " $arch " in
@@ -96,23 +82,6 @@ detect_osarch() {
9682 info " Warning: assuming generic Linux"
9783 esac
9884 OSARCH=" $OSNAME -$arch "
99-
100- if [ " $OSNAME " = " linux" ]; then
101- distrocfg=` cat $( find /etc/* -release -type f) `
102- if contains " $distrocfg " " rhel" ; then
103- OSDISTRO=" rhel"
104- elif contains " $distrocfg " " opensuse" ; then
105- OSDISTRO=" opensuse"
106- elif contains " $distrocfg " " alpine" ; then
107- OSDISTRO=" alpine"
108- elif contains " $distrocfg " " arch" ; then
109- OSDISTRO=" arch"
110- elif contains " $distrocfg " " ubuntu|debian" ; then
111- OSDISTRO=" ubuntu"
112- else
113- OSDISTRO=" ubuntu" # default
114- fi
115- fi
11685}
11786
11887# ---------------------------------------------------------
@@ -150,9 +119,7 @@ process_options() {
150119# ---------------------------------------------------------
151120
152121download_failed () { # <program> <url>
153- warn " "
154- warn " unable to download: $2 "
155- stop " "
122+ stop " unable to download: $2 "
156123}
157124
158125download_file () { # <url|file> <destination file>
@@ -171,7 +138,6 @@ download_file() { # <url|file> <destination file>
171138 stop " Neither 'curl' nor 'wget' is available; install one to continue."
172139 fi ;;
173140 * )
174- # echo "cp $1 to $2"
175141 info " Copying: $1 "
176142 if ! cp $1 $2 ; then
177143 stop " Unable to copy from $1 "
@@ -192,18 +158,22 @@ build_test_install() { # <type> <bundledir> <prefix> <cmake args>
192158 build_dir=" $2 /$1 "
193159 mkdir -p " $build_dir "
194160 cmake . -B " $build_dir " $4
195- cmake --build " $build_dir "
196- ctest --test-dir " $build_dir "
161+ cmake --build " $build_dir " --parallel 4
162+ # ctest --test-dir "$build_dir"
197163 cmake --install " $build_dir " --prefix " $3 "
198164}
199165
200166main_bundle () {
201167 # config
202168 bundle_dir=" out/bundle"
203169 mkdir -p " $bundle_dir "
170+ if [ -z " $PREFIX " ] ; then
171+ prefix_dir=" $bundle_dir /prefix"
172+ else
173+ prefix_dir=" $PREFIX "
174+ fi
204175
205176 # build
206- prefix_dir=" $bundle_dir /prefix"
207177 build_test_install " debug" " $bundle_dir " " $prefix_dir " " -DCMAKE_BUILD_TYPE=Debug"
208178 build_test_install " release" " $bundle_dir " " $prefix_dir " " -DCMAKE_BUILD_TYPE=Release -DMI_OPT_ARCH=ON"
209179 build_test_install " secure" " $bundle_dir " " $prefix_dir " " -DCMAKE_BUILD_TYPE=Release -DMI_OPT_ARCH=ON -DMI_SECURE=ON"
@@ -212,20 +182,22 @@ main_bundle() {
212182 binary_archive_name=" mimalloc-$MI_TAG -$OSARCH .tar.gz"
213183 binary_archive=" $bundle_dir /$binary_archive_name "
214184 info " Create binary archive: $binary_archive_name "
215- pushd " $prefix_dir "
216- tar -czvf " ../$binary_archive_name " .
217- popd
185+ (cd " $prefix_dir " && tar -czvf " ../$binary_archive_name " .)
218186
219187 # 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 "
188+ if [ " $OSNAME " = " linux" ] ; then
189+ info " Download source archive for $MI_TAG "
190+ source_archive=" $bundle_dir /mimalloc-$MI_TAG -source.tar.gz"
191+ download_source_at_commit " $MI_COMMIT " " $source_archive "
192+ fi
223193
224194 # done
225195 info " "
226196 info " Created:"
227197 info " - $binary_archive "
228- info " - $source_archive "
198+ if [ -n " $source_archive " ] ; then
199+ info " - $source_archive "
200+ fi
229201 info " "
230202 info " Done."
231203}
@@ -240,13 +212,14 @@ main_help() {
240212 info " "
241213 info " options:"
242214 info " -q, --quiet suppress output"
243- info " -f, --force continue without prompting"
244215 info " -p, --prefix=<dir> prefix directory ($PREFIX )"
216+ info " -h, --help show command line options"
245217 info " "
246218}
247219
248220main_start () {
249221 detect_osarch
222+ detect_git_tag
250223 process_options $@
251224 if [ " $MODE " = " help" ] ; then
252225 main_help
0 commit comments