mirror of
https://github.com/libretro/parallel-ps2.git
synced 2026-11-10 17:26:34 -10:00
CMake: generate GameDatabaseBuiltin.cpp with cmake -P instead of sh
The gamedb custom command invoked tools/gen_gamedb_builtin.sh via sh,
which does not exist on the MSVC Windows runner (libretro-build-windows-x64,
MSB8066 / exit code 9009). Add tools/gen_gamedb_builtin.cmake, a cmake -P
twin of the shell script (file(READ HEX) + regex, no {n} quantifier or
string(REPEAT) so CMake 3.12 still works), and point the custom command at
it. Output is byte-identical to the .sh generator. The static Makefile rule
still uses the shell script and is unchanged.
This commit is contained in:
1 parent
1dbdc62be3
commit
8254b70ec6
2 files changed
+45
-6
No files matched your search
@@ -1,14 +1,16 @@
|
||||
# All flags, libraries, etc, that are shared between PCSX2 compilation files
|
||||
# GameDatabaseBuiltin.cpp is generated from the shipped GameIndex.yaml at
|
||||
# build time (tools/gen_gamedb_builtin.sh, POSIX shell + od + awk only),
|
||||
# mirroring the static-Makefile rule.
|
||||
# build time. The static Makefile uses tools/gen_gamedb_builtin.sh (POSIX
|
||||
# shell + od + awk); CMake uses the byte-identical cmake -P twin so MSVC
|
||||
# runners without a shell can build too.
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/GameDatabaseBuiltin.cpp
|
||||
COMMAND sh ${CMAKE_SOURCE_DIR}/tools/gen_gamedb_builtin.sh
|
||||
${CMAKE_SOURCE_DIR}/bin/resources/GameIndex.yaml
|
||||
${CMAKE_CURRENT_BINARY_DIR}/GameDatabaseBuiltin.cpp
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DYAML=${CMAKE_SOURCE_DIR}/bin/resources/GameIndex.yaml
|
||||
-DOUT=${CMAKE_CURRENT_BINARY_DIR}/GameDatabaseBuiltin.cpp
|
||||
-P ${CMAKE_SOURCE_DIR}/tools/gen_gamedb_builtin.cmake
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/bin/resources/GameIndex.yaml
|
||||
${CMAKE_SOURCE_DIR}/tools/gen_gamedb_builtin.sh
|
||||
${CMAKE_SOURCE_DIR}/tools/gen_gamedb_builtin.cmake
|
||||
COMMENT "Generating GameDatabaseBuiltin.cpp from GameIndex.yaml"
|
||||
VERBATIM)
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
# Generate GameDatabaseBuiltin.cpp from bin/resources/GameIndex.yaml.
|
||||
# CMake-script twin of tools/gen_gamedb_builtin.sh for hosts without a
|
||||
# POSIX shell (MSVC runners). Output is byte-identical to the .sh script.
|
||||
# Usage: cmake -DYAML=<in> -DOUT=<out.cpp> -P gen_gamedb_builtin.cmake
|
||||
if(NOT YAML OR NOT OUT)
|
||||
message(FATAL_ERROR "gen_gamedb_builtin.cmake: -DYAML=<in> -DOUT=<out.cpp> required")
|
||||
endif()
|
||||
file(READ "${YAML}" HEX HEX)
|
||||
# "0x..," per byte, 20 bytes per line (matches the awk layout).
|
||||
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," HEX "${HEX}")
|
||||
# CMake regex has no {n} quantifier: spell out 20 repetitions.
|
||||
set(_LINE "")
|
||||
foreach(_i RANGE 1 20)
|
||||
string(APPEND _LINE "0x[0-9a-f][0-9a-f],")
|
||||
endforeach()
|
||||
string(REGEX REPLACE "(${_LINE})" "\\1\n" HEX "${HEX}")
|
||||
if(NOT HEX MATCHES "\n$")
|
||||
string(APPEND HEX "\n")
|
||||
endif()
|
||||
file(WRITE "${OUT}.tmp"
|
||||
"// Auto-generated from bin/resources/GameIndex.yaml. Do not edit by hand.
|
||||
// Generated at build time by tools/gen_gamedb_builtin.sh.
|
||||
//
|
||||
// Embeds the PCSX2 game-compatibility database into the core so it works
|
||||
// without an external <systemdir>/resources/GameIndex.yaml.
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
extern const unsigned char g_gameDatabaseBuiltin[];
|
||||
extern const size_t g_gameDatabaseBuiltinSize;
|
||||
|
||||
const unsigned char g_gameDatabaseBuiltin[] = {
|
||||
${HEX}};
|
||||
|
||||
const size_t g_gameDatabaseBuiltinSize = sizeof(g_gameDatabaseBuiltin);
|
||||
")
|
||||
file(RENAME "${OUT}.tmp" "${OUT}")
|
||||
Reference in new issue
Block a user