From 7a9f9e19f69ee867f77bbf2c0e68b68a5492bb27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Soja?= Date: Fri, 30 Dec 2022 00:58:59 +0100 Subject: [PATCH 1/6] Use pragma ws2_32 only for MSC --- libs/sockets/tcpsocket_win.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/sockets/tcpsocket_win.cpp b/libs/sockets/tcpsocket_win.cpp index e6c66210b2..f780ca4d8f 100644 --- a/libs/sockets/tcpsocket_win.cpp +++ b/libs/sockets/tcpsocket_win.cpp @@ -18,7 +18,9 @@ #include "tcpsocket.h" #include "tcpsocket_p.h" +#ifdef _MSC_VER #pragma comment(lib, "Ws2_32.lib") +#endif bool TcpSocketPrivate::createSocket(int domain) { From cf04f25d38337549a5e922ef2936172d11e1b463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Soja?= Date: Fri, 30 Dec 2022 00:59:24 +0100 Subject: [PATCH 2/6] Link ws2_32 library in CMakeLists.txt --- libs/sockets/CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/sockets/CMakeLists.txt b/libs/sockets/CMakeLists.txt index 12b6b94189..3818f533d7 100644 --- a/libs/sockets/CMakeLists.txt +++ b/libs/sockets/CMakeLists.txt @@ -18,14 +18,15 @@ list(APPEND ${PROJECT_NAME}_SOURCES tcpsocket.cpp ) -if(WIN32) +if(UNIX) list(APPEND ${PROJECT_NAME}_SOURCES - tcpsocket_win.cpp + tcpsocket_unix.cpp ) else() list(APPEND ${PROJECT_NAME}_SOURCES - tcpsocket_unix.cpp + tcpsocket_win.cpp ) + target_link_libraries(${PROJECT_NAME} -lws2_32) endif() # Setup Target From bd89c163d65f35f963ca75ac82a3cc3f2f321cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Soja?= Date: Fri, 30 Dec 2022 00:59:58 +0100 Subject: [PATCH 3/6] Fix mkdir/mkpath for Windows --- libs/indidevice/indiutility.cpp | 24 ++++++++++++++++++++++-- libs/indidevice/indiutility.h | 13 ++++++++++--- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/libs/indidevice/indiutility.cpp b/libs/indidevice/indiutility.cpp index 0652d8ec4e..dd5fb69878 100644 --- a/libs/indidevice/indiutility.cpp +++ b/libs/indidevice/indiutility.cpp @@ -23,10 +23,31 @@ #include "indiutility.h" #include +#ifdef _MSC_VER + +#include + +#ifndef S_ISDIR +#define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR) +#endif + +#define mkdir _mkdir + +#endif + namespace INDI { -#ifndef _WINDOWS +int mkdir(const char *path, mode_t mode) +{ +#ifdef _WIN32 + INDI_UNUSED(mode); + return ::mkdir(path); +#else + return ::mkdir(path, mode); +#endif +} + int mkpath(std::string s, mode_t mode) { size_t pre = 0, pos; @@ -61,7 +82,6 @@ int mkpath(std::string s, mode_t mode) } return mdret; } -#endif std::string format_time(const std::tm &tm, const char *format) { diff --git a/libs/indidevice/indiutility.h b/libs/indidevice/indiutility.h index abcee2b711..47c92b0bf7 100644 --- a/libs/indidevice/indiutility.h +++ b/libs/indidevice/indiutility.h @@ -60,16 +60,23 @@ inline static size_t indi_strlcpy(char * dst, const char * src, size_t maxlen) // C++ #ifdef __cplusplus + +#ifdef _WINDOWS +typedef unsigned int mode_t; +#endif + namespace INDI { +/** + * @brief Create directory. + */ +int mkdir(const char *path, mode_t mode); /** * @brief Create a path directory - this function uses 'mkdir' - * @note Not available on Windows. Need to use C++17 cross-platform std::filesystem later. */ -#ifndef _WINDOWS int mkpath(std::string path, mode_t mode); -#endif + /** * @brief Converts the date and time to string - this function uses 'strftime' */ From 9dc88c9f82c169a050b3281bb927cf1efa8bbefb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Soja?= Date: Fri, 30 Dec 2022 01:00:22 +0100 Subject: [PATCH 4/6] Add MinGW workflow for CI --- .github/workflows/windows-mingw.yml | 60 +++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/windows-mingw.yml diff --git a/.github/workflows/windows-mingw.yml b/.github/workflows/windows-mingw.yml new file mode 100644 index 0000000000..481bcbc035 --- /dev/null +++ b/.github/workflows/windows-mingw.yml @@ -0,0 +1,60 @@ +name: MinGW + +on: + workflow_dispatch: + push: + branches: + - 'master' + pull_request: + branches: + - 'master' + +env: + # Path to the solution file relative to the root of the project. + SOLUTION_FILE_PATH: . + + # Configuration type to build. + # You can convert this to a build matrix if you need coverage of multiple configuration types. + # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + BUILD_CONFIGURATION: Debug + +permissions: + contents: read + +jobs: + build: + runs-on: windows-latest + + strategy: + matrix: + include: + - { sys: mingw64, env: x86_64 } +# - { sys: mingw32, env: i686 } + + defaults: + run: + shell: msys2 {0} + + steps: + - uses: msys2/setup-msys2@v2 + with: + msystem: ${{matrix.sys}} + update: true + install: >- + mingw-w64-${{matrix.env}}-openssl + + base-devel + mingw-w64-${{matrix.env}}-cmake + mingw-w64-${{matrix.env}}-gcc + mingw-w64-${{matrix.env}}-libnova + zlib-devel + + - name: Get INDI Sources + uses: actions/checkout@v3 + + - name: Build INDI Core + run: | + mkdir build + cd build + cmake .. -DINDI_BUILD_SERVER=OFF -DINDI_BUILD_DRIVERS=OFF + cmake --build . From 4b9e3df8f87630160e7f61df2af0c1f0092b0847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Soja?= Date: Fri, 30 Dec 2022 01:00:43 +0100 Subject: [PATCH 5/6] Use sharedblob only for Unix --- libs/indicore/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/indicore/CMakeLists.txt b/libs/indicore/CMakeLists.txt index ce14775e63..1ed966c3b6 100644 --- a/libs/indicore/CMakeLists.txt +++ b/libs/indicore/CMakeLists.txt @@ -41,7 +41,7 @@ list(APPEND ${PROJECT_NAME}_SOURCES indiuserio.c ) -if(NOT WIN32) +if(UNIX) list(APPEND ${PROJECT_NAME}_PRIVATE_HEADERS sharedblob_parse.h shm_open_anon.h) From 06dc6ba21ac988708604852681203e6c9b24e88d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Soja?= Date: Fri, 30 Dec 2022 01:01:06 +0100 Subject: [PATCH 6/6] Rename workflows, cleanup --- .github/workflows/{default-i386.yml => linux-i386.yml} | 0 .github/workflows/{package.yml => linux-packages.yml} | 4 ++-- .github/workflows/{pyindi.yml => linux-pyindi.yml} | 1 - .github/workflows/{default.yml => linux.yml} | 0 .github/workflows/{windows.yml => windows-visual.yml} | 2 +- README.md | 10 ++++++---- 6 files changed, 9 insertions(+), 8 deletions(-) rename .github/workflows/{default-i386.yml => linux-i386.yml} (100%) rename .github/workflows/{package.yml => linux-packages.yml} (89%) rename .github/workflows/{pyindi.yml => linux-pyindi.yml} (99%) rename .github/workflows/{default.yml => linux.yml} (100%) rename .github/workflows/{windows.yml => windows-visual.yml} (98%) diff --git a/.github/workflows/default-i386.yml b/.github/workflows/linux-i386.yml similarity index 100% rename from .github/workflows/default-i386.yml rename to .github/workflows/linux-i386.yml diff --git a/.github/workflows/package.yml b/.github/workflows/linux-packages.yml similarity index 89% rename from .github/workflows/package.yml rename to .github/workflows/linux-packages.yml index b9482234d6..aca10ef197 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/linux-packages.yml @@ -1,4 +1,4 @@ -name: Package +name: Debian Packages on: workflow_dispatch: @@ -27,6 +27,6 @@ jobs: with: path: 'indi' - - name: Build INDI Core Package + - name: Build INDI Core Packages run: | indi/scripts/indi-core-deb.sh diff --git a/.github/workflows/pyindi.yml b/.github/workflows/linux-pyindi.yml similarity index 99% rename from .github/workflows/pyindi.yml rename to .github/workflows/linux-pyindi.yml index 5f360f4efd..609bf5d307 100644 --- a/.github/workflows/pyindi.yml +++ b/.github/workflows/linux-pyindi.yml @@ -9,7 +9,6 @@ on: branches: - 'master' - jobs: build: runs-on: ubuntu-latest diff --git a/.github/workflows/default.yml b/.github/workflows/linux.yml similarity index 100% rename from .github/workflows/default.yml rename to .github/workflows/linux.yml diff --git a/.github/workflows/windows.yml b/.github/workflows/windows-visual.yml similarity index 98% rename from .github/workflows/windows.yml rename to .github/workflows/windows-visual.yml index 4b79a00a24..45314baaae 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows-visual.yml @@ -1,4 +1,4 @@ -name: Windows +name: Visual Studio on: workflow_dispatch: diff --git a/README.md b/README.md index 3e41f817de..1710f54252 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ # INDI Core Library -[![Linux](https://github.com/indilib/indi/actions/workflows/default.yml/badge.svg)](https://github.com/indilib/indi/actions) -[![Linux Deb Package](https://github.com/indilib/indi/actions/workflows/package.yml/badge.svg)](https://github.com/indilib/indi/actions) + +[![Linux](https://github.com/indilib/indi/actions/workflows/linux.yml/badge.svg)](https://github.com/indilib/indi/actions) +[![Debian Packages](https://github.com/indilib/indi/actions/workflows/linux-packages.yml/badge.svg)](https://github.com/indilib/indi/actions) [![MacOS](https://github.com/indilib/indi/actions/workflows/macos.yml/badge.svg)](https://github.com/indilib/indi/actions) -[![PyIndi](https://github.com/indilib/indi/actions/workflows/pyindi.yml/badge.svg)](https://github.com/indilib/indi/actions) -[![Windows Client](https://github.com/indilib/indi/actions/workflows/windows.yml/badge.svg)](https://github.com/indilib/indi/actions) +[![Visual Studio](https://github.com/indilib/indi/actions/workflows/windows-visual.yml/badge.svg)](https://github.com/indilib/indi/actions) +[![MinGW](https://github.com/indilib/indi/actions/workflows/windows-mingw.yml/badge.svg)](https://github.com/indilib/indi/actions) +[![PyIndi](https://github.com/indilib/indi/actions/workflows/linux-pyindi.yml/badge.svg)](https://github.com/indilib/indi/actions) INDI is a standard for astronomical instrumentation control. INDI Library is an Open Source POSIX implementation of the [Instrument-Neutral-Device-Interface protocol](http://www.clearskyinstitute.com/INDI/INDI.pdf).