add astyle to windows llvm build script (#411)

This commit is contained in:
Cyano Hao 2024-05-04 10:14:08 +08:00 committed by GitHub
parent 4bd3829484
commit ae8e8fdaa6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 24 additions and 1 deletions

View File

@ -64,6 +64,7 @@ esac
REDPANDA_LLVM_VERSION="18-r0" REDPANDA_LLVM_VERSION="18-r0"
WINDOWS_TERMINAL_VERSION="1.19.10821.0" WINDOWS_TERMINAL_VERSION="1.19.10821.0"
ASTYLE_VERSION_TAG="3.4.14"
_QMAKE="$MINGW_PREFIX/qt5-static/bin/qmake" _QMAKE="$MINGW_PREFIX/qt5-static/bin/qmake"
_NSIS="/mingw32/bin/makensis" _NSIS="/mingw32/bin/makensis"
@ -82,6 +83,7 @@ _WINDOWS_TERMINAL_URL="https://github.com/microsoft/terminal/releases/download/v
_SRCDIR="$PWD" _SRCDIR="$PWD"
_ASSETSDIR="$PWD/assets" _ASSETSDIR="$PWD/assets"
_BUILDDIR="$TEMP/redpanda-llvm-$MSYSTEM-build" _BUILDDIR="$TEMP/redpanda-llvm-$MSYSTEM-build"
_ASTYLE_BUILD_DIR="${_BUILDDIR}/astyle"
_PKGDIR="$TEMP/redpanda-llvm-$MSYSTEM-pkg" _PKGDIR="$TEMP/redpanda-llvm-$MSYSTEM-pkg"
_DISTDIR="$PWD/dist" _DISTDIR="$PWD/dist"
@ -137,12 +139,20 @@ function prepare-dirs() {
[[ -d "$_BUILDDIR" ]] && rm -rf "$_BUILDDIR" [[ -d "$_BUILDDIR" ]] && rm -rf "$_BUILDDIR"
[[ -d "$_PKGDIR" ]] && rm -rf "$_PKGDIR" [[ -d "$_PKGDIR" ]] && rm -rf "$_PKGDIR"
fi fi
mkdir -p "$_ASSETSDIR" "$_BUILDDIR" "$_PKGDIR" "$_DISTDIR" mkdir -p "$_ASSETSDIR" "$_BUILDDIR" "$_ASTYLE_BUILD_DIR" "$_PKGDIR" "$_DISTDIR"
} }
function download-assets() { function download-assets() {
[[ -f "$_ASSETSDIR/$_LLVM_ARCHIVE" ]] || curl -L -o "$_ASSETSDIR/$_LLVM_ARCHIVE" "$_LLVM_URL" [[ -f "$_ASSETSDIR/$_LLVM_ARCHIVE" ]] || curl -L -o "$_ASSETSDIR/$_LLVM_ARCHIVE" "$_LLVM_URL"
[[ -f "$_ASSETSDIR/$_WINDOWS_TERMINAL_ARCHIVE" ]] || curl -L -o "$_ASSETSDIR/$_WINDOWS_TERMINAL_ARCHIVE" "$_WINDOWS_TERMINAL_URL" [[ -f "$_ASSETSDIR/$_WINDOWS_TERMINAL_ARCHIVE" ]] || curl -L -o "$_ASSETSDIR/$_WINDOWS_TERMINAL_ARCHIVE" "$_WINDOWS_TERMINAL_URL"
if [[ ! -d "$_ASSETSDIR/astyle" ]]; then
git clone --bare "https://gitlab.com/saalen/astyle" "$_ASSETSDIR/astyle"
fi
pushd "$_ASSETSDIR/astyle"
if [[ -z "$(git tag -l "$ASTYLE_VERSION_TAG")" ]]; then
git fetch --all --tags
fi
} }
function prepare-openconsole() { function prepare-openconsole() {
@ -161,6 +171,18 @@ function restore-src() {
mv "$_SRCDIR"/RedPandaIDE/RedPandaIDE.pro{.bak,} mv "$_SRCDIR"/RedPandaIDE/RedPandaIDE.pro{.bak,}
} }
function build-astyle() {
pushd "$_ASSETSDIR/astyle"
git --work-tree="${_ASTYLE_BUILD_DIR}" checkout -f "$ASTYLE_VERSION_TAG"
popd
pushd "$_ASTYLE_BUILD_DIR"
cmake . -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXE_LINKER_FLAGS="-static"
mingw32-make -j$(nproc)
cp AStyle/AStyle.exe "$_PKGDIR/astyle.exe"
popd
}
function build() { function build() {
pushd "$_BUILDDIR" pushd "$_BUILDDIR"
"$_QMAKE" PREFIX="$_PKGDIR" "$_SRCDIR" "$_QMAKE" PREFIX="$_PKGDIR" "$_SRCDIR"
@ -200,6 +222,7 @@ prepare-dirs
download-assets download-assets
prepare-openconsole prepare-openconsole
prepare-src prepare-src
build-astyle
trap restore-src EXIT INT TERM trap restore-src EXIT INT TERM
build build
package package