Skip to content

Commit 6e8b032

Browse files
committed
add windows bundle script
1 parent 4e688d2 commit 6e8b032

3 files changed

Lines changed: 121 additions & 57 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ endif()
313313
if(MI_DEBUG AND !MI_GUARDED)
314314
message(STATUS "Enable MI_GUARDED (since MI_DEBUG=ON)")
315315
set(MI_GUARDED=ON)
316-
endif()
316+
endif()
317317
if(MI_GUARDED)
318318
message(STATUS "Compile guard pages behind certain object allocations (MI_GUARDED=ON)")
319319
list(APPEND mi_defines MI_GUARDED=1)
@@ -608,7 +608,7 @@ if(MI_BUILD_SHARED)
608608
# On windows, the import library name for the dll would clash with the static mimalloc.lib library
609609
# so we postfix the dll import library with `.dll.lib` (and also the .pdb debug file)
610610
set_property(TARGET mimalloc PROPERTY ARCHIVE_OUTPUT_NAME "${mi_libname}.dll" )
611-
install(FILES "$<TARGET_FILE_DIR:mimalloc>/${mi_libname}.dll.lib" DESTINATION ${CMAKE_INSTALL_LIBDIR})
611+
install(FILES "$<TARGET_FILE_DIR:mimalloc>/${mi_libname}.dll.lib" DESTINATION ${CMAKE_INSTALL_LIBDIR}/mimalloc-${mi_version})
612612
set_property(TARGET mimalloc PROPERTY PDB_NAME "${mi_libname}.dll")
613613
# don't try to install the pdb since it may not be generated depending on the configuration
614614
# install(FILES "$<TARGET_FILE_DIR:mimalloc>/${mi_libname}.dll.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR})

bin/bundle.bat

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
@echo off
2+
rem ------------------------------------------------------------------
3+
rem Build a binary release
4+
rem ------------------------------------------------------------------
5+
setlocal
6+
7+
mkdir "out/bundle"
8+
mkdir "out/bundle/prefix-x64"
9+
mkdir "out/bundle/prefix-x86"
10+
11+
set MI_TAG=
12+
for /F "tokens=*" %%x in ('git describe --tag 2^> nul') do (set MI_TAG=%%x)
13+
set MI_COMMIT=
14+
for /F "tokens=*" %%x in ('git rev-parse HEAD 2^> nul') do (set MI_COMMIT=%%x)
15+
16+
echo Tag : %MI_TAG%
17+
echo Commit: %MI_COMMIT%
18+
19+
rem (not needed as it is already done on other platforms)
20+
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"
21+
22+
rem Generate x64
23+
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
30+
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
37+
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
44+
45+
echo.
46+
echo Archive: x64
47+
cd "out/bundle/prefix-x64"
48+
tar -czvf "../mimalloc-%MI_TAG%-windows-x64.tar.gz" .
49+
cd ../../..
50+
51+
52+
rem Now generate x86
53+
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
67+
68+
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+
75+
echo.
76+
echo Archive: x86
77+
cd "out/bundle/prefix-x86"
78+
tar -czvf "../mimalloc-%MI_TAG%-windows-x86.tar.gz" .
79+
cd ../../..
80+
81+
echo.
82+
echo Done

bin/bundle.sh

Lines changed: 37 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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

4662
contains() {
@@ -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

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

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

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

255237
main_help() {
256238
info "command:"

0 commit comments

Comments
 (0)