Skip to content

Commit 388fde8

Browse files
committed
update bundle scripts
1 parent 6e8b032 commit 388fde8

2 files changed

Lines changed: 63 additions & 98 deletions

File tree

bin/bundle.bat

Lines changed: 44 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,78 +5,70 @@ rem ------------------------------------------------------------------
55
setlocal
66

77
mkdir "out/bundle"
8-
mkdir "out/bundle/prefix-x64"
9-
mkdir "out/bundle/prefix-x86"
108

119
set MI_TAG=
1210
for /F "tokens=*" %%x in ('git describe --tag 2^> nul') do (set MI_TAG=%%x)
1311
set MI_COMMIT=
1412
for /F "tokens=*" %%x in ('git rev-parse HEAD 2^> nul') do (set MI_COMMIT=%%x)
1513

14+
echo.
1615
echo Tag : %MI_TAG%
1716
echo Commit: %MI_COMMIT%
1817

1918
rem (not needed as it is already done on other platforms)
2019
rem curl --proto =https --tlsv1.2 -f -L -o "https://github.com/microsoft/mimalloc/archive/%MI_COMMIT%.tar.gz" "out/bundle/mimalloc-%MI_TAG%-source.tar.gz"
2120

22-
rem Generate x64
21+
call:bundle x64 debug Debug "-A x64 -T ClangCl" || goto :err
22+
call:bundle x64 release Release "-A x64 -T ClangCl -DMI_OPT_ARCH=ON" || goto :err
23+
call:bundle x64 secure Release "-A x64 -T ClangCl -DMI_OPT_ARCH=ON -DMI_SECURE=ON" || goto:err
24+
call:archive x64 || goto:err
2325

24-
echo.
25-
echo Build: debug x64
26-
cmake . -B "out/bundle/debug-x64" -A x64 -T ClangCl -DCMAKE_BUILD_TYPE=Debug
27-
cmake --build "out/bundle/debug-x64" --config Debug
28-
ctest --test-dir "out/bundle/debug-x64" -C Debug
29-
cmake --install "out/bundle/debug-x64" --prefix "out/bundle/prefix-x64" --config Debug
26+
call:bundle x86 debug Debug "-A Win32 -T ClangCl" || goto :err
27+
call:bundle x86 release Release "-A Win32 -T ClangCl -DMI_OPT_ARCH=ON" || goto :err
28+
call:bundle x86 secure Release "-A Win32 -T ClangCl -DMI_OPT_ARCH=ON -DMI_SECURE=ON" || goto:err
29+
call:archive x86 || goto:err
3030

31-
echo.
32-
echo Build: release x64
33-
cmake . -B "out/bundle/release-x64" -A x64 -T ClangCl -DCMAKE_BUILD_TYPE=Release -DMI_OPT_ARCH=ON
34-
cmake --build "out/bundle/release-x64" --config Release
35-
ctest --test-dir "out/bundle/release-x64" -C Release
36-
cmake --install "out/bundle/release-x64" --prefix "out/bundle/prefix-x64" --config Release
31+
call:bundle arm64 debug Debug "-A ARM64 -T ClangCl" || goto :err
32+
call:bundle arm64 release Release "-A ARM64 -T ClangCl -DMI_OPT_ARCH=ON" || goto :err
33+
call:bundle arm64 secure Release "-A ARM64 -T ClangCl -DMI_OPT_ARCH=ON -DMI_SECURE=ON" || goto:err
34+
call:archive arm64 || goto:err
3735

38-
echo.
39-
echo Build: secure x64
40-
cmake . -B "out/bundle/secure-x64" -A x64 -T ClangCl -DCMAKE_BUILD_TYPE=Release -DMI_OPT_ARCH=ON -DMI_SECURE=ON
41-
cmake --build "out/bundle/secure-x64" --config Release
42-
ctest --test-dir "out/bundle/secure-x64" -C Release
43-
cmake --install "out/bundle/secure-x64" --prefix "out/bundle/prefix-x64" --config Release
36+
call:bundle arm64ec debug Debug "-A Arm64EC" || goto :err
37+
call:bundle arm64ec release Release "-A Arm64EC -DMI_OPT_ARCH=ON" || goto :err
38+
call:bundle arm64ec secure Release "-A Arm64EC -DMI_OPT_ARCH=ON -DMI_SECURE=ON" || goto:err
39+
call:archive arm64ec || goto:err
4440

