fxsdk: handle parentheses in paths for fxgxa

Quotes are still impossible because CMake is unredeemable in that
regard.
This commit is contained in:
Lephenixnoir 2022-11-25 10:56:59 +01:00
parent 8c966821e8
commit e31d053a08
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
3 changed files with 18 additions and 7 deletions

View file

@ -0,0 +1,7 @@
# Who doesn't love to deal with escaping?!
function(shell_escape _str _out)
string(REPLACE "'" "\\'" _str "${_str}")
string(REPLACE "(" "\\(" _str "${_str}")
string(REPLACE ")" "\\)" _str "${_str}")
set("${_out}" "${_str}" PARENT_SCOPE)
endfunction()

View file

@ -1,3 +1,5 @@
include(FxsdkUtils)
function(generate_g1a)
cmake_parse_arguments(G1A "" "TARGET;OUTPUT;NAME;INTERNAL;VERSION;DATE;ICON" "" ${ARGN})
@ -16,6 +18,7 @@ function(generate_g1a)
if(DEFINED G1A_OUTPUT)
get_filename_component(G1A_OUTPUT "${G1A_OUTPUT}" ABSOLUTE
BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
shell_escape("${G1A_OUTPUT}" G1A_OUTPUT)
else()
set(G1A_OUTPUT "${G1A_TARGET}.g1a")
endif()
@ -32,7 +35,8 @@ function(generate_g1a)
if(DEFINED G1A_ICON)
get_filename_component(G1A_ICON "${G1A_ICON}" ABSOLUTE
BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
list(APPEND FXGXA_ARGS "-i" "${G1A_ICON}")
shell_escape("${G1A_ICON}" G1A_ICONB)
list(APPEND FXGXA_ARGS "-i" "${G1A_ICONB}")
endif()
if(DEFINED G1A_INTERNAL)

View file

@ -1,3 +1,5 @@
include(FxsdkUtils)
function(generate_g3a)
cmake_parse_arguments(G3A "" "TARGET;OUTPUT;NAME;VERSION" "ICONS" ${ARGN})
@ -21,8 +23,7 @@ function(generate_g3a)
if(DEFINED G3A_OUTPUT)
get_filename_component(G3A_OUTPUT "${G3A_OUTPUT}" ABSOLUTE
BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
# Who doesn't love to deal with escaping
string(REPLACE "'" "\\'" G3A_OUTPUT "${G3A_OUTPUT}")
shell_escape("${G3A_OUTPUT}" G3A_OUTPUT)
else()
set(G3A_OUTPUT "${G3A_TARGET}.g3a")
endif()
@ -52,9 +53,8 @@ function(generate_g3a)
BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
get_filename_component(G3A_ICON2 "${G3A_ICON2}" ABSOLUTE
BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
# Who doesn't REALLY love to deal with escaping
string(REPLACE "'" "\\'" G3A_ICON1B "${G3A_ICON1}")
string(REPLACE "'" "\\'" G3A_ICON2B "${G3A_ICON2}")
shell_escape("${G3A_ICON1}" G3A_ICON1B)
shell_escape("${G3A_ICON2}" G3A_ICON2B)
list(APPEND FXGXA_ARGS "--icon-uns=${G3A_ICON1B}" "--icon-sel=${G3A_ICON2B}")
endif()
@ -63,7 +63,7 @@ function(generate_g3a)
add_custom_command(
TARGET "${G3A_TARGET}" POST_BUILD
COMMAND ${OBJCOPY} -O binary -R .bss -R .gint_bss ${G3A_TARGET} ${G3A_TARGET}.bin
COMMAND fxgxa --g3a ${FXGXA_ARGS} "${G3A_TARGET}.bin" -o "${G3A_OUTPUT}"
COMMAND fxgxa --g3a ${FXGXA_ARGS} ${G3A_TARGET}.bin -o ${G3A_OUTPUT}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
if(DEFINED G3A_ICONS)