Skip to content

Commit

Permalink
build: script cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: He Xian <[email protected]>
  • Loading branch information
hexian000 committed Nov 21, 2024
1 parent 2c5d839 commit 631b54e
Showing 1 changed file with 53 additions and 51 deletions.
104 changes: 53 additions & 51 deletions m.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,63 +6,64 @@ set -ex
case "$1" in
"c")
# clean artifacts
rm -rf "build" "compile_commands.json"
rm -rf build compile_commands.json
;;
"x")
# cross compiling, environment vars need to be set
rm -rf "build" && mkdir -p "build"
rm -rf build && mkdir -p build && cd build
cmake \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_SYSROOT="${SYSROOT}" \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-DCMAKE_SKIP_RPATH=ON \
-S . -B "build"
cmake --build "build"
ls -lh "build/bin/neosocksd"
..
cmake --build .
ls -lh bin/neosocksd
;;
"posix")
# rebuild for strict POSIX compliance
rm -rf "build" && mkdir -p "build"
rm -rf build && mkdir -p build && cd build
cmake \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_BUILD_TYPE="Release" \
-DFORCE_POSIX=ON \
-S . -B "build"
cp build/compile_commands.json compile_commands.json
cmake --build "build"
ls -lh "build/bin/neosocksd"
..
cp compile_commands.json ../
cmake --build .
ls -lh bin/neosocksd
;;
"clang")
# rebuild with Linux clang/lld
rm -rf "build" && mkdir -p "build"
rm -rf build && mkdir -p build && cd build
cmake \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DCMAKE_C_COMPILER="clang" \
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld --rtlib=compiler-rt" \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-S . -B "build"
cmake --build "build"
(cd "build/bin" && llvm-objdump -drwS "neosocksd" >"neosocksd.S")
ls -lh "build/bin/neosocksd"
..
cmake --build .
(cd bin && llvm-objdump -drwS neosocksd >neosocksd.S)
ls -lh bin/neosocksd
;;
"msys2")
# rebuild with MSYS 2
rm -rf "build" && mkdir "build"
rm -rf build && mkdir -p build && cd build
cmake \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_EXE_LINKER_FLAGS="-static-libgcc" \
-S "." -B "build"
cmake --build "build"
-DENABLE_SANITIZERS=OFF \
..
cmake --build .
HOST="$(cc -dumpmachine)"
zip -9j "build/neosocksd-win32.${HOST}.zip" \
zip -9j "neosocksd-win32.${HOST}.zip" \
"/usr/bin/msys-2.0.dll" \
"/usr/bin/msys-cares-2.dll" \
"build/bin/neosocksd.exe"
ls -lh "build/neosocksd-win32.${HOST}.zip"
"bin/neosocksd.exe"
ls -lh "neosocksd-win32.${HOST}.zip"
;;
"ndk")
# rebuild with Android NDK
rm -rf "build" && mkdir "build"
rm -rf build && mkdir -p build && cd build
cmake \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_SYSTEM_NAME="Android" \
Expand All @@ -72,71 +73,72 @@ case "$1" in
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-DENABLE_MIMALLOC=ON \
-DLINK_STATIC_LIBS=ON \
-S "." -B "build"
cmake --build "build"
ls -lh "build/bin/neosocksd"
..
cmake --build .
ls -lh bin/neosocksd
;;
"san")
# rebuild with clang & sanitizers
rm -rf "build" && mkdir -p "build"
rm -rf build && mkdir -p build && cd build
cmake \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_BUILD_TYPE="Debug" \
-DCMAKE_C_COMPILER="clang" \
-DENABLE_SANITIZERS=ON \
-S . -B "build"
cp build/compile_commands.json compile_commands.json
cmake --build "build"
ls -lh "build/bin/neosocksd"
..
cp compile_commands.json ../
cmake --build .
ls -lh bin/neosocksd
;;
"min")
# rebuild for minimized size
rm -rf "build" && mkdir "build"
rm -rf build && mkdir -p build && cd build
cmake \
-DCMAKE_BUILD_TYPE="MinSizeRel" \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-S "." -B "build"
cmake --build "build"
ls -lh "build/bin/neosocksd"
..
cmake --build .
ls -lh bin/neosocksd
;;
"p")
# rebuild for profiling
rm -rf "build" && mkdir -p "build"
rm -rf build && mkdir -p build && cd build
cmake \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-S . -B "build"
cmake --build "build"
(cd "build/bin" && objdump -drwS "neosocksd" >"neosocksd.S")
ls -lh "build/bin/neosocksd"
..
cmake --build .
(cd bin && objdump -drwS neosocksd >neosocksd.S)
ls -lh bin/neosocksd
;;
"r")
# rebuild for release
rm -rf "build" && mkdir -p "build"
rm -rf build && mkdir -p build && cd build
cmake \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_BUILD_TYPE="Release" \
-S . -B "build"
cp build/compile_commands.json compile_commands.json
cmake --build "build"
ls -lh "build/bin/neosocksd"
..
cp compile_commands.json ../
cmake --build .
ls -lh bin/neosocksd
;;
"d")
# rebuild for debug
if command -v clang-format >/dev/null; then
find src -type f -regex '.*\.[hc]' -exec clang-format -i {} +
fi
rm -rf "build" && mkdir -p "build"
rm -rf build && mkdir -p build && cd build
cmake \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_BUILD_TYPE="Debug" \
-S . -B "build"
cp build/compile_commands.json compile_commands.json
cmake --build "build"
ls -lh "build/bin/neosocksd"
..
cp compile_commands.json ../
cmake --build .
ls -lh bin/neosocksd
;;
*)
cmake --build "build"
ls -lh "build/bin/neosocksd"
cd build
cmake --build .
ls -lh bin/neosocksd
;;
esac

0 comments on commit 631b54e

Please sign in to comment.