aboutsummaryrefslogtreecommitdiff
path: root/template
diff options
context:
space:
mode:
Diffstat (limited to 'template')
-rw-r--r--template/CMakeLists.txt28
-rw-r--r--template/iso.xml23
-rw-r--r--template/makefile69
3 files changed, 43 insertions, 77 deletions
diff --git a/template/CMakeLists.txt b/template/CMakeLists.txt
new file mode 100644
index 0000000..c2d0d9d
--- /dev/null
+++ b/template/CMakeLists.txt
@@ -0,0 +1,28 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+# CMAKE_TOOLCHAIN_FILE must be set to point to cmake/sdk.cmake in the PSn00bSDK
+# installation directory *before* calling project(). You don't have to hardcode
+# the path in your CMakeLists.txt as you can set it from the command line when
+# configuring (-DCMAKE_TOOLCHAIN_FILE=...) or using CMake presets.
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ PSn00bSDK-template
+ LANGUAGES C CXX ASM
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK template"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+psn00bsdk_add_executable(template STATIC main.c)
+psn00bsdk_add_cd_image(
+ iso # Target name
+ template # Output file name (= template.bin + template.cue)
+ iso.xml # Path to config file
+ DEPENDS template
+)
diff --git a/template/iso.xml b/template/iso.xml
index ba2b29d..477c636 100644
--- a/template/iso.xml
+++ b/template/iso.xml
@@ -1,23 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
+<!--
+ This file is processed by CMake and used by mkpsxiso to build the CD image.
+
+ NOTE: all paths are relative to the build directory; if you want to include
+ a file from the source tree, you'll have to prepend its path with
+ ${PROJECT_SOURCE_DIR}.
+-->
<iso_project
- image_name="build/template.bin"
- cue_sheet="build/template.cue"
+ image_name="${CD_IMAGE_NAME}.bin"
+ cue_sheet="${CD_IMAGE_NAME}.cue"
>
<track type="data">
<identifiers
system ="PLAYSTATION"
- volume ="PSN00BSDK"
- volume_set ="PSN00BSDK"
+ volume ="PSN00BSDK_TEMPLATE"
+ volume_set ="PSN00BSDK_TEMPLATE"
publisher ="MEIDOTEK"
- data_preparer ="PSN00BSDK BUILD SCRIPT"
+ data_preparer ="PSN00BSDK ${PSN00BSDK_VERSION}"
application ="PLAYSTATION"
copyright ="README.TXT;1"
/>
<directory_tree>
- <file name="SYSTEM.CNF" type="data" source="system.cnf" />
- <file name="TEMPLATE.EXE" type="data" source="build/template.exe" />
- <file name="TEMPLATE.MAP" type="data" source="build/template.map" />
+ <file name="SYSTEM.CNF" type="data" source="${PROJECT_SOURCE_DIR}/system.cnf" />
+ <file name="TEMPLATE.EXE" type="data" source="template.exe" />
+ <file name="TEMPLATE.MAP" type="data" source="template.map" />
<dummy sectors="1024"/>
</directory_tree>
diff --git a/template/makefile b/template/makefile
deleted file mode 100644
index 707a8d7..0000000
--- a/template/makefile
+++ /dev/null
@@ -1,69 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-# You can edit these here or pass them as environment variables.
-#PREFIX =
-#GCC_VERSION =
-#PSN00BSDK_TC =
-#PSN00BSDK_LIBS =
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = template
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-all: iso
-#all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build