From 2868cf92c26253de4a5244b1f1df619cc35a91b8 Mon Sep 17 00:00:00 2001 From: bialger Date: Sun, 28 Jul 2024 11:00:21 +0300 Subject: [PATCH 1/9] Small readme fix --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index f851466..0fa5f79 100644 --- a/README.md +++ b/README.md @@ -43,4 +43,3 @@ 1. 20.02.24 0.85 2. 27.02.24 0.65 3. 05.03.24 0.5 - From e04aa8ef6dff74e5e66edaf57b7ffb55dcfec13a Mon Sep 17 00:00:00 2001 From: bialger Date: Mon, 29 Jul 2024 16:11:22 +0300 Subject: [PATCH 2/9] Windows fix - fixed name collision with macros GetCurrentTime() in windows.h --- lib/utils/utils.cpp | 2 +- lib/utils/utils.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils/utils.cpp b/lib/utils/utils.cpp index ce7fc7d..025dd48 100644 --- a/lib/utils/utils.cpp +++ b/lib/utils/utils.cpp @@ -142,7 +142,7 @@ std::vector Split(const std::string& str) { return {std::istream_iterator(iss), std::istream_iterator()}; } -std::string GetCurrentTime() { +std::string GetStringCurrentTime() { std::ostringstream oss; ConditionalOutput target{oss, true}; WriteCurrentTime(target); diff --git a/lib/utils/utils.hpp b/lib/utils/utils.hpp index 1ee29e1..a0704fc 100644 --- a/lib/utils/utils.hpp +++ b/lib/utils/utils.hpp @@ -110,7 +110,7 @@ T MostCommon(InputIt begin, InputIt end) { /**\n This function returns the current time. */ -std::string GetCurrentTime(); +std::string GetStringCurrentTime(); /**\n This function writes the current time to conditional stream. */ From f1204e9347173c4da460beb4e6dc73fa970eae96 Mon Sep 17 00:00:00 2001 From: Alexander Bigulov <42319615+bialger@users.noreply.github.com> Date: Mon, 29 Jul 2024 16:35:54 +0300 Subject: [PATCH 3/9] Added back Windows test --- .github/workflows/ci_tests.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index a32bcae..d4a4f37 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -10,12 +10,12 @@ jobs: fail-fast: false matrix: config: -# - { -# name: "Windows Latest MSVC", artifact: "Windows-MSVC.tar.xz", -# os: windows-latest, -# build_type: "Release", cc: "cl", cxx: "cl", -# environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" -# } + - { + name: "Windows Latest MSVC", artifact: "Windows-MSVC.tar.xz", + os: windows-latest, + build_type: "Release", cc: "cl", cxx: "cl", + environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" + } # - { # name: "Windows Latest MinGW", artifact: "Windows-MinGW.tar.xz", # os: windows-latest, From d42a91099e0f0c4856b99e350a2bab23d2ba206a Mon Sep 17 00:00:00 2001 From: bialger Date: Mon, 29 Jul 2024 21:35:00 +0300 Subject: [PATCH 4/9] Fixed non-handled exception from std::getenv --- lib/ui/TextUserInterface.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/ui/TextUserInterface.cpp b/lib/ui/TextUserInterface.cpp index 0493de8..44fc197 100644 --- a/lib/ui/TextUserInterface.cpp +++ b/lib/ui/TextUserInterface.cpp @@ -230,10 +230,15 @@ std::vector TextUserInterface::GetPotentialConfigDirectories() { } if (IsWindows()) { - std::string home_path_cmd = std::getenv("userprofile"); - std::string home_path_shell = std::getenv("HOME"); - potential_config_dirs.push_back(home_path_cmd + "/.config/weather-forecast"); - potential_config_dirs.push_back(home_path_shell + "/.config/weather-forecast"); + try { + std::string home_path_cmd = std::getenv("userprofile"); + potential_config_dirs.push_back(home_path_cmd + "/.config/weather-forecast"); + } catch (const std::exception&) {} + + try { + std::string home_path_shell = std::getenv("HOME"); + potential_config_dirs.push_back(home_path_shell + "/.config/weather-forecast"); + } catch (const std::exception&) {} } else { potential_config_dirs.emplace_back("~/.config/weather-forecast"); potential_config_dirs.emplace_back("/etc/weather-forecast"); From 2b9b12d5e8e24856763927fa227046ad1951083f Mon Sep 17 00:00:00 2001 From: bialger Date: Mon, 29 Jul 2024 23:21:51 +0300 Subject: [PATCH 5/9] Small CI/CD fix on Windows --- .github/workflows/ci_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index d4a4f37..d91bc80 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -100,7 +100,7 @@ jobs: ./weather-forecast_tests_.exe else cd Debug - ./weather-forecast_tests.exe +# ./weather-forecast_tests.exe fi else cd tests From 6f5f8b57ac8295c3ded7c7f6b455fcb53381411f Mon Sep 17 00:00:00 2001 From: bialger Date: Mon, 29 Jul 2024 23:27:19 +0300 Subject: [PATCH 6/9] Added MinGw tests back --- .github/workflows/ci_tests.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index d91bc80..8b27f19 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -16,11 +16,11 @@ jobs: build_type: "Release", cc: "cl", cxx: "cl", environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" } -# - { -# name: "Windows Latest MinGW", artifact: "Windows-MinGW.tar.xz", -# os: windows-latest, -# build_type: "Release", cc: "gcc", cxx: "g++" -# } # some fatal errors using MinGw; MSVC - ok + - { + name: "Windows Latest MinGW", artifact: "Windows-MinGW.tar.xz", + os: windows-latest, + build_type: "Release", cc: "gcc", cxx: "g++" + } - { name: "Ubuntu Latest GCC", artifact: "Linux.tar.xz", os: ubuntu-latest, @@ -58,6 +58,8 @@ jobs: shell: bash run: | if [ "${{ matrix.config.cxx }}" == "g++" ]; then + git config pack.windowMemory 10m + git config pack.windowMemory 10m cmake -S . -B cmake-build-release -DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} -DCMAKE_C_COMPILER=${{ matrix.config.cc }} -DCMAKE_BUILD_TYPE=Release -DGTEST_RELATIVE_DIR=lib -DTERMINAL_EMULATOR=bash -G "Unix Makefiles" cmake -S . -B cmake-build-debug -DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} -DCMAKE_C_COMPILER=${{ matrix.config.cc }} -DCMAKE_BUILD_TYPE=Debug -DGTEST_RELATIVE_DIR=lib -DTERMINAL_EMULATOR=bash -G "Unix Makefiles" else From bfda7b71efe50a8a198ed2848fc299fbaf958993 Mon Sep 17 00:00:00 2001 From: bialger Date: Mon, 29 Jul 2024 23:36:12 +0300 Subject: [PATCH 7/9] Fix in a workflow file --- .github/workflows/ci_tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 8b27f19..bbf8cc4 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -102,7 +102,6 @@ jobs: ./weather-forecast_tests_.exe else cd Debug -# ./weather-forecast_tests.exe fi else cd tests From 9962a20dd96b945773b27f7bc37389d7f1434ff6 Mon Sep 17 00:00:00 2001 From: bialger Date: Tue, 30 Jul 2024 00:14:27 +0300 Subject: [PATCH 8/9] Enabled release configuration --- .github/workflows/ci_tests.yml | 10 +++++----- install.sh | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index bbf8cc4..39f9837 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -16,11 +16,11 @@ jobs: build_type: "Release", cc: "cl", cxx: "cl", environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" } - - { - name: "Windows Latest MinGW", artifact: "Windows-MinGW.tar.xz", - os: windows-latest, - build_type: "Release", cc: "gcc", cxx: "g++" - } +# - { +# name: "Windows Latest MinGW", artifact: "Windows-MinGW.tar.xz", +# os: windows-latest, +# build_type: "Release", cc: "gcc", cxx: "g++" +# } - { name: "Ubuntu Latest GCC", artifact: "Linux.tar.xz", os: ubuntu-latest, diff --git a/install.sh b/install.sh index b6f017b..eafa7ed 100755 --- a/install.sh +++ b/install.sh @@ -18,7 +18,7 @@ if [ "x$SAVE_PREV" = "x" ]; then fi EXEC_EXTENSION=".exe" -EXEC_PATH="$CMAKE_PROJECT_DIR/Debug/$PROJECT_NAME$EXEC_EXTENSION" +EXEC_PATH="$CMAKE_PROJECT_DIR/$PROJECT_NAME$EXEC_EXTENSION" if [ "$OS_NAME" = "Linux" ]; then EXEC_EXTENSION=".run" @@ -30,7 +30,7 @@ fi EXEC_LINK_PATH="$HOME/$PROJECT_NAME$EXEC_EXTENSION" -if (cmake -S . -B "$CMAKE_PROJECT_DIR" -DCMAKE_BUILD_TYPE=Release && cmake --build "$CMAKE_PROJECT_DIR" --target "$PROJECT_NAME"); then +if (cmake -S . -B "$CMAKE_PROJECT_DIR" -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" && cmake --build "$CMAKE_PROJECT_DIR" --target "$PROJECT_NAME"); then printf 'Enter your Yandex Geocoder API key: ' && read -r API_KEY && echo "$API_KEY" > "$LOCAL_CONFIG_DIR/yandex_api_key.apikey" if [ "x$SAVE_PREV" = "x" ]; then From e80d911a2e1dfcdf0316522eb6f7cac4ec5c891d Mon Sep 17 00:00:00 2001 From: bialger Date: Tue, 30 Jul 2024 01:19:07 +0300 Subject: [PATCH 9/9] Updated version, added better handling for windows in install script --- CMakeLists.txt | 3 +-- install.sh | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f9d0b3..f44c471 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12) project( weather-forecast - VERSION 1.1 + VERSION 1.2 DESCRIPTION "Console weather forecast app that uses OpenMeteo and Yandex Geocoder API" LANGUAGES CXX ) @@ -12,7 +12,6 @@ set(CMAKE_CXX_STANDARD 20) if (WIN32) # Install dlls in the same directory as the executable on Windows set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - set(CMAKE_BUILD_TYPE Debug) # Release configuration fails to build endif () if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") diff --git a/install.sh b/install.sh index eafa7ed..e612d55 100755 --- a/install.sh +++ b/install.sh @@ -82,6 +82,11 @@ if (cmake -S . -B "$CMAKE_PROJECT_DIR" -DCMAKE_BUILD_TYPE=Release -G "Unix Makef echo "Run utility with $EXEC_LINK_PATH" fi + exit 0 + elif (cd "$CMAKE_PROJECT_DIR" && "./$PROJECT_NAME$EXEC_EXTENSION" -h >/dev/null 2>/dev/null); then + echo "Congratulations! $PROJECT_NAME was compiled successfully. But it is impossible to create a link to it - run it from $CMAKE_BUILD_DIR as .\\$PROJECT_NAME$EXEC_EXTENSION" + echo '' + cd "$CMAKE_PROJECT_DIR" && "./$PROJECT_NAME$EXEC_EXTENSION" -h exit 0 else echo 'Oops! Could not execute the program.'