Skip to content

Commit

Permalink
Create scripts for tools
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtrujy committed Oct 22, 2021
1 parent 63acc9f commit 58fcc05
Show file tree
Hide file tree
Showing 12 changed files with 235 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on:
push:
pull_request:
repository_dispatch:
types: [run_build]

jobs:
build:
runs-on: ubuntu-latest
container: ghcr.io/fjtrujy/pspsdk:latest
steps:
- uses: actions/checkout@v2

- name: Install dependencies
run: |
apk add build-base bash git python3 py3-pip cmake m4 pkgconfig libarchive-tools libarchive-dev openssl-dev gpgme-dev \
curl-dev asciidoc asciidoctor
- name: Compile PKGConf
run: |
./build-all.sh
61 changes: 61 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CI-Docker

on:
push:
branches:
- main
tags:
- v*
repository_dispatch:
types: [run_build]


jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Extract DOCKER_TAG using tag name
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "DOCKER_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Use default DOCKER_TAG
if: startsWith(github.ref, 'refs/tags/') != true
run: |
echo "DOCKER_TAG=latest" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Github registry
uses: docker/login-action@v1
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io

- uses: docker/build-push-action@v2
with:
push: true
tags: ghcr.io/${{ github.repository }}:${{ env.DOCKER_TAG }}
build-args: |
BASE_DOCKER_IMAGE=ghcr.io/${{ github.repository_owner }}/pspsdk:${{ env.DOCKER_TAG }}
- name: Send Compile action
run: |
export DISPATCH_ACTION="$(echo run_build)"
echo "NEW_DISPATCH_ACTION=$DISPATCH_ACTION" >> $GITHUB_ENV
- name: Repository Dispatch to psp-packages
uses: peter-evans/repository-dispatch@v1
with:
repository: ${{ github.repository_owner }}/psp-packages
token: ${{ secrets.DISPATCH_TOKEN }}
event-type: ${{ env.NEW_DISPATCH_ACTION }}
client-payload: '{"ref": "${{ github.ref }}"}'
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ARG BASE_DOCKER_IMAGE

FROM $BASE_DOCKER_IMAGE

COPY . /src

RUN apk add build-base bash git python3 py3-pip cmake m4 pkgconfig libarchive-tools libarchive-dev openssl-dev gpgme-dev \
curl-dev asciidoc asciidoctor
RUN cd /src && ./build-all.sh

# Second stage of Dockerfile
FROM alpine:latest

ENV PSPDEV /usr/local/pspdev
ENV PATH $PATH:${PSPDEV}/bin

COPY --from=0 ${PSPDEV} ${PSPDEV}
48 changes: 48 additions & 0 deletions build-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
# toolchain.sh by fjtrujy

## Enter the pspdev directory.
cd "$(dirname "$0")" || { echo "ERROR: Could not enter the pspdev directory."; exit 1; }

## Create the build directory.
mkdir -p build || { echo "ERROR: Could not create the build directory."; exit 1; }

## Enter the build directory.
cd build || { echo "ERROR: Could not enter the build directory."; exit 1; }

