forked from blastrock/pkgj
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
155 lines (128 loc) · 4.73 KB
/
build.sh
File metadata and controls
155 lines (128 loc) · 4.73 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/usr/bin/env bash
# build.sh — convenience build script for pkgj fork
#
# Usage:
# ./build.sh [target] [--clean]
#
# Targets:
# host Build host simulator (output: ci/buildhost/pkgj_cli)
# vita Build PS Vita release (output: ci/build/pkgj.vpk) [default]
# vita-release Same as vita
# vita-test Build PS Vita test (output: ci/buildtest/pkgj.vpk)
# Title ID : PKGJ00099
# App name : "PKGj+ TEST"
# (Safe to install alongside the release build on the same Vita)
#
# Options:
# --clean Remove the build directory before building (full rebuild)
set -euo pipefail
# ── Resolve project root ──
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TARGET="vita"
CLEAN=0
for arg in "$@"; do
case "$arg" in
host|vita|vita-release|vita-test) TARGET="$arg" ;;
--clean) CLEAN=1 ;;
*)
echo "Unknown argument: $arg"
echo "Usage: $0 [host|vita|vita-release|vita-test] [--clean]"
exit 1
;;
esac
done
[[ "$TARGET" == "vita-release" ]] && TARGET="vita"
# ── Compilers ──
export CC="${CC:-gcc-12}"
export CXX="${CXX:-g++-12}"
# ── VitaSDK ──
export VITASDK="${VITASDK:-/root/vitasdk}"
export PATH="$VITASDK/bin:$PATH"
# ── Must run conan from inside ci/ so Poetry finds pyproject.toml ──
cd "$SCRIPT_DIR/ci"
# ── Helper: clean build dir ──
maybe_clean() {
local dir="$1"
if [[ $CLEAN -eq 1 && -d "$dir" ]]; then
echo "==> Removing $dir"
rm -rf "$dir"
fi
mkdir -p "$dir"
}
# ── Build ──
case "$TARGET" in
# ------------------------------------------------------------------
host)
echo "==> Building host simulator"
maybe_clean buildhost
cd buildhost
poetry run conan install ../.. \
-s build_type=RelWithDebInfo \
-s compiler=gcc \
-s compiler.version=12 \
-s compiler.libcxx=libstdc++11 \
--build missing \
--output-folder .
cmake ../.. \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DBUILD_SIM=ON
ninja pkgj_cli pkgj_sim
echo ""
echo "==> Done. Binaries: ci/buildhost/pkgj_cli ci/buildhost/pkgj_sim"
;;
# ------------------------------------------------------------------
vita)
echo "==> Building Vita release (PKGJ00001 / PKGj+)"
maybe_clean build
cd build
poetry run conan install ../.. \
-s build_type=RelWithDebInfo \
--profile:host vita \
--build missing \
--output-folder .
poetry run conan build ../.. \
-s build_type=RelWithDebInfo \
--profile:host vita \
--output-folder .
# Keep ELF with debug symbols alongside the stripped eboot
[[ -f pkgj ]] && cp pkgj pkgj.elf
echo ""
echo "==> Done. Package: ci/build/pkgj.vpk"
;;
# ------------------------------------------------------------------
vita-test)
echo "==> Building Vita TEST (PKGJ00099 / PKGj+ TEST)"
maybe_clean buildtest
cd buildtest
# Step 1: conan install — resolves deps, generates conan_toolchain.cmake
poetry run conan install ../.. \
-s build_type=RelWithDebInfo \
--profile:host vita \
--build missing \
--output-folder .
# Source the generated cross-compile env (sets CC/CXX/AR/STRIP/etc)
# Pre-initialize variables that the generated file appends to, so that
# set -u (nounset) does not abort when they are not already in the
# environment (LD_LIBRARY_PATH / DYLD_LIBRARY_PATH are often absent).
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}"
export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:-}"
# shellcheck disable=SC1091
[[ -f conanbuildenv-relwithdebinfo-armv7.sh ]] && \
source conanbuildenv-relwithdebinfo-armv7.sh
# Step 2: cmake configure — override Title ID and App Name for the test build
# VITA_TITLEID and VITA_APP_NAME are CACHE variables in CMakeLists.txt
# so -D flags here take precedence over the defaults.
cmake ../.. \
-G Ninja \
-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DVITA_TITLEID="PKGJ00099" \
-DVITA_APP_NAME="PKGj+ TEST"
# Step 3: cmake build
cmake --build .
[[ -f pkgj ]] && cp pkgj pkgj.elf
echo ""
echo "==> Done. Package: ci/buildtest/pkgj.vpk"
echo " Title ID PKGJ00099 — safe to install alongside the release build."
;;
esac