mirror of
https://github.com/lobomfz/VIctory-xmem.git
synced 2026-12-06 05:48:38 +00:00
48 lines
2.2 KiB
Bash
Executable File
48 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
source "$(dirname "$(readlink -f "$0")")/env.sh"
|
|
sdk=$root/deps/msvc
|
|
source "$root/tools/sdk.sh"
|
|
if ! sdk_ready "$sdk"; then echo "missing or incomplete sdk: run $root/setup.sh sdk"; exit 1; fi
|
|
# cargo and cc split RUSTFLAGS/CFLAGS on whitespace, so a space in the checkout path breaks /winsysroot
|
|
if [[ "$sdk" == *[[:space:]]* ]]; then
|
|
link="${XDG_CACHE_HOME:-$HOME/.cache}/victory-msvc-$(printf %s "$sdk" | sha1sum | cut -c1-8)"
|
|
[[ "$link" == *[[:space:]]* ]] && { echo "path to sdk contains spaces and no space-free alias is possible: $sdk"; exit 1; }
|
|
mkdir -p "$(dirname "$link")"
|
|
ln -sfn "$sdk" "$link"
|
|
sdk=$link
|
|
fi
|
|
export CARGO_BUILD_TARGET=x86_64-pc-windows-msvc
|
|
export CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-$root/target}
|
|
export CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER=lld-link
|
|
export CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUNNER="${WINE_BIN:-wine}"
|
|
export WINESERVER="${WINESERVER:-${WINESERVER_BIN:-wineserver}}"
|
|
export WINEDLLOVERRIDES="${WINEDLLOVERRIDES:-mmdevapi=b;d3d12,d3d12core,dxgi=n;d3dcompiler_47=n,b;winemenubuilder.exe=d}"
|
|
export CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS="-C target-cpu=x86-64-v3 -Clink-arg=/winsysroot:$sdk"
|
|
export CC_x86_64_pc_windows_msvc=clang-cl CXX_x86_64_pc_windows_msvc=clang-cl AR_x86_64_pc_windows_msvc=llvm-lib
|
|
export CFLAGS_x86_64_pc_windows_msvc="--target=x86_64-pc-windows-msvc -Wno-unused-command-line-argument -fuse-ld=lld-link -winsysroot $sdk"
|
|
export CXXFLAGS_x86_64_pc_windows_msvc="$CFLAGS_x86_64_pc_windows_msvc"
|
|
ram=$(awk '/MemAvailable/{print int($2/1024)}' /proc/meminfo)
|
|
if [ "${PROFILE:-release}" = diag ]; then
|
|
profile_args=(--profile diag --features diagnostics)
|
|
else
|
|
profile_args=(--release)
|
|
fi
|
|
cargo_args=()
|
|
extra_args=()
|
|
while [ "$#" -gt 0 ]; do
|
|
if [ "$1" = -- ]; then
|
|
shift
|
|
extra_args=(-- "$@")
|
|
break
|
|
fi
|
|
cargo_args+=("$1")
|
|
shift
|
|
done
|
|
if [ "${#cargo_args[@]}" -eq 0 ]; then
|
|
cargo_args=(build)
|
|
fi
|
|
cd "$root"
|
|
exec systemd-run --user --scope --collect -q -p "MemoryHigh=${MEM_HIGH:-$((ram*2/5))M}" -p "MemoryMax=${MEM_MAX:-$((ram*9/20))M}" -p MemorySwapMax=4G -- \
|
|
nice -n 12 timeout -k 8s "${BUILD_TIMEOUT:-1800}s" cargo "${cargo_args[@]}" --locked "${profile_args[@]}" -j "${JOBS:-$(nproc)}" -p "${PKG:-victory}" ${extra_args[@]+"${extra_args[@]}"}
|