diff --git a/platform/CMakeLists.txt b/platform/CMakeLists.txt index 8b22c12..713cc8f 100644 --- a/platform/CMakeLists.txt +++ b/platform/CMakeLists.txt @@ -1,5 +1,3 @@ -SET(files error.cpp -) add_library(skeldal_platform STATIC) @@ -15,6 +13,15 @@ target_sources(skeldal_platform PRIVATE getopt.c ) +set(all_libs + skeldal_main + skeldal_libs + skeldal_platform + skeldal_sdl + skeldal_libs + ${SDL2_LIBRARIES} + ${STANDARD_LIBRARIES}) + if(WIN32) target_sources(skeldal_platform PRIVATE windows/save_folder.cpp @@ -27,6 +34,7 @@ if(WIN32) windows/skeldal.rc ) target_compile_definitions(skeldal_platform PRIVATE PLATFORM_WINDOWS) + target_link_libraries(skeldal ${all_libs}) message(STATUS "Building for Windows") elseif(UNIX AND NOT APPLE) @@ -34,16 +42,17 @@ elseif(UNIX AND NOT APPLE) linux/save_folder.cpp linux/map_file.cpp ) - add_executable(skeldal) - target_sources(skeldal PRIVATE + add_executable(skeldal_bin) + target_sources(skeldal_bin PRIVATE linux/app_start.cpp ) target_compile_definitions(skeldal_platform PRIVATE PLATFORM_LINUX) add_custom_command( - TARGET skeldal POST_BUILD + TARGET skeldal_bin POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/linux/skeldal.sh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/skeldal.sh) + target_link_libraries(skeldal_bin ${all_libs}) message(STATUS "Building for Linux") elseif(APPLE) @@ -56,18 +65,11 @@ elseif(APPLE) ) target_compile_definitions(mylib PRIVATE PLATFORM_MACOS) message(STATUS "Building for macOS") + target_link_libraries(skeldal ${all_libs}) else() error("Platform not detected, please add new platform here") endif() set_property(TARGET skeldal_platform PROPERTY CXX_STANDARD 20) -add_subdirectory(sdl) + add_subdirectory(sdl) -target_link_libraries(skeldal - skeldal_main - skeldal_libs - skeldal_platform - skeldal_sdl - skeldal_libs - ${SDL2_LIBRARIES} - ${STANDARD_LIBRARIES}) diff --git a/platform/file_access.cpp b/platform/file_access.cpp index 99bb903..b6d1f15 100644 --- a/platform/file_access.cpp +++ b/platform/file_access.cpp @@ -114,6 +114,14 @@ char change_current_directory(const char *path) { return ec == std::error_code{}?1:0; } + +std::chrono::system_clock::time_point from_file_time(std::filesystem::file_time_type::clock::time_point tp) { + return std::chrono::time_point_cast( + tp - std::filesystem::file_time_type::clock::now() + std::chrono::system_clock::now() + ); + +} + int list_files(const char *directory, int type, LIST_FILES_CALLBACK cb, void *ctx) { std::error_code ec; std::filesystem::directory_iterator iter(std::string(directory), ec); @@ -130,7 +138,7 @@ int list_files(const char *directory, int type, LIST_FILES_CALLBACK cb, void *ct tmp = entry.path().string(); } if (type & file_type_need_timestamp) { - auto tm = std::chrono::clock_cast(entry.last_write_time(ec)); + auto tm = from_file_time(entry.last_write_time(ec)); szortm = std::chrono::system_clock::to_time_t(tm); } else { szortm = entry.file_size(ec); diff --git a/platform/linux/app_start.cpp b/platform/linux/app_start.cpp index f47dc05..385cffb 100644 --- a/platform/linux/app_start.cpp +++ b/platform/linux/app_start.cpp @@ -20,7 +20,7 @@ void show_help(const char *arg0) { "-l set language (cz|en)\n" "-s generate string-tables (for localization) and exit\n" "-h this help\n"); - exit(0); + exit(1); } void show_help_short() { diff --git a/platform/linux/skeldal.sh b/platform/linux/skeldal.sh index 9f86177..83b11b5 100755 --- a/platform/linux/skeldal.sh +++ b/platform/linux/skeldal.sh @@ -2,7 +2,7 @@ temp_file=$(mktemp /tmp/skeldal.XXXXXX.log) -./skeldal > "$temp_file" 2>&1 +`dirname $0`/skeldal_bin $* > "$temp_file" 2>&1 exit_code=$? @@ -10,7 +10,7 @@ if [ $exit_code -ne 0 ]; then error_message=$(cat "$temp_file") if command -v zenity > /dev/null; then - zenity --warning --title="Skeldal ERROR" --text="$error_message" + zenity --warning --no-markup --title="Skeldal ERROR" --text="$error_message" elif command -v kdialog > /dev/null; then kdialog --title "Skeldal ERROR" --error "$error_message" elif command -v xmessage > /dev/null; then @@ -22,5 +22,5 @@ if [ $exit_code -ne 0 ]; then cat "$temp_file" fi fi -#rm $temp_file +rm $temp_file exit $exit_code \ No newline at end of file