-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.sh
executable file
·60 lines (45 loc) · 1.73 KB
/
build.sh
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
#!/bin/bash
set -eo pipefail
source "$( dirname "${BASH_SOURCE[0]}" )/_env.sh"
if [[ -z "$DEVKITPRO" ]]; then
echo "DEVKITPRO env var missing" 1>&2
exit 1
fi
if [[ -z "$JOBS" ]]; then
JOBS="$(nproc --all)"
fi
echo "** env **"
source "$DEVKITPRO/switchvars.sh"
CFLAGS="$CFLAGS -g -I$PORTLIBS_PREFIX/include -I$PORTLIBS_PREFIX/include/SDL2 -D__SWITCH__ -I$DEVKITPRO/libnx/include"
export SDL2DIR="$PORTLIBS_PREFIX"
function switch_cmake() {
cmake -G"Unix Makefiles" \
-DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/Switch.cmake" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS="$CFLAGS $CPPFLAGS" \
-DCMAKE_CXX_FLAGS="$CFLAGS" \
"$@"
}
echo "** luajit **"
mkdir -p "$BUILD_DIR/luajit"
cp -auf "$ROOT_DIR/repo/luajit/." "$BUILD_DIR/luajit"
make -C "$BUILD_DIR/luajit/src" -j$JOBS libluajit.a \
CROSS="$TOOL_PREFIX" CFLAGS="" LDFLAGS="" LIBS="" TARGET_SYS="SWITCH" BUILDMODE="static" \
XCFLAGS="-DLJ_TARGET_CONSOLE=1 -DLUAJIT_DISABLE_JIT -DLUAJIT_USE_SYSMALLOC" \
TARGET_CFLAGS="$CFLAGS" TARGET_LDFLAGS="$LDFLAGS" TARGET_LIBS="$LIBS"
echo "** LÖVE **"
mkdir -p "$BUILD_DIR/love"
cd "$BUILD_DIR/love"
switch_cmake \
-DPHYSFS_LIBRARY="$PORTLIBS_PREFIX/lib/libphysfs.a" \
-DOPENAL_LIBRARY="$PORTLIBS_PREFIX/lib/libopenal.a" \
-DLUAJIT_LIBRARY="$BUILD_DIR/luajit/src/libluajit.a" \
-DLUAJIT_INCLUDE_DIR="$ROOT_DIR/repo/luajit/src" \
"$ROOT_DIR/repo/love"
make -j$JOBS
echo "** NRO **"
mkdir -p "$DIST_DIR"
cp -vf "$BUILD_DIR/love/love.elf" "$DIST_DIR/$APP_NAME.elf"
"$DEVKITPRO/tools/bin/nacptool" --create "$APP_TITLE" "$APP_AUTHOR" "$APP_VERSION" "$DIST_DIR/$APP_NAME.nacp"
"$DEVKITPRO/tools/bin/elf2nro" "$DIST_DIR/$APP_NAME.elf" "$DIST_DIR/$APP_NAME.nro" --icon="$APP_ICON" --nacp="$DIST_DIR/$APP_NAME.nacp"
echo "Built $DIST_DIR/$APP_NAME.nro"