mirror of https://github.com/AxioDL/metaforce.git
Use bintoc_compress; reduce URDE/HECL binary sizes
This commit is contained in:
parent
b0b663f71f
commit
316128b7af
|
@ -128,6 +128,11 @@ else()
|
||||||
if (HAS_NO_PLT)
|
if (HAS_NO_PLT)
|
||||||
add_compile_options(-fno-plt)
|
add_compile_options(-fno-plt)
|
||||||
endif()
|
endif()
|
||||||
|
check_cxx_compiler_flag(-fno-asynchronous-unwind-tables HAS_NO_ASYNC_UNWIND_TABLES)
|
||||||
|
if (HAS_NO_ASYNC_UNWIND_TABLES)
|
||||||
|
# Binary size reduction
|
||||||
|
add_compile_options(-fno-asynchronous-unwind-tables)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(URDE_MSAN)
|
if(URDE_MSAN)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||||
|
@ -180,7 +185,7 @@ endif()
|
||||||
if(USE_LD_LLD)
|
if(USE_LD_LLD)
|
||||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=lld -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
|
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=lld -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
|
||||||
if("${LD_VERSION}" MATCHES "LLD")
|
if("${LD_VERSION}" MATCHES "LLD")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld -Wl,--build-id=uuid")
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld")
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld")
|
||||||
if(USE_LTO)
|
if(USE_LTO)
|
||||||
add_compile_options(-flto=thin)
|
add_compile_options(-flto=thin)
|
||||||
|
@ -228,7 +233,7 @@ add_subdirectory(nod)
|
||||||
|
|
||||||
set(HECL_DLPACKAGE ${URDE_DLPACKAGE})
|
set(HECL_DLPACKAGE ${URDE_DLPACKAGE})
|
||||||
|
|
||||||
set(DATA_SPEC_LIBS RetroDataSpec)
|
set(DATA_SPEC_LIBS RetroDataSpec AssetNameMap)
|
||||||
set(HECL_DATASPEC_DECLS
|
set(HECL_DATASPEC_DECLS
|
||||||
"/* RetroCommon specs */
|
"/* RetroCommon specs */
|
||||||
namespace DataSpec
|
namespace DataSpec
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
#include "AssetNameMap.hpp"
|
#include "AssetNameMap.hpp"
|
||||||
|
#include "athena/Compression.hpp"
|
||||||
#include "athena/MemoryReader.hpp"
|
#include "athena/MemoryReader.hpp"
|
||||||
|
|
||||||
extern "C" const uint8_t ASSET_NAME_MP32[];
|
extern "C" const uint8_t ASSET_NAME_MP32[];
|
||||||
extern "C" const size_t ASSET_NAME_MP32_SZ;
|
extern "C" const size_t ASSET_NAME_MP32_SZ;
|
||||||
|
extern "C" const size_t ASSET_NAME_MP32_DECOMPRESSED_SZ;
|
||||||
extern "C" const uint8_t ASSET_NAME_MP64[];
|
extern "C" const uint8_t ASSET_NAME_MP64[];
|
||||||
extern "C" const size_t ASSET_NAME_MP64_SZ;
|
extern "C" const size_t ASSET_NAME_MP64_SZ;
|
||||||
|
extern "C" const size_t ASSET_NAME_MP64_DECOMPRESSED_SZ;
|
||||||
|
|
||||||
namespace DataSpec::AssetNameMap {
|
namespace DataSpec::AssetNameMap {
|
||||||
logvisor::Module Log("AssetNameMap");
|
logvisor::Module Log("AssetNameMap");
|
||||||
|
@ -53,14 +56,28 @@ void InitAssetNameMap() {
|
||||||
Log.report(logvisor::Info, fmt("Initializing asset name database..."));
|
Log.report(logvisor::Info, fmt("Initializing asset name database..."));
|
||||||
|
|
||||||
/* First load the 32bit map for MP1/2 */
|
/* First load the 32bit map for MP1/2 */
|
||||||
{
|
if (ASSET_NAME_MP32_DECOMPRESSED_SZ) {
|
||||||
athena::io::MemoryReader ar(ASSET_NAME_MP32, ASSET_NAME_MP32_SZ);
|
auto decompressed = new uint8_t[ASSET_NAME_MP32_DECOMPRESSED_SZ];
|
||||||
|
athena::io::Compression::decompressZlib(ASSET_NAME_MP32, ASSET_NAME_MP32_SZ, decompressed,
|
||||||
|
ASSET_NAME_MP32_DECOMPRESSED_SZ);
|
||||||
|
athena::io::MemoryReader ar(decompressed, ASSET_NAME_MP32_DECOMPRESSED_SZ);
|
||||||
LoadAssetMap(ar);
|
LoadAssetMap(ar);
|
||||||
|
delete[](decompressed);
|
||||||
|
} else {
|
||||||
|
Log.report(logvisor::Warning,
|
||||||
|
fmt(_SYS_STR("AssetNameMap32 unavailable; Assets will not have proper filenames for most files.")));
|
||||||
}
|
}
|
||||||
/* Now load the 64bit map for MP3 */
|
/* Now load the 64bit map for MP3 */
|
||||||
{
|
if (ASSET_NAME_MP64_DECOMPRESSED_SZ) {
|
||||||
athena::io::MemoryReader ar(ASSET_NAME_MP64, ASSET_NAME_MP64_SZ);
|
auto decompressed = new uint8_t[ASSET_NAME_MP64_DECOMPRESSED_SZ];
|
||||||
|
athena::io::Compression::decompressZlib(ASSET_NAME_MP64, ASSET_NAME_MP64_SZ, decompressed,
|
||||||
|
ASSET_NAME_MP64_DECOMPRESSED_SZ);
|
||||||
|
athena::io::MemoryReader ar(decompressed, ASSET_NAME_MP64_DECOMPRESSED_SZ);
|
||||||
LoadAssetMap(ar);
|
LoadAssetMap(ar);
|
||||||
|
delete[](decompressed);
|
||||||
|
} else {
|
||||||
|
Log.report(logvisor::Warning,
|
||||||
|
fmt(_SYS_STR("AssetNameMap64 unavailable; Assets will not have proper filenames for most files.")));
|
||||||
}
|
}
|
||||||
g_AssetNameMapInit = true;
|
g_AssetNameMapInit = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
extern "C" const uint8_t ASSET_NAME_MP32[] = {};
|
||||||
|
extern "C" const size_t ASSET_NAME_MP32_SZ = 0;
|
||||||
|
extern "C" const size_t ASSET_NAME_MP32_DECOMPRESSED_SZ = 0;
|
||||||
|
extern "C" const uint8_t ASSET_NAME_MP64[] = {};
|
||||||
|
extern "C" const size_t ASSET_NAME_MP64_SZ = 0;
|
||||||
|
extern "C" const size_t ASSET_NAME_MP64_DECOMPRESSED_SZ = 0;
|
|
@ -42,11 +42,11 @@ bintoc(RetroMasterShader.cpp Blender/RetroMasterShader.py RETRO_MASTER_SHADER)
|
||||||
# Download asset name databases
|
# Download asset name databases
|
||||||
add_custom_command(OUTPUT AssetNameMap32.bin COMMAND ${CMAKE_COMMAND} ARGS -P
|
add_custom_command(OUTPUT AssetNameMap32.bin COMMAND ${CMAKE_COMMAND} ARGS -P
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/AssetMap32Download.cmake)
|
${CMAKE_CURRENT_SOURCE_DIR}/AssetMap32Download.cmake)
|
||||||
bintoc(AssetNameMap32.cpp ${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap32.bin ASSET_NAME_MP32)
|
bintoc_compress(AssetNameMap32.cpp ${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap32.bin ASSET_NAME_MP32)
|
||||||
|
|
||||||
add_custom_command(OUTPUT AssetNameMap64.bin COMMAND ${CMAKE_COMMAND} ARGS -P
|
add_custom_command(OUTPUT AssetNameMap64.bin COMMAND ${CMAKE_COMMAND} ARGS -P
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/AssetMap64Download.cmake)
|
${CMAKE_CURRENT_SOURCE_DIR}/AssetMap64Download.cmake)
|
||||||
bintoc(AssetNameMap64.cpp ${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap64.bin ASSET_NAME_MP64)
|
bintoc_compress(AssetNameMap64.cpp ${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap64.bin ASSET_NAME_MP64)
|
||||||
|
|
||||||
# Each game's DataSpec implementation
|
# Each game's DataSpec implementation
|
||||||
add_library(RetroDataSpec
|
add_library(RetroDataSpec
|
||||||
|
@ -65,9 +65,12 @@ add_library(RetroDataSpec
|
||||||
Blender/RetroMasterShader.py
|
Blender/RetroMasterShader.py
|
||||||
AssetNameMap.hpp
|
AssetNameMap.hpp
|
||||||
AssetNameMap.cpp
|
AssetNameMap.cpp
|
||||||
AssetNameMap32.bin AssetNameMap32.cpp
|
|
||||||
AssetNameMap64.bin AssetNameMap64.cpp
|
|
||||||
RetroMasterShader.cpp)
|
RetroMasterShader.cpp)
|
||||||
|
add_library(AssetNameMap
|
||||||
|
AssetNameMap32.bin AssetNameMap32.cpp
|
||||||
|
AssetNameMap64.bin AssetNameMap64.cpp)
|
||||||
|
add_library(AssetNameMapNull
|
||||||
|
AssetNameMapNull.cpp)
|
||||||
|
|
||||||
get_target_property(HECL_INCLUDES hecl-full INCLUDE_DIRECTORIES)
|
get_target_property(HECL_INCLUDES hecl-full INCLUDE_DIRECTORIES)
|
||||||
target_include_directories(RetroDataSpec PUBLIC ${LIBPNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}
|
target_include_directories(RetroDataSpec PUBLIC ${LIBPNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}
|
||||||
|
|
|
@ -132,7 +132,7 @@ endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
set(RUNTIME_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
set(RUNTIME_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
set(RUNTIME_LIBRARIES ${HECL_APPLICATION_REPS_TARGETS_LIST} RetroDataSpec NESEmulator
|
set(RUNTIME_LIBRARIES ${HECL_APPLICATION_REPS_TARGETS_LIST} RetroDataSpec AssetNameMapNull NESEmulator
|
||||||
libjpeg-turbo jbus kabufuda discord-rpc logvisor)
|
libjpeg-turbo jbus kabufuda discord-rpc logvisor)
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
||||||
Subproject commit 57bfd8cb3fefb3e57caddef46b636d762ec642a1
|
Subproject commit 7bd95f9abe8b315a4aeba03d88b83f7b0a5e0ef1
|
Loading…
Reference in New Issue