diff options
| author | John "Lameguy" Wilbert Villamor <lameguy64@gmail.com> | 2022-03-25 09:22:20 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-25 09:22:20 +0800 |
| commit | 975e614b3c840e2f717adac1d1cb9cee4e5e561b (patch) | |
| tree | 6584ce5b0dbe27a466c95c81fac61b0d90f627bd /libpsn00b/cmake | |
| parent | 05d44488bd5587786f4bd0286fc0f555c79aa46a (diff) | |
| parent | 45168ae43e29aa5930ee5a206475ae836078915f (diff) | |
| download | psn00bsdk-975e614b3c840e2f717adac1d1cb9cee4e5e561b.tar.gz | |
Merge pull request #46 from spicyjpeg/psxmdec
Critical ldscript fixes, initial MDEC support and CI updates
Diffstat (limited to 'libpsn00b/cmake')
| -rw-r--r-- | libpsn00b/cmake/flags.cmake | 11 | ||||
| -rw-r--r-- | libpsn00b/cmake/internal_setup.cmake | 93 |
2 files changed, 92 insertions, 12 deletions
diff --git a/libpsn00b/cmake/flags.cmake b/libpsn00b/cmake/flags.cmake index 249c5b4..e31773f 100644 --- a/libpsn00b/cmake/flags.cmake +++ b/libpsn00b/cmake/flags.cmake @@ -5,10 +5,10 @@ # directories and compiler flags when a target is linked against them. The # following targets are currently defined: # - psn00bsdk_common -# - psn00bsdk_object_lib (same as psn00bsdk_common) # - psn00bsdk_static_exe # - psn00bsdk_dynamic_exe # - psn00bsdk_static_lib +# - psn00bsdk_object_lib (same as psn00bsdk_static_lib) # - psn00bsdk_shared_lib # - psn00bsdk_module_lib (same as psn00bsdk_shared_lib) # @@ -21,12 +21,7 @@ add_library(psn00bsdk_common INTERFACE) foreach( _target IN ITEMS - object_lib - static_exe - dynamic_exe - static_lib - shared_lib - module_lib + static_exe dynamic_exe static_lib object_lib shared_lib module_lib ) add_library (psn00bsdk_${_target} INTERFACE) target_link_libraries(psn00bsdk_${_target} INTERFACE psn00bsdk_common) @@ -128,6 +123,8 @@ target_compile_options( -Wa,--strip-local-absolute ) +target_link_libraries(psn00bsdk_object_lib INTERFACE psn00bsdk_static_lib) + # Options for dynamically-loaded libraries: # - Position-independent code enabled # - GP-relative addressing disabled (incompatible with ABI calls) diff --git a/libpsn00b/cmake/internal_setup.cmake b/libpsn00b/cmake/internal_setup.cmake index 7d6bfdd..d293127 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 ${CD_CONFIG_FILE} BYPRODUCTS ${image_name}.bin ${image_name}.cue COMMENT "Building CD image ${image_name}" ${ARGN} @@ -180,4 +195,72 @@ endfunction() ## Helper functions for assets -# TODO: add them +# psn00bsdk_target_incbin_a( +# <existing target name> <PRIVATE|PUBLIC|INTERFACE> +# <data symbol name> +# <size symbol name> +# <path to binary file> +# <linker section name> +# <alignment> +# ) +function(psn00bsdk_target_incbin_a name type symbol_name size_name path section align) + string(MAKE_C_IDENTIFIER ${symbol_name} _id) + string(MAKE_C_IDENTIFIER ${size_name} _size) + 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 ${section} +.balign ${align} + +.global ${_id} +.type ${_id}, @object +${_id}: + .incbin "${_path}" + +.local ${_id}_end +${_id}_end: + +.balign ${align} +.balign 4 + +.global ${_size} +.type ${_size}, @object +${_size}: + .int (${_id}_end - ${_id}) + +.size ${_id}, (${_id}_end - ${_id}) +.size ${_size}, 4 +]] + ESCAPE_QUOTES + NEWLINE_STYLE LF + ) + + target_sources(${name} ${type} ${_asm_file}) + set_source_files_properties(${_asm_file} PROPERTIES OBJECT_DEPENDS ${_path}) +endfunction() + +# 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) + + psn00bsdk_target_incbin_a( + ${name} + ${type} + ${_id} + ${_id}_size + ${path} + .data.${_id} + 4 + ) +endfunction() |
