From c945293b3ecaaaab03a5441e64f24a4c4686eeb6 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 6 May 2025 12:42:23 +0100 Subject: [PATCH] Add sanity checking strict mode to build scripts --- util/buildscripts/build.sh | 22 +++++++ util/buildscripts/scripts/compile_linux.sh | 28 +++++++- util/buildscripts/scripts/compile_win32.sh | 66 ++++++++++++++++--- .../scripts/make_package_linux.sh | 32 +++++++++ .../scripts/make_package_win32.sh | 37 ++++++++++- 5 files changed, 174 insertions(+), 11 deletions(-) diff --git a/util/buildscripts/build.sh b/util/buildscripts/build.sh index 9363e25f6..698f7feba 100755 --- a/util/buildscripts/build.sh +++ b/util/buildscripts/build.sh @@ -142,6 +142,7 @@ TYPE="" SNAPNAME="" SYMSTORE="" SKIPCOMPILE="" +STRICT="" LLVM_ARM32=$(realpath $(dirname $0)/support/llvm_arm32) LLVM_ARM64=$(realpath $(dirname $0)/support/llvm_arm64) @@ -166,6 +167,8 @@ usage() { echo " --llvm_arm32 Give the path to an ARM32 build of LLVM, for android."; echo " --llvm_arm64 Give the path to an ARM64 build of LLVM, for android."; echo " --skipcompile Skip compile steps, package already compiled binaries."; + echo " --strict Require all build steps to complete successfully,"; + echo " including optional steps e.g. android/installer."; } while [[ $# -gt 0 ]]; do @@ -205,6 +208,11 @@ while [[ $# -gt 0 ]]; do shift ;; + --strict) + STRICT="yes" + shift + ;; + -h|-?|-help|--help) usage; exit 0; @@ -233,6 +241,8 @@ if [[ "$TYPE" == "snapshot" ]] && [[ "$SNAPNAME" == "" ]]; then exit 1; fi +export STRICT; + echo "Building $TYPE"; if [[ "$SYMSTORE" != "" ]]; then @@ -319,10 +329,18 @@ if [[ "$PLATFORM" == "Windows" ]]; then ./scripts/sign_files.sh + if [ $? -ne 0 ]; then + exit 1; + fi + cd "${BUILD_ROOT}" ./scripts/prepare_symbols.sh + if [ $? -ne 0 ]; then + exit 1; + fi + fi cd "${BUILD_ROOT}" @@ -339,3 +357,7 @@ fi ./scripts/make_package.sh "${FILENAME}" +if [ $? -ne 0 ]; then + rm -rf "${REPO_ROOT}"/package/ + exit 1; +fi diff --git a/util/buildscripts/scripts/compile_linux.sh b/util/buildscripts/scripts/compile_linux.sh index ee799220f..54672778d 100755 --- a/util/buildscripts/scripts/compile_linux.sh +++ b/util/buildscripts/scripts/compile_linux.sh @@ -47,7 +47,11 @@ popd; # docs # if we didn't produce an html file, bail out even if sphinx didn't return an error code above if [ ! -f ./Documentation/html/index.html ]; then echo "Didn't get successful build of html docs." - exit 1; + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Fail to build html documentation."; + exit 1; + fi fi # Build android libraries and apks @@ -56,11 +60,21 @@ export PATH=$PATH:$ANDROID_SDK/tools/ # Check that we're set up to build for android if [ ! -d $ANDROID_SDK/tools ] ; then echo "\$ANDROID_SDK is not correctly configured: '$ANDROID_SDK'" + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Fail to build Android."; + exit 1; + fi exit 0; fi if [ ! -d $LLVM_ARM32 ] || [ ! -d $LLVM_ARM64 ] ; then echo "llvm is not available, expected $LLVM_ARM32 and $LLVM_ARM64 respectively." + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Fail to build Android."; + exit 1; + fi exit 0; fi @@ -86,6 +100,12 @@ else if ! ls bin/*.apk; then echo "Android build failed" + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Fail to build Android."; + exit 1; + fi + exit 0; fi @@ -108,6 +128,12 @@ else if ! ls bin/*.apk; then echo "Android build failed" + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Fail to build Android."; + exit 1; + fi + exit 0; fi diff --git a/util/buildscripts/scripts/compile_win32.sh b/util/buildscripts/scripts/compile_win32.sh index 0f416cb84..5444d3496 100755 --- a/util/buildscripts/scripts/compile_win32.sh +++ b/util/buildscripts/scripts/compile_win32.sh @@ -8,9 +8,19 @@ pushd "${REPO_ROOT}" # Build 32-bit Release MSYS2_ARG_CONV_EXCL="*" msbuild.exe /nologo /m /fl4 /flp4':Verbosity=minimal;Encoding=ASCII;logfile=dist/build32.log' renderdoc.sln /t:Rebuild /p:'Configuration=Release;Platform=x86' +if [ ! -f ./Win32/Release/renderdoc.dll ] || [ ! -f ./Win32/Release/qrenderdoc.exe ] || [ ! -f ./Win32/Release/renderdoccmd.exe ] ; then + echo "Failed to build 32-bit release mode."; + exit 1; +fi + # Build 64-bit Release MSYS2_ARG_CONV_EXCL="*" msbuild.exe /nologo /m /fl4 /flp4':Verbosity=minimal;Encoding=ASCII;logfile=dist/build64.log' renderdoc.sln /t:Rebuild /p:'Configuration=Release;Platform=x64' +if [ ! -f ./x64/Release/renderdoc.dll ] || [ ! -f ./x64/Release/qrenderdoc.exe ] || [ ! -f ./x64/Release/renderdoccmd.exe ] ; then + echo "Failed to build 64-bit release mode."; + exit 1; +fi + # Step into the docs folder and build pushd docs ./make.sh clean @@ -21,24 +31,28 @@ popd; # docs # if we didn't produce a chm file, bail out even if sphinx didn't return an error code above if [ ! -f ./Documentation/htmlhelp/renderdoc.chm ]; then echo "Didn't auto-build chm file. Missing HTML Help Workshop?" - exit 1; + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Fail to build CHM help file."; + exit 1; + fi fi # Transform ANDROID_SDK / ANDROID_NDK to native paths if needed if echo "${ANDROID_SDK}" | grep -q :; then - NATIVE_ANDROID_SDK_PATH=$(echo "${ANDROID_SDK}" | sed -e '{s#^\(.\):[/\]#\1/#g}' | tr '\\' '/') - # Add on wherever windows drives are - ANDROID_SDK="${WIN_ROOT}${NATIVE_ANDROID_SDK_PATH}" + NATIVE_ANDROID_SDK_PATH=$(echo "${ANDROID_SDK}" | sed -e '{s#^\(.\):[/\]#\1/#g}' | tr '\\' '/') + # Add on wherever windows drives are + ANDROID_SDK="${WIN_ROOT}${NATIVE_ANDROID_SDK_PATH}" - export ANDROID_SDK + export ANDROID_SDK fi if echo "${ANDROID_NDK}" | grep -q :; then - NATIVE_ANDROID_NDK_PATH=$(echo "${ANDROID_NDK}" | sed -e '{s#^\(.\):[/\]#\1/#g}' | tr '\\' '/') - # Add on wherever windows drives are - ANDROID_NDK="${WIN_ROOT}${NATIVE_ANDROID_NDK_PATH}" + NATIVE_ANDROID_NDK_PATH=$(echo "${ANDROID_NDK}" | sed -e '{s#^\(.\):[/\]#\1/#g}' | tr '\\' '/') + # Add on wherever windows drives are + ANDROID_NDK="${WIN_ROOT}${NATIVE_ANDROID_NDK_PATH}" - export ANDROID_NDK + export ANDROID_NDK fi export PATH=$PATH:"${ANDROID_SDK}/tools" @@ -46,22 +60,46 @@ export PATH=$PATH:"${ANDROID_SDK}/tools" # Check that we're set up to build for android if [ ! -d "${ANDROID_SDK}"/tools ] ; then echo "\$ANDROID_SDK is not correctly configured: '$ANDROID_SDK'" + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Fail to build Android."; + exit 1; + fi + # Don't return an error code, consider android errors non-fatal exit 0; fi if ! which cmake > /dev/null 2>&1; then echo "Don't have cmake, can't build android"; + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Fail to build Android."; + exit 1; + fi + exit 0; fi if ! which make > /dev/null 2>&1; then echo "Don't have make, can't build android"; + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Fail to build Android."; + exit 1; + fi + exit 0; fi if [ ! -d $LLVM_ARM32 ] || [ ! -d $LLVM_ARM64 ] ; then echo "llvm is not available, expected $LLVM_ARM32 and $LLVM_ARM64 respectively." + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Fail to build Android."; + exit 1; + fi + # Don't return an error code, consider android errors non-fatal exit 0; fi @@ -94,6 +132,11 @@ else if ! ls bin/*.apk; then echo "Android build failed" + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Fail to build Android."; + exit 1; + fi fi popd # build-android-arm32 @@ -115,6 +158,11 @@ else if ! ls bin/*.apk; then echo "Android build failed" + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Fail to build Android."; + exit 1; + fi fi popd # build-android-arm64 diff --git a/util/buildscripts/scripts/make_package_linux.sh b/util/buildscripts/scripts/make_package_linux.sh index 2da260b60..0e583ce85 100755 --- a/util/buildscripts/scripts/make_package_linux.sh +++ b/util/buildscripts/scripts/make_package_linux.sh @@ -31,6 +31,14 @@ if [ -d "${REPO_ROOT}"/Documentation/html ]; then cp -R "${REPO_ROOT}"/Documentation/html "./${FILENAME}/share/doc/renderdoc/html" else echo "WARNING: Documentation not built! run 'make html' in docs folder"; + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Failed to locate documentation."; + + popd + rm -rf "${REPO_ROOT}"/package + exit 1; + fi fi # copy in plugins @@ -39,6 +47,14 @@ if [ -d "${REPO_ROOT}"/plugins-linux64 ]; then chmod +x -R "./${FILENAME}/share/renderdoc/plugins"/* else echo "WARNING: Plugins not present. Download and extract https://renderdoc.org/plugins.tgz in root folder"; + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Failed to locate plugins."; + + popd + rm -rf "${REPO_ROOT}"/package + exit 1; + fi fi # copy in all of the android files. @@ -48,12 +64,28 @@ if ls "${REPO_ROOT}"/build-android*/bin/*.apk; then cp "${REPO_ROOT}"/build-android*/bin/*.apk "./${FILENAME}/share/renderdoc/plugins/android/" else echo "WARNING: Android build not present. Build arm32 and arm64 apks in build-android-arm{32,64} folders"; + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Failed to locate Android."; + + popd + rm -rf "${REPO_ROOT}"/package + exit 1; + fi fi # compress the folder and GPG sign it tar -zcf ${FILENAME}.tar.gz "./${FILENAME}/"* --xform 's#^./##g' gpg -o ${FILENAME}.tar.gz.sig --detach-sign --armor ${FILENAME}.tar.gz +if [[ "$STRICT" == "yes" ]] && [ ! -f ${FILENAME}.tar.gz.sig ]; then + echo "Strict mode: Failed to sign tarball."; + + popd + rm -rf "${REPO_ROOT}"/package + exit 1; +fi + rm -rf "./${FILENAME}" popd # $REPO_ROOT/package diff --git a/util/buildscripts/scripts/make_package_win32.sh b/util/buildscripts/scripts/make_package_win32.sh index 52d995ac7..7429074e8 100755 --- a/util/buildscripts/scripts/make_package_win32.sh +++ b/util/buildscripts/scripts/make_package_win32.sh @@ -12,6 +12,8 @@ if [ ! -d "${REPO_ROOT}"/x64/Release ] || [ ! -d "${REPO_ROOT}"/Win32/Release ]; exit 1; fi +rm -rf "${REPO_ROOT}"/package + pushd "${REPO_ROOT}" # clean any old files lying around and make new structure @@ -47,12 +49,22 @@ if [ -d plugins-win64 ]; then cp -R plugins-win64/ dist/Release64/plugins else echo "WARNING: x64 plugins missing, download and extract https://renderdoc.org/plugins.zip in root"; + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Failed to locate plugins."; + exit 1; + fi fi; if [ -d plugins-win32 ]; then cp -R plugins-win32/ dist/Release32/plugins else echo "WARNING: x86 plugins missing, download and extract https://renderdoc.org/plugins.zip in root"; + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Failed to locate plugins."; + exit 1; + fi fi # Delete new VS2015 incremental pdb files, these are just build artifacts @@ -66,6 +78,11 @@ if ls build-android-* > /dev/null; then find build-android-* -iname 'org.renderdoc.renderdoccmd.*.apk' -exec cp '{}' dist/Release64/plugins/android ';' else echo "WARNING: No android builds found, expected build-android-arm32 and build-android-arm64"; + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Failed to locate Android build."; + exit 1; + fi fi # Copy in android adb and patching requirements @@ -76,6 +93,11 @@ else echo " These files must be in plugins-android/ in the root and"; echo " MUST be built locally from an AOSP checkout, not from a"; echo " distributed android SDK due to licensing concerns."; + + if [[ "$STRICT" == "yes" ]]; then + echo "Strict mode: Failed to locate Android support files."; + exit 1; + fi fi if [ -d dist/Release64/plugins/android ]; then @@ -111,14 +133,27 @@ export WSLENV=$WSLENV:RENDERDOC_VERSION "$WIX/bin/candle.exe" -o dist/Installer32.wixobj util/installer/Installer32.wxs "$WIX/bin/light.exe" -ext WixUIExtension -sw1076 -loc util/installer/customtext.wxl -o dist/Installer32.msi dist/Installer32.wixobj +if [[ "$STRICT" == "yes" ]]; then + if [ ! -f "${REPO_ROOT}"/dist/Installer32.msi ] ; then + echo "Failed to build 32-bit installer."; + exit 1; + fi +fi + "$WIX/bin/candle.exe" -o dist/Installer64.wixobj util/installer/Installer64.wxs "$WIX/bin/light.exe" -ext WixUIExtension -sw1076 -loc util/installer/customtext.wxl -o dist/Installer64.msi dist/Installer64.wixobj +if [[ "$STRICT" == "yes" ]]; then + if [ ! -f "${REPO_ROOT}"/dist/Installer64.msi ] ; then + echo "Failed to build 64-bit installer."; + exit 1; + fi +fi + rm -f dist/*.wixobj dist/*.wixpdb popd # $REPO_ROOT -rm -rf "${REPO_ROOT}"/package mkdir "${REPO_ROOT}"/package pushd "${REPO_ROOT}"/package