## Fetch the depend scripts.
DEPEND_SCRIPTS=($(ls ../depends/*.sh | sort))

## Run all the depend scripts.
for SCRIPT in ${DEPEND_SCRIPTS[@]}; do "$SCRIPT" || { echo "$SCRIPT: Failed."; exit 1; } done

## Check if repo is in a tag, to install this specfic PSP Dev environment
if git describe --exact-match --tags $(git log -n1 --pretty='%h') >/dev/null 2>&1; then
TAG=$(git describe --exact-match --tags $(git log -n1 --pretty='%h'))
if [ "$TAG" = "latest" ]; then
## Ignore latest tag, as this tag is for service purposes only
echo "Installing latest environment status"
TAG="";
else
echo "Instaling specific version $TAG";
fi
else
echo "Installing latest environment status"
TAG=""
fi

## Fetch the build scripts.
BUILD_SCRIPTS=($(ls ../scripts/*.sh | sort))

## If specific steps were requested...
if [ "$1" ]; then

## Run the requested build scripts.
for STEP in "$@"; do "${BUILD_SCRIPTS[$STEP-1]}" "$TAG" || { echo "${BUILD_SCRIPTS[$STEP-1]}: Failed."; exit 1; } done

else

## Run the all build scripts.
for SCRIPT in ${BUILD_SCRIPTS[@]}; do "$SCRIPT" "$TAG" || { echo "$SCRIPT: Failed."; exit 1; } done

fi
5 changes: 5 additions & 0 deletions depends/check-git.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
# check-git.sh by Mathias Lafeldt <[email protected]>

## Check for git.
git --version > /dev/null || { echo "ERROR: Install Git before continuing."; exit 1; }
5 changes: 5 additions & 0 deletions depends/check-make.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
# check-make.sh by Naomi Peori ([email protected])

## Check for make.
make -v 1> /dev/null || { echo "ERROR: Install make before continuing."; exit 1; }
5 changes: 5 additions & 0 deletions depends/check-patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
# check-patch.sh by Naomi Peori ([email protected])

## Check for patch.
patch -v 1> /dev/null || { echo "ERROR: Install patch before continuing."; exit 1; }
5 changes: 5 additions & 0 deletions depends/check-pspdev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
# check-pspdev.sh by Naomi Peori ([email protected])

## Check if $PSPDEV is set.
if test ! "$PSPDEV"; then { echo "ERROR: Set \$PSPDEV before continuing."; exit 1; } fi
21 changes: 21 additions & 0 deletions pspdev.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_SYSTEM_PROCESSOR mips)
SET(CMAKE_C_COMPILER psp-gcc)
SET(CMAKE_CXX_COMPILER psp-g++)
SET(CMAKE_C_FLAGS_INIT "-I$ENV{PSPDEV}/psp/include -I$ENV{PSPDEV}/psp/sdk/include -DPSP -O2 -G0")
SET(CMAKE_CXX_FLAGS_INIT "-I$ENV{PSPDEV}/psp/include -I$ENV{PSPDEV}/psp/sdk/include -DPSP -O2 -G0")
SET(CMAKE_EXE_LINKER_FLAGS_INIT "-L$ENV{PSPDEV}/lib -L$ENV{PSPDEV}/psp/lib -L$ENV{PSPDEV}/psp/sdk/lib -Wl,-zmax-page-size=128")
#SET(CMAKE_SHARED_LINKER_FLAGS_INIT "...")
#SET(CMAKE_STATIC_LINKER_FLAGS_CONFIG_INIT "...")
#SET(CMAKE_STATIC_LINKER_FLAGS_INIT "...")
SET(CMAKE_TARGET_INSTALL_PREFIX $ENV{PSPDEV}/psp/sdk)

SET(CMAKE_FIND_ROOT_PATH $ENV{PSPDEV} $ENV{PSPDEV}/psp $ENV{PSPDEV}/psp/sdk)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

## Add Default PSPSDK Libraries according to build.mak and add stdc++ for C++ builds so this doesn't need to be done manually later
include_directories($ENV{PSPDEV}/psp/include $ENV{PSPDEV}/psp/sdk/include)
link_directories( $ENV{PSPDEV}/lib $ENV{PSPDEV}/psp/lib $ENV{PSPDEV}/psp/sdk/lib)
21 changes: 21 additions & 0 deletions scripts/001-psp-pkgconf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# psp-pkgconf.sh by fjtrujy

## Download the source code.
REPO_URL="https://github.com/fjtrujy/psp-pkgconf"
REPO_FOLDER="psp-pkgconf"
BRANCH_NAME="master"
if test ! -d "$REPO_FOLDER"; then
git clone --depth 1 -b $BRANCH_NAME $REPO_URL && cd $REPO_FOLDER || { exit 1; }
else
cd $REPO_FOLDER && git fetch origin && git reset --hard origin/${BRANCH_NAME} || { exit 1; }
fi

## Determine the maximum number of processes that Make can work with.
PROC_NR=$(getconf _NPROCESSORS_ONLN)

## Compile and install.
make --quiet -j $PROC_NR clean || { exit 1; }
make --quiet -j $PROC_NR all || { exit 1; }
make --quiet -j $PROC_NR install || { exit 1; }
make --quiet -j $PROC_NR clean || { exit 1; }
18 changes: 18 additions & 0 deletions scripts/002-psp-pacman.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
# psp-pacman.sh by fjtrujy

## Download the source code.
REPO_URL="https://github.com/fjtrujy/psp-pacman"
REPO_FOLDER="psp-pacman"
BRANCH_NAME="master"
if test ! -d "$REPO_FOLDER"; then
git clone --depth 1 -b $BRANCH_NAME $REPO_URL && cd $REPO_FOLDER || { exit 1; }
else
cd $REPO_FOLDER && git fetch origin && git reset --hard origin/${BRANCH_NAME} || { exit 1; }
fi

## Determine the maximum number of processes that Make can work with.
PROC_NR=$(getconf _NPROCESSORS_ONLN)

## Compile and install.
./pacman.sh || { exit 1; }
6 changes: 6 additions & 0 deletions scripts/003-pspcmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# pspcmake.sh by fjtrujy

## Compile and install.
mkdir -p PSPDEV/psp/share || { exit 1; }
cp ../pspdev.cmake $PSPDEV/psp/share/pspdev.cmake || { exit 1; }

0 comments on commit 58fcc05

Please sign in to comment.