From a75b3fa4b1a1b882c33f533645ddae75c09dd697 Mon Sep 17 00:00:00 2001 From: spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> Date: Sun, 28 Nov 2021 18:15:14 +0100 Subject: Switch to mipsel-none-elf, move docs, add template presets --- doc/installation.md | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 doc/installation.md (limited to 'doc/installation.md') diff --git a/doc/installation.md b/doc/installation.md new file mode 100644 index 0000000..576eb7a --- /dev/null +++ b/doc/installation.md @@ -0,0 +1,155 @@ + +# Getting started with PSn00bSDK + +## Building and installing + +The instructions below are for Windows and Linux. Building on macOS hasn't been +tested extensively yet, however it should work once the GCC toolchain is built +and installed properly. + +1. Install prerequisites and a host compiler toolchain. On Linux (most distros) + install the following packages from your distro's package manager: + + - `git` + - `build-essential`, `base-devel` or similar + - `make` or `ninja-build` + - `cmake` (3.20+ is required, download it from + [here](https://cmake.org/download) if your package manager only provides + older versions) + + On Windows you can obtain these dependencies by installing + [MSys2](https://www.msys2.org), opening the "MSys2 MSYS" shell and running: + + ```bash + pacman -Syu git mingw-w64-x86_64-make mingw-w64-x86_64-ninja mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc + ``` + + If you are prompted to close the shell, you may have to reopen it afterwards + and rerun the command to finish installation. + **Do not use the MSys2 shell for the next steps**, use a regular command + prompt or PowerShell instead. + + Add these directories (replace `C:\msys64` if you installed MSys2 to a + different location) to the `PATH` environment variable using System + Properties: + + - `C:\msys64\mingw64\bin` + - `C:\msys64\usr\bin` + +2. Download a precompiled copy of the GCC toolchain for `mipsel-none-elf` from + the releases page and extract it into one of the directories listed in + step 3. If you want to build the toolchain yourself, see + [toolchain.md](toolchain.md). + + **NOTE**: PSn00bSDK is also compatible with toolchains that target + `mipsel-unknown-elf`. If you already have such a toolchain, you can use it + by passing `-DPSN00BSDK_TARGET=mipsel-unknown-elf` to CMake when configuring + the SDK (see step 5). + +3. If you chose a non-standard install location for the toolchain, add the + `bin` subfolder (inside the top-level toolchain directory) to the `PATH` + environment variable. This step is unnecessary if you installed/extracted + the toolchain into any of these directories: + + - `C:\Program Files\mipsel-none-elf` + - `C:\Program Files (x86)\mipsel-none-elf` + - `C:\mipsel-none-elf` + - `/usr/local/mipsel-none-elf` + - `/usr/mipsel-none-elf` + - `/opt/mipsel-none-elf` + +4. Clone the PSn00bSDK repo, then run the following command from the PSn00bSDK + repository to download additional dependencies: + + ```bash + git submodule update --init --recursive --remote + ``` + +5. Compile the libraries, tools and examples using CMake: + + ```bash + cmake --preset default . + cmake --build ./build + ``` + + If you want to install the SDK to a custom location rather than the default + one (`C:\Program Files\PSn00bSDK` or `/usr/local` depending on your OS), add + `--install-prefix ` to the first command. Add + `-DPSN00BSDK_TARGET=mipsel-none-elf` if your toolchain targets + `mipsel-none-elf` rather than `mipsel-unknown-elf`. + + **NOTE**: Ninja is used by default to build the SDK. If you can't get it to + work or don't have it installed, pass `-G "Unix Makefiles"` (or + `-G "MSYS Makefiles"` on Windows) to the first command to build using `make` + instead. + +6. Install the SDK to the path you chose (add `sudo` or run it from a command + prompt with admin privileges if necessary): + + ```bash + cmake --install ./build + ``` + + This will create and populate the following directories: + + - `/bin` + - `/lib/libpsn00b` + - `/share/psn00bsdk` + +7. Set the `PSN00BSDK_LIBS` environment variable to point to the `lib/libpsn00b` + subfolder inside the install directory. You might also want to add the `bin` + folder to `PATH` if it's not listed already. + +Although not strictly required, you'll probably want to install a PS1 emulator +with debugging capabilities such as [no$psx](https://problemkaputt.de/psx.htm) +(Windows only), [DuckStation](https://github.com/stenzek/duckstation) or +[pcsx-redux](https://github.com/grumpycoders/pcsx-redux). +**Avoid ePSXe and anything based on MAME** as they are inaccurate. + +## Building installer packages + +CPack can be used to build NSIS-based installers, DEB/RPM packages and zipped +releases that include built SDK libraries, headers as well as the GCC toolchain. +Distributing prebuilt releases is however discouraged since PSn00bSDK is still +far from being feature-complete. + +1. Follow steps 1-4 above to set up the toolchain, then install + [NSIS](https://nsis.sourceforge.io/Download) on Windows or `dpkg` and `rpm` + on Linux. + +2. Run the following commands from the PSn00bSDK directory (pass the + appropriate options to the first command if necessary): + + ```bash + cmake --preset package . + cmake --build ./build -t package + ``` + + All built packages will be copied to the `build/packages` folder. + +## Creating a project + +1. Copy the contents of `/share/psn00bsdk/template` (or the + `template` folder within the repo) to your new project's root directory. + +2. Configure and build the template by running: + + ```bash + cmake -S . -B ./build + cmake --build ./build + ``` + + If you did everything correctly there should be a `template.bin` CD image in + the `build` folder. Test it in an emulator to ensure it works. + +Note that, even though the template relies on the `PSN00BSDK_LIBS` environment +variable to locate the SDK by default, you can also specify the path directly +on the CMake command line by adding +`-DCMAKE_TOOLCHAIN_FILE=/lib/libpsn00b/cmake/sdk.cmake` to the +CMake command line. + +The toolchain script defines a few CMake macros to create PS1 executables, DLLs +and CD images. See the [reference](doc/cmake_reference.md) for details. + +----------------------------------------- +_Last updated on 2021-11-19 by spicyjpeg_ -- cgit v1.2.3 From d60b046bf362fcc9332f463823e8d02147d516de Mon Sep 17 00:00:00 2001 From: spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> Date: Thu, 23 Dec 2021 23:20:12 +0100 Subject: Remove PSN00BSDK_LIBS leftovers, improve CI artifact upload --- .github/workflows/build.yml | 32 +++++++++++++++++++++++------ doc/installation.md | 25 +++++++++++----------- examples/beginner/cppdemo/CMakeLists.txt | 4 ---- examples/beginner/hello/CMakeLists.txt | 4 ---- examples/cdrom/cdbrowse/CMakeLists.txt | 4 ---- examples/cdrom/cdxa/CMakeLists.txt | 4 ---- examples/demos/n00bdemo/CMakeLists.txt | 4 ---- examples/graphics/balls/CMakeLists.txt | 4 ---- examples/graphics/billboard/CMakeLists.txt | 4 ---- examples/graphics/fpscam/CMakeLists.txt | 4 ---- examples/graphics/gte/CMakeLists.txt | 4 ---- examples/graphics/hdtv/CMakeLists.txt | 4 ---- examples/graphics/render2tex/CMakeLists.txt | 4 ---- examples/graphics/rgb24/CMakeLists.txt | 4 ---- examples/io/pads/CMakeLists.txt | 4 ---- examples/io/system573/CMakeLists.txt | 4 ---- examples/lowlevel/cartrom/CMakeLists.txt | 4 ---- examples/sound/spustream/CMakeLists.txt | 4 ---- examples/sound/vagsample/CMakeLists.txt | 4 ---- examples/system/childexec/CMakeLists.txt | 4 ---- examples/system/console/CMakeLists.txt | 4 ---- examples/system/dynlink/CMakeLists.txt | 4 ---- examples/system/timer/CMakeLists.txt | 4 ---- examples/system/tty/CMakeLists.txt | 4 ---- 24 files changed, 38 insertions(+), 107 deletions(-) (limited to 'doc/installation.md') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8c16ac3..3cbefb1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -124,13 +124,20 @@ jobs: cmake --build build cmake --build build -t package + # The GitHub Actions UI doesn't allow downloading individual files from + # an artifact, so it's best to upload each package type as a separate + # artifact. - name: Upload build artifacts uses: actions/upload-artifact@v2 with: name: psn00bsdk-windows - path: | - build/packages/* - !build/packages/_CPack_Packages + path: build/packages/*.zip + + - name: Upload build artifacts (NSIS) + uses: actions/upload-artifact@v2 + with: + name: psn00bsdk-windows-nsis + path: build/packages/*.exe build-sdk-linux: name: Build PSn00bSDK on Linux @@ -169,9 +176,19 @@ jobs: uses: actions/upload-artifact@v2 with: name: psn00bsdk-linux - path: | - build/packages/* - !build/packages/_CPack_Packages + path: build/packages/*.zip + + - name: Upload build artifacts (DEB) + uses: actions/upload-artifact@v2 + with: + name: psn00bsdk-linux-deb + path: build/packages/*.deb + + - name: Upload build artifacts (RPM) + uses: actions/upload-artifact@v2 + with: + name: psn00bsdk-linux-rpm + path: build/packages/*.rpm # This job takes care of creating a new release and upload the build # artifacts if the last commit is associated to a tag. @@ -222,4 +239,7 @@ jobs: files: | *.zip psn00bsdk-windows/* + psn00bsdk-windows-nsis/* psn00bsdk-linux/* + psn00bsdk-linux-deb/* + psn00bsdk-linux-rpm/* diff --git a/doc/installation.md b/doc/installation.md index 576eb7a..ca3aab4 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -96,9 +96,9 @@ and installed properly. - `/lib/libpsn00b` - `/share/psn00bsdk` -7. Set the `PSN00BSDK_LIBS` environment variable to point to the `lib/libpsn00b` - subfolder inside the install directory. You might also want to add the `bin` - folder to `PATH` if it's not listed already. +7. You may optionally set the `PSN00BSDK_LIBS` environment variable to point to + the `lib/libpsn00b` subfolder inside the install directory. You might also + want to add the `bin` folder to `PATH` if it's not listed already. Although not strictly required, you'll probably want to install a PS1 emulator with debugging capabilities such as [no$psx](https://problemkaputt.de/psx.htm) @@ -132,24 +132,23 @@ far from being feature-complete. 1. Copy the contents of `/share/psn00bsdk/template` (or the `template` folder within the repo) to your new project's root directory. -2. Configure and build the template by running: +2. If you haven't set the `PSN00BSDK_LIBS` environment variable previously or + if you want to use a different PSn00bSDK installation for the project, edit + `CMakePresets.json` to set the path you installed the SDK to. See the + [setup guide](cmake_reference.md#setup) for details. + +3. Configure and build the template by running: ```bash - cmake -S . -B ./build + cmake --preset default . cmake --build ./build ``` If you did everything correctly there should be a `template.bin` CD image in the `build` folder. Test it in an emulator to ensure it works. -Note that, even though the template relies on the `PSN00BSDK_LIBS` environment -variable to locate the SDK by default, you can also specify the path directly -on the CMake command line by adding -`-DCMAKE_TOOLCHAIN_FILE=/lib/libpsn00b/cmake/sdk.cmake` to the -CMake command line. - The toolchain script defines a few CMake macros to create PS1 executables, DLLs -and CD images. See the [reference](doc/cmake_reference.md) for details. +and CD images. See the [reference](cmake_reference.md) for details. ----------------------------------------- -_Last updated on 2021-11-19 by spicyjpeg_ +_Last updated on 2021-12-23 by spicyjpeg_ diff --git a/examples/beginner/cppdemo/CMakeLists.txt b/examples/beginner/cppdemo/CMakeLists.txt index becf464..c43d4a1 100644 --- a/examples/beginner/cppdemo/CMakeLists.txt +++ b/examples/beginner/cppdemo/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( cppdemo LANGUAGES CXX diff --git a/examples/beginner/hello/CMakeLists.txt b/examples/beginner/hello/CMakeLists.txt index 7fb7c22..d8297c5 100644 --- a/examples/beginner/hello/CMakeLists.txt +++ b/examples/beginner/hello/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( hello LANGUAGES C diff --git a/examples/cdrom/cdbrowse/CMakeLists.txt b/examples/cdrom/cdbrowse/CMakeLists.txt index e5ec759..e36407d 100644 --- a/examples/cdrom/cdbrowse/CMakeLists.txt +++ b/examples/cdrom/cdbrowse/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( cdbrowse LANGUAGES C diff --git a/examples/cdrom/cdxa/CMakeLists.txt b/examples/cdrom/cdxa/CMakeLists.txt index 18dcc69..7b90f59 100644 --- a/examples/cdrom/cdxa/CMakeLists.txt +++ b/examples/cdrom/cdxa/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( cdxa LANGUAGES C diff --git a/examples/demos/n00bdemo/CMakeLists.txt b/examples/demos/n00bdemo/CMakeLists.txt index c62c4ef..1c211b3 100644 --- a/examples/demos/n00bdemo/CMakeLists.txt +++ b/examples/demos/n00bdemo/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( n00bdemo LANGUAGES C ASM diff --git a/examples/graphics/balls/CMakeLists.txt b/examples/graphics/balls/CMakeLists.txt index 5886484..f5297c3 100644 --- a/examples/graphics/balls/CMakeLists.txt +++ b/examples/graphics/balls/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( balls LANGUAGES C diff --git a/examples/graphics/billboard/CMakeLists.txt b/examples/graphics/billboard/CMakeLists.txt index 8cd31a9..1b417d2 100644 --- a/examples/graphics/billboard/CMakeLists.txt +++ b/examples/graphics/billboard/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( billboard LANGUAGES C ASM diff --git a/examples/graphics/fpscam/CMakeLists.txt b/examples/graphics/fpscam/CMakeLists.txt index 791f6c2..cb0c086 100644 --- a/examples/graphics/fpscam/CMakeLists.txt +++ b/examples/graphics/fpscam/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( fpscam LANGUAGES C diff --git a/examples/graphics/gte/CMakeLists.txt b/examples/graphics/gte/CMakeLists.txt index 85b2942..f95c5ff 100644 --- a/examples/graphics/gte/CMakeLists.txt +++ b/examples/graphics/gte/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( gte LANGUAGES C diff --git a/examples/graphics/hdtv/CMakeLists.txt b/examples/graphics/hdtv/CMakeLists.txt index f92faeb..804b096 100644 --- a/examples/graphics/hdtv/CMakeLists.txt +++ b/examples/graphics/hdtv/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( hdtv LANGUAGES C diff --git a/examples/graphics/render2tex/CMakeLists.txt b/examples/graphics/render2tex/CMakeLists.txt index 360840d..70e489e 100644 --- a/examples/graphics/render2tex/CMakeLists.txt +++ b/examples/graphics/render2tex/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( render2tex LANGUAGES C ASM diff --git a/examples/graphics/rgb24/CMakeLists.txt b/examples/graphics/rgb24/CMakeLists.txt index bf8a8fa..449981a 100644 --- a/examples/graphics/rgb24/CMakeLists.txt +++ b/examples/graphics/rgb24/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( rgb24 LANGUAGES C ASM diff --git a/examples/io/pads/CMakeLists.txt b/examples/io/pads/CMakeLists.txt index 5bd7f5d..cf5f817 100644 --- a/examples/io/pads/CMakeLists.txt +++ b/examples/io/pads/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( pads LANGUAGES C ASM diff --git a/examples/io/system573/CMakeLists.txt b/examples/io/system573/CMakeLists.txt index 34c9153..1c74347 100644 --- a/examples/io/system573/CMakeLists.txt +++ b/examples/io/system573/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.21) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( system573 LANGUAGES C ASM diff --git a/examples/lowlevel/cartrom/CMakeLists.txt b/examples/lowlevel/cartrom/CMakeLists.txt index 3e807a3..107cc3d 100644 --- a/examples/lowlevel/cartrom/CMakeLists.txt +++ b/examples/lowlevel/cartrom/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.21) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( cartrom LANGUAGES C ASM diff --git a/examples/sound/spustream/CMakeLists.txt b/examples/sound/spustream/CMakeLists.txt index 91243cf..9e84fa3 100644 --- a/examples/sound/spustream/CMakeLists.txt +++ b/examples/sound/spustream/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( spustream LANGUAGES C diff --git a/examples/sound/vagsample/CMakeLists.txt b/examples/sound/vagsample/CMakeLists.txt index 1a15d9c..f37be97 100644 --- a/examples/sound/vagsample/CMakeLists.txt +++ b/examples/sound/vagsample/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( vagsample LANGUAGES C diff --git a/examples/system/childexec/CMakeLists.txt b/examples/system/childexec/CMakeLists.txt index 88168e0..ca0c110 100644 --- a/examples/system/childexec/CMakeLists.txt +++ b/examples/system/childexec/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( childexec LANGUAGES C ASM diff --git a/examples/system/console/CMakeLists.txt b/examples/system/console/CMakeLists.txt index 6dc6154..d58f212 100644 --- a/examples/system/console/CMakeLists.txt +++ b/examples/system/console/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( console LANGUAGES C diff --git a/examples/system/dynlink/CMakeLists.txt b/examples/system/dynlink/CMakeLists.txt index 5834647..aae3bb3 100644 --- a/examples/system/dynlink/CMakeLists.txt +++ b/examples/system/dynlink/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( dynlink LANGUAGES C diff --git a/examples/system/timer/CMakeLists.txt b/examples/system/timer/CMakeLists.txt index 58daf9b..328e07e 100644 --- a/examples/system/timer/CMakeLists.txt +++ b/examples/system/timer/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( timer LANGUAGES C diff --git a/examples/system/tty/CMakeLists.txt b/examples/system/tty/CMakeLists.txt index 4e0ca36..0664502 100644 --- a/examples/system/tty/CMakeLists.txt +++ b/examples/system/tty/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required(VERSION 3.20) -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS}) - set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake) -endif() - project( tty LANGUAGES C -- cgit v1.2.3 From fe42ce7f1c98947baa49427835deb5ce70470afb Mon Sep 17 00:00:00 2001 From: spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> Date: Wed, 29 Dec 2021 17:30:56 +0100 Subject: Fix CMake and CI bugs, set version number, update docs --- .github/workflows/build.yml | 4 ++-- CMakeLists.txt | 33 ++++++++++++++++++++++----------- CMakePresets.json | 9 +++++---- cpack/setup.cmake | 3 +-- cpack/welcome.txt | 3 --- doc/cmake_reference.md | 10 +++++++--- doc/installation.md | 9 ++++----- examples/sound/spustream/main.c | 2 +- libpsn00b/CMakeLists.txt | 1 - libpsn00b/build.json.template | 9 ++++++--- libpsn00b/cmake/internal_setup.cmake | 5 +++-- 11 files changed, 51 insertions(+), 37 deletions(-) delete mode 100644 cpack/welcome.txt (limited to 'doc/installation.md') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3cbefb1..a72f5d3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -116,7 +116,7 @@ jobs: - name: Update repo submodules run: | cd sdk - git submodule update --init --recursive --remote + git submodule update --init --recursive - name: Build and package PSn00bSDK run: | @@ -164,7 +164,7 @@ jobs: - name: Update repo submodules run: | cd sdk - git submodule update --init --recursive --remote + git submodule update --init --recursive - name: Build and package PSn00bSDK run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 720ca8c..6a20a0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ include(ExternalProject) project( PSn00bSDK LANGUAGES NONE - VERSION 0.1.0 + VERSION 0.18 DESCRIPTION "Open source PlayStation 1 SDK" HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk" ) @@ -39,9 +39,15 @@ set( CACHE BOOL "Skip building SDK examples (not required for installation)" ) set( - BUILD_INFO "" - CACHE STRING "Information about this build to be included in build.json" + PSN00BSDK_GIT_TAG "" + CACHE STRING "Git tag or branch name (used by CI)" ) +set( + PSN00BSDK_GIT_COMMIT "" + CACHE STRING "Git commit hash (used by CI)" +) + +string(TIMESTAMP PSN00BSDK_BUILD_DATE UTC) # Forward some important variables to mkpsxiso and to the subprojects (they are # not inherited automatically as they are not environment variables). This also @@ -50,20 +56,24 @@ set( # invoked (ExternalProject_Add() runs the subprojects' install step at build # time). set( - COMMON_ARGS + _common_args -DPSN00BSDK_TC:PATH=${PSN00BSDK_TC} -DPSN00BSDK_TARGET:STRING=${PSN00BSDK_TARGET} -DPSN00BSDK_VERSION:STRING=${PROJECT_VERSION} - -DPSN00BSDK_BUILD_INFO:STRING=${BUILD_INFO} + -DPSN00BSDK_BUILD_DATE:STRING=${PSN00BSDK_BUILD_DATE} + -DPSN00BSDK_GIT_TAG:STRING=${PSN00BSDK_GIT_TAG} + -DPSN00BSDK_GIT_COMMIT:STRING=${PSN00BSDK_GIT_COMMIT} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} ) set( - SUBPROJECT_ARGS + _sdk_args + ${_common_args} -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_INSTALL_PREFIX:PATH=${PROJECT_BINARY_DIR}/install_tree ) set( - EXAMPLES_ARGS + _examples_args + ${_common_args} -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${PROJECT_BINARY_DIR}/install_tree/${CMAKE_INSTALL_LIBDIR}/libpsn00b/cmake/sdk.cmake -DCMAKE_INSTALL_PREFIX:PATH=${PROJECT_BINARY_DIR}/examples ) @@ -77,26 +87,26 @@ endif() ExternalProject_Add( tools SOURCE_DIR ${PROJECT_SOURCE_DIR}/tools - CMAKE_CACHE_ARGS ${COMMON_ARGS} ${SUBPROJECT_ARGS} + CMAKE_CACHE_ARGS ${_sdk_args} INSTALL_DIR install_tree ) ExternalProject_Add( mkpsxiso SOURCE_DIR ${PROJECT_SOURCE_DIR}/tools/mkpsxiso - CMAKE_CACHE_ARGS ${COMMON_ARGS} ${SUBPROJECT_ARGS} + CMAKE_CACHE_ARGS ${_sdk_args} INSTALL_DIR install_tree ) ExternalProject_Add( libpsn00b SOURCE_DIR ${PROJECT_SOURCE_DIR}/libpsn00b - CMAKE_CACHE_ARGS ${COMMON_ARGS} ${SUBPROJECT_ARGS} + CMAKE_CACHE_ARGS ${_sdk_args} INSTALL_DIR install_tree #DEPENDS tools ) ExternalProject_Add( examples SOURCE_DIR ${PROJECT_SOURCE_DIR}/examples - CMAKE_CACHE_ARGS ${COMMON_ARGS} ${EXAMPLES_ARGS} + CMAKE_CACHE_ARGS ${_examples_args} INSTALL_DIR examples DEPENDS libpsn00b tools mkpsxiso EXCLUDE_FROM_ALL ${SKIP_EXAMPLES} @@ -108,6 +118,7 @@ foreach( _subdir IN ITEMS ${CMAKE_INSTALL_BINDIR} ${CMAKE_INSTALL_LIBDIR} + ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_DATADIR} ) install( diff --git a/CMakePresets.json b/CMakePresets.json index 7c9fdd3..d71c1ae 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -32,10 +32,11 @@ "generator": "Ninja", "binaryDir": "${sourceDir}/../build", "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release", - "BUNDLE_TOOLCHAIN": "ON", - "BUILD_INFO": "Built by GitHub Actions ($env{GITHUB_REF_NAME} $env{GITHUB_SHA})", - "PSN00BSDK_TARGET": "$env{GCC_TARGET}" + "CMAKE_BUILD_TYPE": "Release", + "BUNDLE_TOOLCHAIN": "ON", + "PSN00BSDK_TARGET": "$env{GCC_TARGET}", + "PSN00BSDK_GIT_TAG": "$env{GITHUB_REF_NAME}", + "PSN00BSDK_GIT_COMMIT": "$env{GITHUB_SHA}" } } ] diff --git a/cpack/setup.cmake b/cpack/setup.cmake index 57568bb..a5d71ff 100644 --- a/cpack/setup.cmake +++ b/cpack/setup.cmake @@ -21,7 +21,7 @@ set( ## Bundled components -# "Install" the toolchain and CMake (by pulling files from its their install +# "Install" the toolchain and CMake (by pulling files from their install # locations). This is only useful when building installers, as CPack will pick # up these installation rules and bundle the toolchain in the installers. # NOTE: unfortunately there is no easy way to reuse the toolchain finding logic @@ -105,7 +105,6 @@ set(CPACK_RESOURCE_FILE_README ${PROJECT_SOURCE_DIR}/README.md) set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE.md) set(CPACK_PACKAGE_ICON ${CMAKE_CURRENT_LIST_DIR}/icon.ico) set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_LIST_DIR}/description.txt) -set(CPACK_RESOURCE_FILE_WELCOME ${CMAKE_CURRENT_LIST_DIR}/welcome.txt) set(CPACK_PRE_BUILD_SCRIPTS ${CMAKE_CURRENT_LIST_DIR}/fakeroot_fix.cmake) set(CPACK_PACKAGE_INSTALL_DIRECTORY PSn00bSDK) diff --git a/cpack/welcome.txt b/cpack/welcome.txt deleted file mode 100644 index e024336..0000000 --- a/cpack/welcome.txt +++ /dev/null @@ -1,3 +0,0 @@ -This installer will set up PSn00bSDK, including prebuilt libraries, CMake scripts as well as several command-line utilities for PlayStation 1 homebrew development. - -NOTE: CMake and the GCC toolchain must be installed separately. diff --git a/doc/cmake_reference.md b/doc/cmake_reference.md index 9e134d9..3c89da3 100644 --- a/doc/cmake_reference.md +++ b/doc/cmake_reference.md @@ -207,9 +207,13 @@ the build script. ## Read-only variables -- `PSN00BSDK_VERSION` +- `PSN00BSDK_VERSION`, `PSN00BSDK_BUILD_DATE`, `PSN00BSDK_GIT_TAG`, + `PSN00BSDK_GIT_COMMIT` - The SDK's version number (`major.minor.patch`). + These variables are loaded from `lib/libpsn00b/build.json` and contain + information about the SDK's version. Note that `PSN00BSDK_GIT_TAG` and + `PSN00BSDK_GIT_COMMIT` are not populated by default when building PSn00bSDK + manually from source, so they might be empty strings. - `PSN00BSDK_TOOLS`, `PSN00BSDK_INCLUDE`, `PSN00BSDK_LDSCRIPTS` @@ -229,4 +233,4 @@ the build script. LZP archives as part of the build pipeline. ----------------------------------------- -_Last updated on 2021-11-24 by spicyjpeg_ +_Last updated on 2021-12-29 by spicyjpeg_ diff --git a/doc/installation.md b/doc/installation.md index ca3aab4..1646653 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -62,7 +62,7 @@ and installed properly. repository to download additional dependencies: ```bash - git submodule update --init --recursive --remote + git submodule update --init --recursive ``` 5. Compile the libraries, tools and examples using CMake: @@ -74,9 +74,8 @@ and installed properly. If you want to install the SDK to a custom location rather than the default one (`C:\Program Files\PSn00bSDK` or `/usr/local` depending on your OS), add - `--install-prefix ` to the first command. Add - `-DPSN00BSDK_TARGET=mipsel-none-elf` if your toolchain targets - `mipsel-none-elf` rather than `mipsel-unknown-elf`. + `--install-prefix ` to the first command. Remember to add + `-DPSN00BSDK_TARGET=mipsel-unknown-elf` if necessary. **NOTE**: Ninja is used by default to build the SDK. If you can't get it to work or don't have it installed, pass `-G "Unix Makefiles"` (or @@ -151,4 +150,4 @@ The toolchain script defines a few CMake macros to create PS1 executables, DLLs and CD images. See the [reference](cmake_reference.md) for details. ----------------------------------------- -_Last updated on 2021-12-23 by spicyjpeg_ +_Last updated on 2021-12-29 by spicyjpeg_ diff --git a/examples/sound/spustream/main.c b/examples/sound/spustream/main.c index 2032df5..e268c7d 100644 --- a/examples/sound/spustream/main.c +++ b/examples/sound/spustream/main.c @@ -349,7 +349,7 @@ void start_stream(void) { for (uint32_t i = 0; i < NUM_CHANNELS; i++) { SPU_CHANNELS[i].addr = SPU_RAM_ADDR(BUFFER_START_ADDR + BUFFER_SIZE * i); SPU_CHANNELS[i].freq = SAMPLE_RATE; - SPU_CHANNELS[i].adsr_param = 0xdfee80ff; // or 0x9fc080ff, 0xdff18087 + SPU_CHANNELS[i].adsr_param = 0x1fee80ff; // or 0x9fc080ff, 0xdff18087 } // Unmute the channels and route them for stereo output. You'll want to diff --git a/libpsn00b/CMakeLists.txt b/libpsn00b/CMakeLists.txt index 2b2e76d..829a2f7 100644 --- a/libpsn00b/CMakeLists.txt +++ b/libpsn00b/CMakeLists.txt @@ -73,7 +73,6 @@ install( # Generate build.json. This file is used to determine the SDK version after # installation and may contain additional metadata about the build. -string(TIMESTAMP PSN00BSDK_BUILD_DATE UTC) configure_file( build.json.template build.json ESCAPE_QUOTES diff --git a/libpsn00b/build.json.template b/libpsn00b/build.json.template index 666bb43..374b22a 100644 --- a/libpsn00b/build.json.template +++ b/libpsn00b/build.json.template @@ -1,5 +1,8 @@ { - "version": "${PSN00BSDK_VERSION}", - "build_date": "${PSN00BSDK_BUILD_DATE}", - "build_info": "${PSN00BSDK_BUILD_INFO}" + "version": "${PSN00BSDK_VERSION}", + "build_date": "${PSN00BSDK_BUILD_DATE}", + "git_tag": "${PSN00BSDK_GIT_TAG}", + "git_commit": "${PSN00BSDK_GIT_COMMIT}", + "cmake_version": "${CMAKE_VERSION}", + "host_system": "${CMAKE_HOST_SYSTEM_NAME}" } diff --git a/libpsn00b/cmake/internal_setup.cmake b/libpsn00b/cmake/internal_setup.cmake index 1d63e92..7d6bfdd 100644 --- a/libpsn00b/cmake/internal_setup.cmake +++ b/libpsn00b/cmake/internal_setup.cmake @@ -7,13 +7,14 @@ cmake_minimum_required(VERSION 3.20) include(GNUInstallDirs) -# Fetch the SDK version number from build.json. +# Fetch SDK version information from build.json. if(NOT DEFINED PSN00BSDK_VERSION) file(READ ${CMAKE_CURRENT_LIST_DIR}/../build.json _json) string(JSON PSN00BSDK_VERSION GET ${_json} version) string(JSON PSN00BSDK_BUILD_DATE GET ${_json} build_date) - string(JSON PSN00BSDK_BUILD_INFO GET ${_json} build_info) + string(JSON PSN00BSDK_GIT_TAG GET ${_json} git_tag) + string(JSON PSN00BSDK_GIT_COMMIT GET ${_json} git_commit) endif() ## Settings (can be overridden by projects) -- cgit v1.2.3