mirror of
https://github.com/hedge-dev/XenonRecomp.git
synced 2025-04-19 10:51:18 +00:00
Update bin2h to allow changing the output array type
This commit is contained in:
parent
6e49be2702
commit
6810be7315
@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.8)
|
||||
|
||||
project("PowerRecomp")
|
||||
|
||||
BIN2H(SOURCE_FILE ${POWERUTILS_ROOT}/ppc_context.h HEADER_FILE "generated/ppc_context.gen.h" VARIABLE_NAME "gPPCContextText")
|
||||
BIN2H(SOURCE_FILE ${POWERUTILS_ROOT}/ppc_context.h HEADER_FILE "generated/ppc_context.gen.h" ARRAY_TYPE "char" VARIABLE_NAME "g_PPCContextText")
|
||||
|
||||
add_executable(PowerRecomp "main.cpp" "pch.h" "recompiler.cpp" "recompiler.h" "test_recompiler.cpp" "test_recompiler.h" "recompiler_config.h" "recompiler_config.cpp")
|
||||
target_precompile_headers(PowerRecomp PUBLIC "pch.h")
|
||||
|
@ -2393,7 +2393,7 @@ void Recompiler::Recompile()
|
||||
println("#pragma once");
|
||||
|
||||
println("#include \"ppc_config.h\"\n");
|
||||
println("{}", std::string_view{gPPCContextText, gPPCContextText_SIZE});
|
||||
println("{}", std::string_view{g_PPCContextText, g_PPCContextText_size});
|
||||
|
||||
SaveCurrentOutData("ppc_context.h");
|
||||
}
|
||||
|
@ -37,16 +37,17 @@ endfunction()
|
||||
# VARIABLE_NAME - The name of the variable for the byte array. The string "_SIZE" will be append
|
||||
# to this name and will be used a variable name for size variable.
|
||||
# HEADER_FILE - The path of header file.
|
||||
# ARRAY_TYPE - The type of each element of the array in the header file.
|
||||
# APPEND - If specified appends to the header file instead of overwriting it
|
||||
# NULL_TERMINATE - If specified a null byte(zero) will be append to the byte array. This will be
|
||||
# useful if the source file is a text file and we want to use the file contents
|
||||
# as string. But the size variable holds size of the byte array without this
|
||||
# null byte.
|
||||
# Usage:
|
||||
# bin2h(SOURCE_FILE "Logo.png" HEADER_FILE "Logo.h" VARIABLE_NAME "LOGO_PNG")
|
||||
# bin2h(SOURCE_FILE "Logo.png" HEADER_FILE "Logo.h" ARRAY_TYPE "char" VARIABLE_NAME "LOGO_PNG")
|
||||
function(BIN2H)
|
||||
set(options APPEND NULL_TERMINATE)
|
||||
set(oneValueArgs SOURCE_FILE VARIABLE_NAME HEADER_FILE)
|
||||
set(oneValueArgs SOURCE_FILE VARIABLE_NAME HEADER_FILE ARRAY_TYPE)
|
||||
cmake_parse_arguments(BIN2H "${options}" "${oneValueArgs}" "" ${ARGN})
|
||||
|
||||
# reads source file contents as hex string
|
||||
@ -71,8 +72,8 @@ function(BIN2H)
|
||||
string(MAKE_C_IDENTIFIER "${BIN2H_VARIABLE_NAME}" BIN2H_VARIABLE_NAME)
|
||||
|
||||
# declares byte array and the length variables
|
||||
set(arrayDefinition "const char ${BIN2H_VARIABLE_NAME}[] = { ${arrayValues} };")
|
||||
set(arraySizeDefinition "const size_t ${BIN2H_VARIABLE_NAME}_SIZE = ${arraySize};")
|
||||
set(arrayDefinition "const ${BIN2H_ARRAY_TYPE} ${BIN2H_VARIABLE_NAME}[] = { ${arrayValues} };")
|
||||
set(arraySizeDefinition "const size_t ${BIN2H_VARIABLE_NAME}_size = ${arraySize};")
|
||||
|
||||
set(declarations "${arrayDefinition}\n\n${arraySizeDefinition}\n\n")
|
||||
if(BIN2H_APPEND)
|
||||
@ -80,4 +81,4 @@ function(BIN2H)
|
||||
else()
|
||||
file(WRITE ${BIN2H_HEADER_FILE} "${declarations}")
|
||||
endif()
|
||||
endfunction()
|
||||
endfunction()
|
||||
|
Loading…
x
Reference in New Issue
Block a user