mirror of
https://github.com/starr-dusT/tzdb_to_nx
synced 2024-03-05 21:18:52 -08:00
Merge pull request #9 from lat9nq/pure-cmake
general: Use pure CMake in place of shell scripts
This commit is contained in:
commit
25b0d508a8
10
CMakeModules/list_directory.cmake
Normal file
10
CMakeModules/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(${HOW_TO_GLOB} FILE_LIST LIST_DIRECTORIES ${WITH_DIRECTORIES} RELATIVE ${CMAKE_SOURCE_DIR} "*")
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "${FILE_LIST};")
|
20
externals/tz/CMakeLists.txt
vendored
20
externals/tz/CMakeLists.txt
vendored
@ -28,7 +28,23 @@ if (NOT EXISTS "${TZ_DIR}" OR NOT EXISTS "${TZIF_LIST_FILE}")
|
|||||||
|
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND
|
COMMAND
|
||||||
sh "${CMAKE_CURRENT_SOURCE_DIR}/find_tzif.sh" "${TZ_ZONEINFO_DIR}" "${TZIF_LIST_FILE}"
|
${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/CMakeModules/list_directory.cmake false ON
|
||||||
COMMAND_ERROR_IS_FATAL ANY
|
WORKING_DIRECTORY
|
||||||
|
"${TZ_ZONEINFO_DIR}"
|
||||||
|
OUTPUT_VARIABLE
|
||||||
|
TZIF_SCAN
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(TZIF_LIST "")
|
||||||
|
foreach(CANDIDATE ${TZIF_SCAN})
|
||||||
|
if (CANDIDATE STREQUAL "\n")
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
set(TZIF_FILE "${TZ_ZONEINFO_DIR}/${CANDIDATE}")
|
||||||
|
file(READ "${TZIF_FILE}" HEADER LIMIT 4)
|
||||||
|
string(SUBSTRING "${HEADER}" 0 4 HEADER) # Remove trailing newline
|
||||||
|
if (HEADER STREQUAL "TZif")
|
||||||
|
file(APPEND "${TZIF_LIST_FILE}" "${TZIF_FILE}\n")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
14
externals/tz/find_tzif.sh
vendored
14
externals/tz/find_tzif.sh
vendored
@ -1,14 +0,0 @@
|
|||||||
#/bin/sh
|
|
||||||
set -e
|
|
||||||
directory=$1
|
|
||||||
tzif_list=$2
|
|
||||||
|
|
||||||
truncate -s 0 $tzif_list
|
|
||||||
|
|
||||||
for i in `find $directory -type f`; do
|
|
||||||
header=`head -c 4 $i`
|
|
||||||
if [ "$header" = "TZif" ]; then
|
|
||||||
echo "$i" >> $tzif_list
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
@ -50,7 +50,7 @@ add_custom_command(
|
|||||||
OUTPUT
|
OUTPUT
|
||||||
${BINARY_LIST_TXT}
|
${BINARY_LIST_TXT}
|
||||||
COMMAND
|
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} ${PROJECT_SOURCE_DIR}/CMakeModules/list_directory.cmake
|
||||||
WORKING_DIRECTORY
|
WORKING_DIRECTORY
|
||||||
${NX_ZONEINFO_DIR})
|
${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(${TARG}/${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}
|
|
Loading…
x
Reference in New Issue
Block a user