4541
echo.
46-
echo Archive: x64
47-
cd "out/bundle/prefix-x64"
48-
tar -czvf "../mimalloc-%MI_TAG%-windows-x64.tar.gz" .
49-
cd ../../..
50-
42+
echo Done
43+
exit /b 0
5144

52-
rem Now generate x86
45+
:err
46+
echo Failed with error: %errorlevel%
47+
exit /b %errorlevel%
5348

54-
echo.
55-
echo Build: debug x86
56-
cmake . -B "out/bundle/debug-x86" -A Win32 -T ClangCl -DCMAKE_BUILD_TYPE=Debug
57-
cmake --build "out/bundle/debug-x86" --config Debug
58-
ctest --test-dir "out/bundle/debug-x86" -C Debug
59-
cmake --install "out/bundle/debug-x86" --prefix "out/bundle/prefix-x86" --config Debug
60-
61-
echo.
62-
echo Build: release x86
63-
cmake . -B "out/bundle/release-x86" -A Win32 -T ClangCl -DCMAKE_BUILD_TYPE=Release -DMI_OPT_ARCH=ON
64-
cmake --build "out/bundle/release-x86" --config Release
65-
ctest --test-dir "out/bundle/release-x86" -C Release
66-
cmake --install "out/bundle/release-x86" --prefix "out/bundle/prefix-x86" --config Release
6749

50+
:bundle
51+
rem bundle: 1:arch 2:build-variant 3:build-type 4:cmake options
6852
echo.
69-
echo Build: secure x86
70-
cmake . -B "out/bundle/secure-x86" -A Win32 -T ClangCl -DCMAKE_BUILD_TYPE=Release -DMI_OPT_ARCH=ON -DMI_SECURE=ON
71-
cmake --build "out/bundle/secure-x86" --config Release
72-
ctest --test-dir "out/bundle/secure-x86" -C Release
73-
cmake --install "out/bundle/secure-x86" --prefix "out/bundle/prefix-x86" --config Release
74-
53+
echo Build: %~1 %~2: %~3
54+
mkdir "out/bundle/prefix-%~1"
55+
cmake . -B "out/bundle/%~2-%~1" -DCMAKE_BUILD_TYPE=%~3 %~4 || goto :err
56+
cmake --build "out/bundle/%~2-%~1" --config %~3 || goto :err
57+
if "%~1" == "x64" (ctest --test-dir "out/bundle/%~2-%~1" -C %~3 || goto :err)
58+
if "%~1" == "x86" (ctest --test-dir "out/bundle/%~2-%~1" -C %~3 || goto :err)
59+
cmake --install "out/bundle/%~2-%~1" --prefix "out/bundle/prefix-%~1" --config %~3 || goto :err
60+
exit /b %errorlevel%
61+
62+
63+
:archive
64+
rem archive: 1:arch
7565
echo.
76-
echo Archive: x86
77-
cd "out/bundle/prefix-x86"
78-
tar -czvf "../mimalloc-%MI_TAG%-windows-x86.tar.gz" .
66+
echo Archive: %~1
67+
if "%~1" == "x64" (xcopy /Y /F "bin/minject.exe" "out/bundle/prefix-%~1/bin")
68+
if "%~1" == "x86" (xcopy /Y /F "bin/minject32.exe" "out/bundle/prefix-%~1/bin")
69+
if "%~1" == "arm64" (xcopy /Y /F "bin/minject-arm64.exe" "out/bundle/prefix-%~1/bin")
70+
if "%~1" == "arm64ec" (xcopy /Y /F "bin/minject-arm64.exe" "out/bundle/prefix-%~1/bin")
71+
cd "out/bundle/prefix-%~1"
72+
tar -czvf "../mimalloc-%MI_TAG%-windows-%~1.tar.gz" .
7973
cd ../../..
80-
81-
echo.
82-
echo Done
74+
exit /b %errorlevel%

bin/bundle.sh

Lines changed: 19 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
# Bundle release
55
#-----------------------------------------------------------------------------
66

7-
QUIET=""
8-
FORCE=""
97
OSARCH=""
108
OSNAME=""
119
MI_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-
7056
detect_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

152121
download_failed() { # <program> <url>
153-
warn ""
154-
warn "unable to download: $2"
155-
stop ""
122+
stop "unable to download: $2"
156123
}
157124

158125
download_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

200166
main_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

248220
main_start() {
249221
detect_osarch
222+
detect_git_tag
250223
process_options $@
251224
if [ "$MODE" = "help" ] ; then
252225
main_help

0 commit comments

Comments
 (0)