|
| 1 | +#!/bin/sh -e |
| 2 | + |
| 3 | +echo "Starting RPCS3 build (Bash script)" |
| 4 | + |
| 5 | +# Automatically find clang_rt.builtins-x86_64.lib |
| 6 | +echo "Searching for clang_rt.builtins-x86_64.lib ..." |
| 7 | +clangBuiltinsLibPath=$(find "C:\Program Files\LLVM\lib\clang" -name "clang_rt.builtins-x86_64.lib" | sed 's|Program Files|PROGRA~1|g') |
| 8 | + |
| 9 | +if [[ -z "$clangBuiltinsLibPath" ]]; then |
| 10 | + echo "ERROR: Could not find clang_rt.builtins-x86_64.lib in LLVM installation." |
| 11 | + exit 1 |
| 12 | +fi |
| 13 | + |
| 14 | +clangBuiltinsDir=$(dirname "$clangBuiltinsLibPath") |
| 15 | +clangBuiltinsLib=$(basename "$clangBuiltinsLibPath") |
| 16 | +clangPath=$(echo "C:\Program Files\LLVM\bin" | sed 's|Program Files|PROGRA~1|g') |
| 17 | + |
| 18 | +echo "Found Clang builtins library: $clangBuiltinsLib in $clangBuiltinsDir" |
| 19 | +echo "Found Clang Path: $clangPath" |
| 20 | + |
| 21 | +# Search for mt.exe in SDK bin directories |
| 22 | +echo "Searching for llvm-mt.exe ..." |
| 23 | +mtPath=$(find "$clangPath" -name "llvm-mt.exe") |
| 24 | + |
| 25 | +if [[ -z "$mtPath" ]]; then |
| 26 | + echo "ERROR: Could not find llvm-mt.exe in SDK directories." |
| 27 | + exit 1 |
| 28 | +fi |
| 29 | + |
| 30 | +echo "Found llvm-mt.exe at: $mtPath" |
| 31 | + |
| 32 | +VcpkgRoot="$(pwd)/vcpkg" |
| 33 | +VcpkgTriplet="$VCPKG_TRIPLET" |
| 34 | +VcpkgInstall="$VcpkgRoot/installed/$VcpkgTriplet" |
| 35 | +VcpkgInclude="$VcpkgInstall/include" |
| 36 | +VcpkgLib="$VcpkgInstall/lib" |
| 37 | +VcpkgBin="$VcpkgInstall/bin" |
| 38 | + |
| 39 | +# Configure git safe directory |
| 40 | +echo "Configuring git safe directory" |
| 41 | +git config --global --add safe.directory '*' |
| 42 | + |
| 43 | +# Initialize submodules except certain ones |
| 44 | +echo "Initializing submodules" |
| 45 | +excludedSubs=("llvm" "opencv" "ffmpeg" "FAudio" "zlib" "libpng" "feralinteractive") |
| 46 | + |
| 47 | +# Get submodule paths excluding those in excludedSubs |
| 48 | +readarray -t submodules < <(grep 'path = ' .gitmodules | sed 's/path = //' | grep -v -E "$(IFS=\|; echo "${excludedSubs[*]}")") |
| 49 | + |
| 50 | +echo "Updating submodules: ${submodules[*]}" |
| 51 | +git submodule update --init --quiet ${submodules[@]} |
| 52 | + |
| 53 | +# Create and enter build directory |
| 54 | +echo "Creating build directory" |
| 55 | +mkdir -p build |
| 56 | +cd build || exit |
| 57 | +echo "Changed directory to: $(pwd)" |
| 58 | + |
| 59 | +# Run CMake with Ninja generator and required flags |
| 60 | +echo "Running CMake configuration" |
| 61 | +cmake .. \ |
| 62 | + -G Ninja \ |
| 63 | + -DCMAKE_BUILD_TYPE=Release \ |
| 64 | + -DCMAKE_C_COMPILER="${clangPath}/clang-cl.exe" \ |
| 65 | + -DCMAKE_CXX_COMPILER="${clangPath}/clang-cl.exe" \ |
| 66 | + -DCMAKE_LINKER="${clangPath}/lld-link.exe" \ |
| 67 | + -DCMAKE_INSTALL_PREFIX=/usr \ |
| 68 | + -DCMAKE_TOOLCHAIN_FILE="$VcpkgRoot/scripts/buildsystems/vcpkg.cmake" \ |
| 69 | + -DCMAKE_EXE_LINKER_FLAGS="/LIBPATH:${clangBuiltinsDir} /defaultlib:${clangBuiltinsLib}" \ |
| 70 | + -DCMAKE_MT="${mtPath}" \ |
| 71 | + -DUSE_NATIVE_INSTRUCTIONS=OFF \ |
| 72 | + -DUSE_PRECOMPILED_HEADERS=OFF \ |
| 73 | + -DVCPKG_TARGET_TRIPLET="$VcpkgTriplet" \ |
| 74 | + -DFFMPEG_INCLUDE_DIR="$VcpkgInclude" \ |
| 75 | + -DFFMPEG_LIBAVCODEC="$VcpkgLib/avcodec.lib" \ |
| 76 | + -DFFMPEG_LIBAVFORMAT="$VcpkgLib/avformat.lib" \ |
| 77 | + -DFFMPEG_LIBAVUTIL="$VcpkgLib/avutil.lib" \ |
| 78 | + -DFFMPEG_LIBSWSCALE="$VcpkgLib/swscale.lib" \ |
| 79 | + -DFFMPEG_LIBSWRESAMPLE="$VcpkgLib/swresample.lib" \ |
| 80 | + -DUSE_SYSTEM_CURL=OFF \ |
| 81 | + -DUSE_FAUDIO=OFF \ |
| 82 | + -DUSE_SDL=ON \ |
| 83 | + -DUSE_SYSTEM_SDL=OFF \ |
| 84 | + -DUSE_SYSTEM_FFMPEG=ON \ |
| 85 | + -DUSE_SYSTEM_OPENCV=ON \ |
| 86 | + -DUSE_SYSTEM_OPENAL=OFF \ |
| 87 | + -DUSE_SYSTEM_LIBPNG=ON \ |
| 88 | + -DUSE_DISCORD_RPC=ON \ |
| 89 | + -DUSE_SYSTEM_ZSTD=ON \ |
| 90 | + -DWITH_LLVM=ON \ |
| 91 | + -DSTATIC_LINK_LLVM=ON \ |
| 92 | + -DBUILD_RPCS3_TESTS=OFF |
| 93 | + |
| 94 | +echo "CMake configuration complete" |
| 95 | + |
| 96 | +# Build with ninja |
| 97 | +echo "Starting build with Ninja..." |
| 98 | +ninja |
| 99 | + |
| 100 | +if [[ $? -ne 0 ]]; then |
| 101 | + echo "Build failed with exit code $?" |
| 102 | + exit 1 |
| 103 | +fi |
| 104 | + |
| 105 | +echo "Build succeeded" |
| 106 | + |
| 107 | +# Go back to root directory |
| 108 | +cd .. |
| 109 | +echo "Returned to root directory: $(pwd)" |
0 commit comments