mirror of
https://github.com/starr-dusT/tzdb_to_nx
synced 2024-03-05 21:18:52 -08:00
tzdb: Use pure cmake to generate binaryList.txt
This commit is contained in:
parent
e5a9681b37
commit
7c1fc8b9ad
@ -46,11 +46,18 @@ add_custom_target(x80e
|
||||
${NX_VERSION_FILE})
|
||||
|
||||
set(BINARY_LIST_TXT ${NX_TZDB_DIR}/binaryList.txt)
|
||||
# add_custom_command(
|
||||
# OUTPUT
|
||||
# ${BINARY_LIST_TXT}
|
||||
# COMMAND
|
||||
# sh ${CMAKE_CURRENT_SOURCE_DIR}/generate_binary_list_txt.sh ${BINARY_LIST_TXT}
|
||||
# WORKING_DIRECTORY
|
||||
# ${NX_ZONEINFO_DIR})
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
${BINARY_LIST_TXT}
|
||||
COMMAND
|
||||
sh ${CMAKE_CURRENT_SOURCE_DIR}/generate_binary_list_txt.sh ${BINARY_LIST_TXT}
|
||||
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/generate_binary_list_txt.cmake ${BINARY_LIST_TXT} ${CMAKE_CURRENT_SOURCE_DIR}/list_directory.cmake
|
||||
WORKING_DIRECTORY
|
||||
${NX_ZONEINFO_DIR})
|
||||
|
||||
|
48
src/tzdb/generate_binary_list_txt.cmake
Normal file
48
src/tzdb/generate_binary_list_txt.cmake
Normal file
@ -0,0 +1,48 @@
|
||||
set(BINARY_LIST_TXT ${CMAKE_ARGV3})
|
||||
set(LIST_DIR_CMAKE ${CMAKE_ARGV4})
|
||||
|
||||
# Fill text file with zone names
|
||||
# Issue: Hyphens/underscores are not handled the same way Nintendo handles them
|
||||
function(get_files_nx TARG SUB_DIR)
|
||||
execute_process(
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -P ${LIST_DIR_CMAKE} false OFF
|
||||
WORKING_DIRECTORY
|
||||
${TARG}
|
||||
OUTPUT_VARIABLE
|
||||
FILE_LIST
|
||||
)
|
||||
list(SORT FILE_LIST)
|
||||
execute_process(
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -P ${LIST_DIR_CMAKE} true OFF
|
||||
WORKING_DIRECTORY
|
||||
${TARG}
|
||||
OUTPUT_VARIABLE
|
||||
DIR_LIST
|
||||
)
|
||||
|
||||
foreach(FILE ${FILE_LIST})
|
||||
if(FILE STREQUAL "\n")
|
||||
continue()
|
||||
endif()
|
||||
list(REMOVE_ITEM DIR_LIST FILE)
|
||||
if (SUB_DIR)
|
||||
file(APPEND ${BINARY_LIST_TXT} "${SUB_DIR}/${FILE}\r\n")
|
||||
else()
|
||||
file(APPEND ${BINARY_LIST_TXT} "${FILE}\r\n")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
list(SORT DIR_LIST)
|
||||
|
||||
foreach(DIR ${DIR_LIST})
|
||||
if (NOT DIR OR DIR STREQUAL "\n")
|
||||
continue()
|
||||
endif()
|
||||
get_files_nx(${DIR} ${DIR})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
get_files_nx(${CMAKE_SOURCE_DIR} "")
|
||||
|
@ -1,23 +0,0 @@
|
||||
#!/bin/sh
|
||||
BINARY_LIST_TXT="$1"
|
||||
|
||||
# Fill text file with zone names
|
||||
# Issue: Hyphens/underscores are not handled the same way Nintendo handles them
|
||||
get_files_nx() {
|
||||
local target=$1
|
||||
find $target -maxdepth 1 -type f -not -regex '.*Factory' | sort
|
||||
local DIRS=`find $target -maxdepth 1 -type d | sort`
|
||||
for i in $DIRS; do
|
||||
if [ "`readlink -e $i`" = "`readlink -e $target`" ]; then
|
||||
continue
|
||||
fi
|
||||
get_files_nx $i
|
||||
done
|
||||
}
|
||||
|
||||
get_files_nx . | cut -c3- > ${BINARY_LIST_TXT}
|
||||
|
||||
# Convert LF to CRLF
|
||||
awk -v ORS='\r\n' 1 ${BINARY_LIST_TXT} > win
|
||||
# Overwrite LF with CRLF conversion
|
||||
mv win ${BINARY_LIST_TXT}
|
10
src/tzdb/list_directory.cmake
Normal file
10
src/tzdb/list_directory.cmake
Normal file
@ -0,0 +1,10 @@
|
||||
set(WITH_DIRECTORIES ${CMAKE_ARGV3})
|
||||
set(RECURSE ${CMAKE_ARGV4})
|
||||
|
||||
set(HOW_TO_GLOB "GLOB")
|
||||
if (RECURSE)
|
||||
set(HOW_TO_GLOB "GLOB_RECURSE")
|
||||
endif()
|
||||
|
||||
file(GLOB FILE_LIST LIST_DIRECTORIES ${WITH_DIRECTORIES} RELATIVE ${CMAKE_SOURCE_DIR} "*")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "${FILE_LIST};")
|
Loading…
x
Reference in New Issue
Block a user