diff options
| author | spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> | 2022-02-20 20:55:27 +0100 |
|---|---|---|
| committer | spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> | 2022-02-20 23:10:19 +0100 |
| commit | a2da2debfde1d44338d203aa4d56e485c4bb16ae (patch) | |
| tree | bcce13d2c63acfe4d9b1d72c1887130b29bb098f /libpsn00b | |
| parent | 72db767f5a5bdb958bb11bcb6fe6b9b332a2b195 (diff) | |
| download | psn00bsdk-a2da2debfde1d44338d203aa4d56e485c4bb16ae.tar.gz | |
Add psn00bsdk_target_incbin() CMake function
Diffstat (limited to 'libpsn00b')
| -rw-r--r-- | libpsn00b/CMakeLists.txt | 13 | ||||
| -rw-r--r-- | libpsn00b/build.json.template | 8 | ||||
| -rw-r--r-- | libpsn00b/cmake/internal_setup.cmake | 69 |
3 files changed, 75 insertions, 15 deletions
diff --git a/libpsn00b/CMakeLists.txt b/libpsn00b/CMakeLists.txt index 829a2f7..f9c4f9d 100644 --- a/libpsn00b/CMakeLists.txt +++ b/libpsn00b/CMakeLists.txt @@ -73,8 +73,17 @@ install( # Generate build.json. This file is used to determine the SDK version after # installation and may contain additional metadata about the build. -configure_file( - build.json.template build.json +file( + CONFIGURE + OUTPUT build.json + CONTENT [[{ + "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}" +}]] ESCAPE_QUOTES NEWLINE_STYLE LF ) diff --git a/libpsn00b/build.json.template b/libpsn00b/build.json.template deleted file mode 100644 index 374b22a..0000000 --- a/libpsn00b/build.json.template +++ /dev/null @@ -1,8 +0,0 @@ -{ - "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 7d6bfdd..8fb6482 100644 --- a/libpsn00b/cmake/internal_setup.cmake +++ b/libpsn00b/cmake/internal_setup.cmake @@ -26,7 +26,19 @@ set(PSN00BSDK_SYMBOL_MAP_SUFFIX ".map") ## SDK libraries # DON'T CHANGE THE ORDER or you'll break the libraries' internal dependencies. -set(PSN00BSDK_LIBRARIES psxgpu psxgte psxspu psxcd psxsio psxetc psxapi lzp c) +set( + PSN00BSDK_LIBRARIES + psxgpu + psxgte + psxspu + psxcd + #psxpress + psxsio + psxetc + psxapi + lzp + c +) include(${CMAKE_CURRENT_LIST_DIR}/libpsn00b.cmake OPTIONAL) include(${CMAKE_CURRENT_LIST_DIR}/flags.cmake) @@ -166,12 +178,15 @@ function(psn00bsdk_add_cd_image name image_name config_file) message(FATAL_ERROR "Failed to locate mkpsxiso. If mkpsxiso wasn't installed alongside the SDK, check your PATH environment variable.") endif() - set(CD_IMAGE_NAME ${image_name}) - configure_file(${config_file} _gen_${config_file}) + cmake_path(HASH config_file _hash) + + set(CD_IMAGE_NAME ${image_name}) + set(CD_CONFIG_FILE cd_image_${_hash}.xml) + configure_file(${config_file} ${CD_CONFIG_FILE}) add_custom_target( ${name} ALL - COMMAND ${MKPSXISO} -y -q _gen_${config_file} + COMMAND ${MKPSXISO} -y -q ${CD_CONFIG_FILE} BYPRODUCTS ${image_name}.bin ${image_name}.cue COMMENT "Building CD image ${image_name}" ${ARGN} @@ -180,4 +195,48 @@ endfunction() ## Helper functions for assets -# TODO: add them +# psn00bsdk_target_incbin( +# <existing target name> <PRIVATE|PUBLIC|INTERFACE> +# <symbol name> +# <path to binary file> +# ) +function(psn00bsdk_target_incbin name type symbol_name path) + string(MAKE_C_IDENTIFIER ${symbol_name} _id) + cmake_path(ABSOLUTE_PATH path OUTPUT_VARIABLE _path) + + # Generate an assembly source file that includes the binary file and add it + # to the target's sources. The file is also added as a depedency to ensure + # CMake builds it before the target (if it's not a static file). + set(_asm_file ${PROJECT_BINARY_DIR}/incbin_${name}_${_id}.s) + file( + CONFIGURE + OUTPUT ${_asm_file} + CONTENT [[ +.section .data.${_id} +.balign 4 + +.global ${_id} +.type ${_id}, @object +${_id}: + .incbin "${_path}" + +.local ${_id}_end +${_id}_end: + +.balign 4 + +.global ${_id}_size +.type ${_id}_size, @object +${_id}_size: + .int (${_id}_end - ${_id}) + +.size ${_id}, (${_id}_end - ${_id}) +.size ${_id}_size, 4 +]] + ESCAPE_QUOTES + NEWLINE_STYLE LF + ) + + target_sources(${name} ${type} ${_asm_file}) + set_source_files_properties(${_asm_file} PROPERTIES OBJECT_DEPENDS ${_path}) +endfunction() |
