summaryrefslogtreecommitdiff
path: root/vendor/bionic-fg/build-linux-x86_64.sh
blob: 91a3b26808f5b0ffafa8ff65984af3b81da51230 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR="${BIONIC_FG_BUILD_DIR:-$ROOT_DIR/build/linux-x86_64}"
OUTPUT_DIR="${BIONIC_FG_OUTPUT_DIR:-$ROOT_DIR/dist/linux-x86_64}"

if [[ -f "$BUILD_DIR/CMakeCache.txt" ]]; then
    cached_source="$(sed -n 's/^CMAKE_HOME_DIRECTORY:INTERNAL=//p' "$BUILD_DIR/CMakeCache.txt")"
    if [[ "$cached_source" != "$ROOT_DIR" ]]; then
        rm -rf "$BUILD_DIR"
    fi
fi

cmake -S "$ROOT_DIR" -B "$BUILD_DIR" \
    -DCMAKE_BUILD_TYPE=Release
cmake --build "$BUILD_DIR" \
    --parallel "${CMAKE_BUILD_PARALLEL_LEVEL:-$(getconf _NPROCESSORS_ONLN 2>/dev/null || printf '2')}"

mkdir -p "$OUTPUT_DIR"
rm -f "$OUTPUT_DIR/libbionic_fg.so" "$OUTPUT_DIR/VkLayer_BIONIC_framegen.json"
cp "$BUILD_DIR/libbionic_fg.so" "$OUTPUT_DIR/libbionic_fg.so"
cp "$ROOT_DIR/VkLayer_BIONIC_framegen.json" "$OUTPUT_DIR/VkLayer_BIONIC_framegen.json"

if command -v file >/dev/null 2>&1; then
    file "$OUTPUT_DIR/libbionic_fg.so"
fi
printf 'Library: %s\nManifest: %s\n' \
    "$OUTPUT_DIR/libbionic_fg.so" "$OUTPUT_DIR/VkLayer_BIONIC_framegen.json"