From 8b6a76055ca426c494e16042e21f5e19b870b2ac Mon Sep 17 00:00:00 2001 From: spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> Date: Thu, 11 Nov 2021 00:37:10 +0100 Subject: Cleaned up pads example, added CMake script for cartrom --- examples/lowlevel/cartrom/CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++ examples/lowlevel/cartrom/makefile | 14 ------------- 2 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 examples/lowlevel/cartrom/CMakeLists.txt delete mode 100644 examples/lowlevel/cartrom/makefile (limited to 'examples/lowlevel') diff --git a/examples/lowlevel/cartrom/CMakeLists.txt b/examples/lowlevel/cartrom/CMakeLists.txt new file mode 100644 index 0000000..3e807a3 --- /dev/null +++ b/examples/lowlevel/cartrom/CMakeLists.txt @@ -0,0 +1,36 @@ +# PSn00bSDK example CMake script +# (C) 2021 spicyjpeg - MPL licensed + +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 + VERSION 1.0.0 + DESCRIPTION "PSn00bSDK expansion port ROM example" + HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk" +) + +file(GLOB _sources *.c *.s) + +# This example only uses the toolchain (without the rest of the SDK), so the +# executable has to be created manually and converted into raw binary format +# (for testing on emulators or flashing to a cheat cartridge). +add_executable (cartrom ${_sources}) +target_link_libraries(cartrom psn00bsdk_static_exe) +set_target_properties(cartrom PROPERTIES PREFIX "" SUFFIX ".elf") +target_link_options (cartrom PRIVATE -T${PROJECT_SOURCE_DIR}/rom.ld) + +target_include_directories(cartrom PRIVATE ${PROJECT_SOURCE_DIR}) + +add_custom_command( + TARGET cartrom POST_BUILD + COMMAND ${CMAKE_OBJCOPY} -O binary cartrom.elf cartrom.bin + BYPRODUCTS cartrom.bin +) + +install(FILES ${PROJECT_BINARY_DIR}/cartrom.bin TYPE BIN) diff --git a/examples/lowlevel/cartrom/makefile b/examples/lowlevel/cartrom/makefile deleted file mode 100644 index 2434685..0000000 --- a/examples/lowlevel/cartrom/makefile +++ /dev/null @@ -1,14 +0,0 @@ -PREFIX = mipsel-unknown-elf- - -CC = $(PREFIX)gcc -AS = $(PREFIX)as -LD = $(PREFIX)ld - -all: rom.o - $(LD) --oformat binary -T rom.ld -o cartrom.rom rom.o - -%.o: %.s - $(AS) -msoft-float --warn $< -o $@ - -clean: - rm -f rom.o cartrom.rom \ No newline at end of file -- cgit v1.2.3