Skip to content

Commit

Permalink
Reworked build scripts (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeef authored Jun 16, 2024
1 parent 31ef9e3 commit 85afefc
Show file tree
Hide file tree
Showing 32 changed files with 175 additions and 135 deletions.
14 changes: 8 additions & 6 deletions scripts/build-android.sh → scripts/android/build.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#!/usr/bin/env bash
# This script is meant to be run from the root of the project.

source scripts/variables-android.sh
source variables.sh

# Following variables must be present in the environment:
#
# ANDROID_NDK_HOME - Root of directory with unpacked Android NDK, i.e - /opt/android/android-ndk-r15c
# ANDROID_DEPS_ARMEABI_V7A - Root of directory with armeabi-v7a dependency artifacts, i.e - /opt/android/deps-armeabi-v7a,
# will be forwarded to CMake through CMAKE_PREFIX_PATH.
# ANDROID_DEPS_ARM64_V8A - Root of directory with arm64-v8a dependency artifacts, i.e - /opt/android/deps-arm64-v8a,
# will be forwarded to CMake through CMAKE_PREFIX_PATH.
# will be forwarded to CMake through CMAKE_PREFIX_PATH.

rm -rf $INSTALL_PATH
mkdir -p $INSTALL_PATH
echo ANDROID_NDK_HOME: $ANDROID_NDK_HOME
echo ANDROID_DEPS_ARMEABI_V7A: $ANDROID_DEPS_ARMEABI_V7A
echo ANDROID_DEPS_ARM64_V8A: $ANDROID_DEPS_ARM64_V8A

cd $ROOT_PATH/platforms/android
# FIXME: This should be building under TMP_PATH, just like every other artifact:
cd $PLATFORMS_PATH/android
./gradlew assemble
cp build/android-app/outputs/apk/debug/Spelunky_PSP-debug.apk $INSTALL_PATH/Spelunky_PSP.apk
5 changes: 5 additions & 0 deletions scripts/android/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source variables.sh

yes | rm -r $TMP_PATH
14 changes: 14 additions & 0 deletions scripts/android/variables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# Stop on error:
set -e
# Referencing unset variables are errors:
set -u

ROOT_PATH=$(realpath ../../)
TMP_PATH=$ROOT_PATH/tmp
INSTALL_PATH=$TMP_PATH/install-android
BUILD_PATH=$TMP_PATH/build-android
# TODO: Think about moving this directory somewhere else or more specific naming;
# "platform-specific/android", "platform-files/android", "extras/android"?
PLATFORMS_PATH=$ROOT_PATH/platforms
4 changes: 0 additions & 4 deletions scripts/build-darwin.sh

This file was deleted.

7 changes: 0 additions & 7 deletions scripts/build-linux.sh

This file was deleted.

6 changes: 0 additions & 6 deletions scripts/build-psp.sh

This file was deleted.

8 changes: 0 additions & 8 deletions scripts/build-windows.ps1

This file was deleted.

4 changes: 0 additions & 4 deletions scripts/clean.sh

This file was deleted.

13 changes: 0 additions & 13 deletions scripts/config-darwin.sh

This file was deleted.

16 changes: 0 additions & 16 deletions scripts/config-linux.sh

This file was deleted.

20 changes: 0 additions & 20 deletions scripts/config-psp.sh

This file was deleted.

27 changes: 0 additions & 27 deletions scripts/config-windows.ps1

This file was deleted.

9 changes: 9 additions & 0 deletions scripts/darwin/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

source variables.sh

cmake \
--build $BUILD_PATH \
--target install \
--config Release \
-j $NUM_THREADS
5 changes: 5 additions & 0 deletions scripts/darwin/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source variables.sh

yes | rm -r $TMP_PATH
10 changes: 10 additions & 0 deletions scripts/darwin/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

source variables.sh

cmake \
-B $BUILD_PATH \
-S $ROOT_PATH \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$INSTALL_PATH
12 changes: 12 additions & 0 deletions scripts/darwin/variables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# Stop on error:
set -e
# Referencing unset variables are errors:
set -u

ROOT_PATH=$(realpath ../../)
TMP_PATH=$ROOT_PATH/tmp
INSTALL_PATH=$TMP_PATH/install-darwin
BUILD_PATH=$TMP_PATH/build-darwin
NUM_THREADS=$(nproc)
9 changes: 9 additions & 0 deletions scripts/linux/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

source variables.sh

cmake \
--build $BUILD_PATH \
--target install \
--config Release \
-j $NUM_THREADS
5 changes: 5 additions & 0 deletions scripts/linux/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source variables.sh

yes | rm -r $TMP_PATH
10 changes: 10 additions & 0 deletions scripts/linux/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

source variables.sh

cmake \
-S $ROOT_PATH \
-B $BUILD_PATH \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$INSTALL_PATH
12 changes: 12 additions & 0 deletions scripts/linux/variables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# Stop on error:
set -e
# Referencing unset variables are errors:
set -u

ROOT_PATH=$(realpath ../../)
TMP_PATH=$ROOT_PATH/tmp
INSTALL_PATH=$TMP_PATH/install-linux
BUILD_PATH=$TMP_PATH/build-linux
NUM_THREADS=$(nproc)
9 changes: 9 additions & 0 deletions scripts/psp/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

source variables.sh

cmake \
--build $BUILD_PATH \
--target install \
--config Release \
-j $NUM_THREADS
5 changes: 5 additions & 0 deletions scripts/psp/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source variables.sh

yes | rm -r $TMP_PATH
13 changes: 13 additions & 0 deletions scripts/psp/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#/usr/bin/env bash

source variables.sh

# "psp-cmake" is guaranteed to be in PATH after successful pspdev/psptoolchain installation AND in the official PSP SDK Docker image;
# it's a shell script calling host's vanilla cmake with cmake toolchain file already passed:

psp-cmake \
-S $ROOT_PATH \
-B $BUILD_PATH \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$INSTALL_PATH \
-DCMAKE_VERBOSE_MAKEFILE=ON
12 changes: 12 additions & 0 deletions scripts/psp/docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

source variables.sh

cd $ROOT_PATH
sudo docker run \
--rm \
-it \
-v $(pwd):/root \
pspdev/pspdev:latest \
/bin/bash -c "cd /root/scripts/psp/ && ./config.sh && ./build.sh"
sudo chown -R $(whoami) $TMP_PATH
6 changes: 6 additions & 0 deletions scripts/psp/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

source variables.sh

# Run filtering everything except Spelunky-PSP output:
ppsspp $BUILD_PATH/EBOOT.PBP 2>&1 | grep -F SPELUNKY
12 changes: 12 additions & 0 deletions scripts/psp/variables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# Stop on error:
set -e
# Referencing unset variables are errors:
set -u

ROOT_PATH=$(realpath ../../)
TMP_PATH=$ROOT_PATH/tmp
INSTALL_PATH=$TMP_PATH/install-psp
BUILD_PATH=$TMP_PATH/build-psp
NUM_THREADS=$(nproc)
7 changes: 0 additions & 7 deletions scripts/run-psp.sh

This file was deleted.

8 changes: 0 additions & 8 deletions scripts/variables-android.sh

This file was deleted.

8 changes: 0 additions & 8 deletions scripts/variables-psp.sh

This file was deleted.

3 changes: 3 additions & 0 deletions scripts/windows/build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$ErrorActionPreference = "Stop"

cmake --build "../../tmp/build-windows" --target install --config Release -j $env:NUMBER_OF_PROCESSORS
15 changes: 15 additions & 0 deletions scripts/windows/config.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$ErrorActionPreference = "Stop"

$ROOT_PATH = "$(Get-Location)/../../"
$TMP_PATH = "$ROOT_PATH/tmp"
$DEPS_PATH = "$TMP_PATH/deps-windows/SDL"
$INSTALL_PATH = "$TMP_PATH/install-windows"
$BUILD_PATH = "$TMP_PATH/build-windows"

New-Item -Path "$BUILD_PATH" -ItemType "Directory"

cmake `
-S $ROOT_PATH `
-B "$BUILD_PATH" `
-DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" `
-DCMAKE_PREFIX_PATH="$DEPS_PATH"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ param (
$SDLMixerVersion="1.2.12",

[Parameter()][String]
$DepsDirectory="deps"
$DepsDirectory="../../tmp/deps-windows"
)

$ErrorActionPreference = "Stop"
Expand Down

0 comments on commit 85afefc

Please sign in to comment.