prepare linux build target Ubuntu 22, x64

This commit is contained in:
Ondřej Novák 2025-02-20 19:20:00 +01:00
parent 8ef23fe366
commit 0a39f2d3d5
4 changed files with 29 additions and 19 deletions

View file

@ -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,6 +65,7 @@ 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()
@ -63,11 +73,3 @@ set_property(TARGET skeldal_platform PROPERTY CXX_STANDARD 20)
add_subdirectory(sdl)
target_link_libraries(skeldal
skeldal_main
skeldal_libs
skeldal_platform
skeldal_sdl
skeldal_libs
${SDL2_LIBRARIES}
${STANDARD_LIBRARIES})

View file

@ -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<std::chrono::system_clock::duration>(
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<std::chrono::system_clock>(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);

View file

@ -20,7 +20,7 @@ void show_help(const char *arg0) {
"-l <lang> set language (cz|en)\n"
"-s <directory> generate string-tables (for localization) and exit\n"
"-h this help\n");
exit(0);
exit(1);
}
void show_help_short() {

View file

@ -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