diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fee66b19..00d2bd11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,18 +26,18 @@ jobs: compiler: [gcc, clang] address_size: [64] crypto_backend: [OpenSSL, Libgcrypt, mbedTLS] - enable_zlib_compression: [OFF, ON] + enable_zlib_compression: ['OFF', 'ON'] b: [cmake] include: - compiler: gcc address_size: 64 crypto_backend: OpenSSL - enable_zlib_compression: OFF + enable_zlib_compression: 'OFF' b: configure - compiler: clang address_size: 64 crypto_backend: OpenSSL - enable_zlib_compression: OFF + enable_zlib_compression: 'OFF' b: configure env: CC: ${{ matrix.compiler }} @@ -57,7 +57,9 @@ jobs: MBEDTLSVER=mbedtls-3.4.0 curl -L https://github.com/Mbed-TLS/mbedtls/archive/$MBEDTLSVER.tar.gz | tar -xzf - cd mbedtls-$MBEDTLSVER - cmake $TOOLCHAIN_OPTION -DUSE_SHARED_MBEDTLS_LIBRARY=ON -DCMAKE_INSTALL_PREFIX:PATH=../usr . + cmake $TOOLCHAIN_OPTION \ + -DUSE_SHARED_MBEDTLS_LIBRARY=ON \ + -DCMAKE_INSTALL_PREFIX:PATH=../usr . make -j3 install cd .. echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/usr/lib" >> $GITHUB_ENV @@ -75,7 +77,11 @@ jobs: run: | mkdir bin cd bin - cmake $TOOLCHAIN_OPTION -DENABLE_WERROR=ON -DCRYPTO_BACKEND=$CRYPTO_BACKEND -DBUILD_SHARED_LIBS=ON -DENABLE_ZLIB_COMPRESSION=$ENABLE_ZLIB_COMPRESSION .. + cmake $TOOLCHAIN_OPTION \ + -DENABLE_WERROR=ON \ + -DBUILD_SHARED_LIBS=ON \ + -DCRYPTO_BACKEND=$CRYPTO_BACKEND \ + -DENABLE_ZLIB_COMPRESSION=$ENABLE_ZLIB_COMPRESSION .. cmake --build . export OPENSSH_SERVER_IMAGE=ghcr.io/libssh2/ci_tests_openssh_server:$(git rev-parse --short=20 HEAD:../tests/openssh_server) ctest -VV --output-on-failure @@ -109,3 +115,44 @@ jobs: ./configure --enable-debug --enable-static --disable-shared --with-crypto=openssl make -j3 make check VERBOSE=1 + + build_msvc: + name: msvc + runs-on: windows-latest + timeout-minutes: 30 + strategy: + matrix: + include: + - { arch: x64 , plat: windows, crypto: WinCNG , log: 'OFF', shared: 'OFF', zlib: 'OFF' } + - { arch: x64 , plat: windows, crypto: WinCNG , log: 'ON' , shared: 'ON' , zlib: 'OFF' } + - { arch: x64 , plat: windows, crypto: OpenSSL, log: 'OFF', shared: 'ON' , zlib: 'OFF' } + - { arch: x64 , plat: uwp , crypto: WinCNG , log: 'OFF', shared: 'ON' , zlib: 'OFF' } + - { arch: arm64, plat: windows, crypto: WinCNG , log: 'OFF', shared: 'ON' , zlib: 'OFF' } + - { arch: arm64, plat: uwp , crypto: WinCNG , log: 'OFF', shared: 'ON' , zlib: 'OFF' } + - { arch: x86 , plat: windows, crypto: WinCNG , log: 'OFF', shared: 'ON' , zlib: 'OFF' } + fail-fast: false + steps: + - uses: actions/checkout@v3 + - name: Configure with CMake + shell: bash + run: | + archgen=${{matrix.arch}}; [ "${archgen}" = 'x86' ] && archgen='Win32' + if [ "${{matrix.plat}}" = 'uwp' ]; then + system='WindowsStore' + options='-DCMAKE_SYSTEM_VERSION=10.0' + else + system='Windows' + fi + cmake . -B bld ${options} \ + -DCMAKE_SYSTEM_NAME=${system} \ + -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake \ + -DCMAKE_GENERATOR_PLATFORM=${archgen} \ + -DVCPKG_TARGET_TRIPLET=${{matrix.arch}}-${{matrix.plat}} \ + -DENABLE_WERROR=ON \ + -DENABLE_DEBUG_LOGGING=${{matrix.log}} \ + -DBUILD_SHARED_LIBS=${{matrix.shared}} \ + -DCRYPTO_BACKEND=${{matrix.crypto}} \ + -DENABLE_ZLIB_COMPRESSION=${{matrix.zlib}} + - name: Build with CMake + run: | + cmake --build bld --config Release --target package diff --git a/src/agent.c b/src/agent.c index 9b38d910..cb1fe20b 100644 --- a/src/agent.c +++ b/src/agent.c @@ -251,7 +251,7 @@ static struct agent_ops agent_ops_unix = { }; #endif /* PF_UNIX */ -#if defined(WIN32) && !defined(LIBSSH2_WINDOWS_APP) +#if defined(WIN32) && !defined(LIBSSH2_WINDOWS_UWP) /* Code to talk to Pageant was taken from PuTTY. * * Portions copyright Robert de Bath, Joris van Rantwijk, Delian @@ -354,16 +354,16 @@ static struct agent_ops agent_ops_pageant = { agent_transact_pageant, agent_disconnect_pageant }; -#endif /* defined(WIN32) && !defined(LIBSSH2_WINDOWS_APP) */ +#endif /* defined(WIN32) && !defined(LIBSSH2_WINDOWS_UWP) */ static struct { const char *name; struct agent_ops *ops; } supported_backends[] = { -#if defined(WIN32) && !defined(LIBSSH2_WINDOWS_APP) +#if defined(WIN32) && !defined(LIBSSH2_WINDOWS_UWP) {"Pageant", &agent_ops_pageant}, {"OpenSSH", &agent_ops_openssh}, -#endif +#endif /* defined(WIN32) && !defined(LIBSSH2_WINDOWS_UWP) */ #ifdef PF_UNIX {"Unix", &agent_ops_unix}, #endif /* PF_UNIX */ diff --git a/src/agent_win.c b/src/agent_win.c index 323ed6ba..4a93e1ca 100644 --- a/src/agent_win.c +++ b/src/agent_win.c @@ -41,7 +41,7 @@ #include "agent.h" #include -#if defined(WIN32) && !defined(LIBSSH2_WINDOWS_APP) +#if defined(WIN32) && !defined(LIBSSH2_WINDOWS_UWP) #include /* for getenv() */ @@ -347,4 +347,4 @@ struct agent_ops agent_ops_openssh = { agent_transact_openssh, agent_disconnect_openssh }; -#endif /* defined(WIN32) && !defined(LIBSSH2_WINDOWS_APP) */ +#endif /* defined(WIN32) && !defined(LIBSSH2_WINDOWS_UWP) */ diff --git a/src/libssh2_priv.h b/src/libssh2_priv.h index 6cbb2532..857b1359 100644 --- a/src/libssh2_priv.h +++ b/src/libssh2_priv.h @@ -97,7 +97,7 @@ # include # if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \ !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) -# define LIBSSH2_WINDOWS_APP +# define LIBSSH2_WINDOWS_UWP # endif # endif #endif diff --git a/tests/openssh_fixture.c b/tests/openssh_fixture.c index 407cdcbf..cbe08d99 100644 --- a/tests/openssh_fixture.c +++ b/tests/openssh_fixture.c @@ -61,6 +61,14 @@ #define LIBSSH2_SOCKET_MASK "%d" #endif +#ifdef LIBSSH2_WINDOWS_UWP +#define popen(x, y) (NULL) +#define pclose(x) (-1) +#elif defined(WIN32) +#define popen _popen +#define pclose _pclose +#endif + static int have_docker = 0; int openssh_fixture_have_docker(void) @@ -102,11 +110,7 @@ static int run_command_varg(char **output, const char *command, va_list args) } fprintf(stdout, "Command: %s\n", command_buf); -#ifdef WIN32 - pipe = _popen(buf, "r"); -#else pipe = popen(buf, "r"); -#endif if(!pipe) { fprintf(stderr, "Unable to execute command '%s'\n", command); return -1; @@ -118,11 +122,7 @@ static int run_command_varg(char **output, const char *command, va_list args) buf_len = strlen(buf); } -#ifdef WIN32 - ret = _pclose(pipe); -#else ret = pclose(pipe); -#endif if(ret) { fprintf(stderr, "Error running command '%s' (exit %d): %s\n", command, ret, buf);