diff --git a/.github/workflows/test-win-latest.yml b/.github/workflows/test-win-latest.yml index 66261d1e6..4497493ed 100644 --- a/.github/workflows/test-win-latest.yml +++ b/.github/workflows/test-win-latest.yml @@ -32,7 +32,7 @@ concurrency: jobs: test: - name: Test on Windows ${{ matrix.arch }}-${{ matrix.build }}${{ matrix.transport == 'WinInet' && ' (WinInet)' || '' }} + name: Windows 10 API floor ${{ matrix.arch }}-${{ matrix.build }}${{ matrix.transport == 'WinInet' && ' (WinInet)' || '' }} runs-on: ${{ matrix.os }} timeout-minutes: 30 strategy: @@ -75,7 +75,7 @@ jobs: retention-days: 7 public-headers: - name: Public header gate (MSVC) + name: Public header gate (MSVC, Windows 10 API floor) runs-on: windows-2022 steps: - name: Checkout diff --git a/CMakeLists.txt b/CMakeLists.txt index 30fe6e3c8..9dadc7a70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -246,7 +246,7 @@ if(MATSDK_SQLITE_PROVIDER_RESOLVED STREQUAL "SYSTEM" AND NOT TARGET SQLite3::SQL matsdk_add_apple_system_library(SQLite3::SQLite3 sqlite3) else() find_package(SQLite3 QUIET) - if(NOT TARGET SQLite3::SQLite3 AND TARGET SQLite::SQLite3) + if(TARGET SQLite::SQLite3 AND NOT TARGET SQLite3::SQLite3) matsdk_add_interface_dependency(SQLite3::SQLite3 SQLite::SQLite3) endif() if(NOT TARGET SQLite3::SQLite3 AND MATSDK_USING_VCPKG) diff --git a/README.md b/README.md index 935cf1da2..ba11b35cd 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,8 @@ Other resources to learn how to setup the build system: * **Supported** - these platforms are known to work well with the SDK in production. * **Covered by CI** - these platforms are tested as part of CI. -* Windows 7, Windows 8, and Windows 8.1 are not supported. Some project files - retain older target macros for binary compatibility, but those macros do not - extend the supported operating-system matrix above. +* Windows 7, Windows 8, and Windows 8.1 are not supported. Windows desktop + builds target the Windows 10 API floor in CI. * For iOS simulator, CI covers representative supported simulator configurations on the current macOS runner images rather than every supported iOS 12+ runtime. diff --git a/Solutions/net48/net48.vcxproj b/Solutions/net48/net48.vcxproj index 5f7b09148..8eea81770 100644 --- a/Solutions/net48/net48.vcxproj +++ b/Solutions/net48/net48.vcxproj @@ -113,7 +113,7 @@ Level4 Disabled - ZLIB_WINAPI;WIN32;MATSDK_SHARED_LIB=1;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0601;_DEBUG;_WINDOWS;_USRDLL;NOMINMAX;%(PreprocessorDefinitions) + ZLIB_WINAPI;WIN32;MATSDK_SHARED_LIB=1;_CRT_SECURE_NO_WARNINGS;WINVER=0x0A00;_WIN32_WINNT=0x0A00;_DEBUG;_WINDOWS;_USRDLL;NOMINMAX;%(PreprocessorDefinitions) $(ProjectDir)..\..\lib;$(ProjectDir)..\..\lib\include\public;$(ProjectDir)..\..\lib\include\mat;$(ProjectDir)..\..\lib\include;$(ProjectDir)..\..\bondlite\include;$(ProjectDir)..\..\lib\shared;$(ProjectDir)..\..\lib\shared\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) ProgramDatabase true @@ -196,7 +196,7 @@ Disabled true false - ZLIB_WINAPI;WIN32;MATSDK_SHARED_LIB=1;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0601;NDEBUG;_WINDOWS;_USRDLL;NOMINMAX;%(PreprocessorDefinitions) + ZLIB_WINAPI;WIN32;MATSDK_SHARED_LIB=1;_CRT_SECURE_NO_WARNINGS;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NDEBUG;_WINDOWS;_USRDLL;NOMINMAX;%(PreprocessorDefinitions) $(ProjectDir)..\..\lib;$(ProjectDir)..\..\lib\include\public;$(ProjectDir)..\..\lib\include\mat;$(ProjectDir)..\..\lib\include;$(ProjectDir)..\..\bondlite\include;$(ProjectDir)..\..\lib\shared;$(ProjectDir)..\..\lib\shared\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) true false diff --git a/Solutions/net48/targetver.h b/Solutions/net48/targetver.h index 8b0d0d66f..498108c8d 100644 --- a/Solutions/net48/targetver.h +++ b/Solutions/net48/targetver.h @@ -5,6 +5,6 @@ // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. -#define _WIN32_WINNT 0x0601 +#define _WIN32_WINNT 0x0A00 #include diff --git a/Solutions/win32-dll/win32-dll.vcxproj b/Solutions/win32-dll/win32-dll.vcxproj index 968f36990..7f5bce688 100644 --- a/Solutions/win32-dll/win32-dll.vcxproj +++ b/Solutions/win32-dll/win32-dll.vcxproj @@ -162,7 +162,7 @@ NotUsing Level4 Disabled - ORIGINAL_FILENAME="ClientTelemetry.dll";ZLIB_WINAPI;WIN32;MATSDK_SHARED_LIB=1;_DEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN7;NOMINMAX;%(PreprocessorDefinitions) + ORIGINAL_FILENAME="ClientTelemetry.dll";ZLIB_WINAPI;WIN32;MATSDK_SHARED_LIB=1;_DEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN10;_WIN32_WINNT=_WIN32_WINNT_WIN10;NOMINMAX;%(PreprocessorDefinitions) $(ProjectDir)..\..\lib;$(ProjectDir)..\..\lib\include\public;$(ProjectDir)..\..\lib\include\mat;$(ProjectDir)..\..\lib\include;$(ProjectDir)..\..\bondlite\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) ProgramDatabase false @@ -253,7 +253,7 @@ MaxSpeed true false - ZLIB_WINAPI;WIN32;MATSDK_SHARED_LIB=1;NDEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN7;NOMINMAX;%(PreprocessorDefinitions) + ZLIB_WINAPI;WIN32;MATSDK_SHARED_LIB=1;NDEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN10;_WIN32_WINNT=_WIN32_WINNT_WIN10;NOMINMAX;%(PreprocessorDefinitions) $(ProjectDir)..\..\lib;$(ProjectDir)..\..\lib\include\public;$(ProjectDir)..\..\lib\include\mat;$(ProjectDir)..\..\lib\include;$(ProjectDir)..\..\bondlite\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) false false diff --git a/Solutions/win32-lib/win32-lib.vcxproj b/Solutions/win32-lib/win32-lib.vcxproj index d088b06c7..691cceb91 100644 --- a/Solutions/win32-lib/win32-lib.vcxproj +++ b/Solutions/win32-lib/win32-lib.vcxproj @@ -252,7 +252,7 @@ Level4 Disabled - ZLIB_WINAPI;WIN32;WIN32;NOMINMAX;_DEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN7;NOMINMAX;%(PreprocessorDefinitions) + ZLIB_WINAPI;WIN32;WIN32;NOMINMAX;_DEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN10;_WIN32_WINNT=_WIN32_WINNT_WIN10;NOMINMAX;%(PreprocessorDefinitions) $(ProjectDir)..\..\lib;$(ProjectDir)..\..\lib\include\public;$(ProjectDir)..\..\lib\include\mat;$(ProjectDir)..\..\lib\include;$(ProjectDir)..\..\bondlite\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) ProgramDatabase false @@ -320,7 +320,7 @@ Level4 Disabled - ZLIB_WINAPI;WIN32;NOMINMAX;_DEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN7;%(PreprocessorDefinitions) + ZLIB_WINAPI;WIN32;NOMINMAX;_DEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN10;_WIN32_WINNT=_WIN32_WINNT_WIN10;%(PreprocessorDefinitions) $(ProjectDir)..\..\lib;$(ProjectDir)..\..\lib\include\public;$(ProjectDir)..\..\lib\include\mat;$(ProjectDir)..\..\lib\include;$(ProjectDir)..\..\bondlite\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) ProgramDatabase false @@ -395,7 +395,7 @@ MinSpace true false - ZLIB_WINAPI;WIN32;NOMINMAX;NDEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN7;%(PreprocessorDefinitions) + ZLIB_WINAPI;WIN32;NOMINMAX;NDEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN10;_WIN32_WINNT=_WIN32_WINNT_WIN10;%(PreprocessorDefinitions) $(ProjectDir)..\..\lib;$(ProjectDir)..\..\lib\include\public;$(ProjectDir)..\..\lib\include\mat;$(ProjectDir)..\..\lib\include;$(ProjectDir)..\..\bondlite\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) false false @@ -471,7 +471,7 @@ MinSpace true false - ZLIB_WINAPI;WIN32;NOMINMAX;NDEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN7;%(PreprocessorDefinitions) + ZLIB_WINAPI;WIN32;NOMINMAX;NDEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN10;_WIN32_WINNT=_WIN32_WINNT_WIN10;%(PreprocessorDefinitions) $(ProjectDir)..\..\lib;$(ProjectDir)..\..\lib\include\public;$(ProjectDir)..\..\lib\include\mat;$(ProjectDir)..\..\lib\include;$(ProjectDir)..\..\bondlite\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) false false diff --git a/Solutions/win32-mini-dll/win32-mini-dll.vcxproj b/Solutions/win32-mini-dll/win32-mini-dll.vcxproj index 99d21d1ba..81fca2b6b 100644 --- a/Solutions/win32-mini-dll/win32-mini-dll.vcxproj +++ b/Solutions/win32-mini-dll/win32-mini-dll.vcxproj @@ -164,7 +164,7 @@ NotUsing Level4 MinSpace - CONFIG_CUSTOM_H="config-compact-noutc.h";ZLIB_WINAPI;WIN32;MATSDK_SHARED_LIB=1;NOMINMAX;_DEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN7;%(PreprocessorDefinitions) + CONFIG_CUSTOM_H="config-compact-noutc.h";ZLIB_WINAPI;WIN32;MATSDK_SHARED_LIB=1;NOMINMAX;_DEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN10;_WIN32_WINNT=_WIN32_WINNT_WIN10;%(PreprocessorDefinitions) $(ProjectDir)..\..\lib;$(ProjectDir)..\..\lib\include\public;$(ProjectDir)..\..\lib\include\mat;$(ProjectDir)..\..\lib\include;$(ProjectDir)..\..\bondlite\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) ProgramDatabase false @@ -287,7 +287,7 @@ MinSpace false false - CONFIG_CUSTOM_H="config-compact-noutc.h";ZLIB_WINAPI;WIN32;MATSDK_SHARED_LIB=1;WIN32;NOMINMAX;NDEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN7;%(PreprocessorDefinitions) + CONFIG_CUSTOM_H="config-compact-noutc.h";ZLIB_WINAPI;WIN32;MATSDK_SHARED_LIB=1;WIN32;NOMINMAX;NDEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN10;_WIN32_WINNT=_WIN32_WINNT_WIN10;%(PreprocessorDefinitions) $(ProjectDir)..\..\lib;$(ProjectDir)..\..\lib\include\public;$(ProjectDir)..\..\lib\include\mat;$(ProjectDir)..\..\lib\include;$(ProjectDir)..\..\bondlite\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) false false diff --git a/Solutions/win32-mini-lib/win32-mini-lib.vcxproj b/Solutions/win32-mini-lib/win32-mini-lib.vcxproj index aba9e8999..8d305209a 100644 --- a/Solutions/win32-mini-lib/win32-mini-lib.vcxproj +++ b/Solutions/win32-mini-lib/win32-mini-lib.vcxproj @@ -255,7 +255,7 @@ NotUsing Level4 MinSpace - CONFIG_CUSTOM_H="config-compact-noutc.h";ZLIB_WINAPI;WIN32;MATSDK_STATIC_LIB=1;_DEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN7;NOMINMAX;%(PreprocessorDefinitions) + CONFIG_CUSTOM_H="config-compact-noutc.h";ZLIB_WINAPI;WIN32;MATSDK_STATIC_LIB=1;_DEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN10;_WIN32_WINNT=_WIN32_WINNT_WIN10;NOMINMAX;%(PreprocessorDefinitions) $(ProjectDir)..\..\lib;$(ProjectDir)..\..\lib\include\public;$(ProjectDir)..\..\lib\include\mat;$(ProjectDir)..\..\lib\include;$(ProjectDir)..\..\bondlite\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) ProgramDatabase false @@ -361,7 +361,7 @@ NotUsing Level4 MinSpace - CONFIG_CUSTOM_H="config-compact-noutc.h";ZLIB_WINAPI;WIN32;MATSDK_STATIC_LIB=1;WIN32;_DEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN7;NOMINMAX;%(PreprocessorDefinitions) + CONFIG_CUSTOM_H="config-compact-noutc.h";ZLIB_WINAPI;WIN32;MATSDK_STATIC_LIB=1;WIN32;_DEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN10;_WIN32_WINNT=_WIN32_WINNT_WIN10;NOMINMAX;%(PreprocessorDefinitions) $(ProjectDir)..\..\lib;$(ProjectDir)..\..\lib\include\public;$(ProjectDir)..\..\lib\include\mat;$(ProjectDir)..\..\lib\include;$(ProjectDir)..\..\bondlite\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) ProgramDatabase false @@ -474,7 +474,7 @@ MinSpace false false - CONFIG_CUSTOM_H="config-compact-noutc.h";ZLIB_WINAPI;WIN32;MATSDK_STATIC_LIB=1;WIN32;NDEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN7;NOMINMAX;%(PreprocessorDefinitions) + CONFIG_CUSTOM_H="config-compact-noutc.h";ZLIB_WINAPI;WIN32;MATSDK_STATIC_LIB=1;WIN32;NDEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN10;_WIN32_WINNT=_WIN32_WINNT_WIN10;NOMINMAX;%(PreprocessorDefinitions) $(ProjectDir)..\..\lib;$(ProjectDir)..\..\lib\include\public;$(ProjectDir)..\..\lib\include\mat;$(ProjectDir)..\..\lib\include;$(ProjectDir)..\..\bondlite\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) false false @@ -579,7 +579,7 @@ MinSpace false true - CONFIG_CUSTOM_H="config-compact-noutc.h";ZLIB_WINAPI;WIN32;MATSDK_STATIC_LIB=1;WIN32;NDEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN7;NOMINMAX;%(PreprocessorDefinitions) + CONFIG_CUSTOM_H="config-compact-noutc.h";ZLIB_WINAPI;WIN32;MATSDK_STATIC_LIB=1;WIN32;NDEBUG;_WINDOWS;_USRDLL;WINVER=_WIN32_WINNT_WIN10;_WIN32_WINNT=_WIN32_WINNT_WIN10;NOMINMAX;%(PreprocessorDefinitions) $(ProjectDir)..\..\lib;$(ProjectDir)..\..\lib\include\public;$(ProjectDir)..\..\lib\include\mat;$(ProjectDir)..\..\lib\include;$(ProjectDir)..\..\bondlite\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) false false diff --git a/build-android.cmd b/build-android.cmd index add5f03d8..1ab6da44e 100644 --- a/build-android.cmd +++ b/build-android.cmd @@ -1,29 +1,30 @@ -@echo off -pushd "%~dp0" - -REM Users may override the default %ANDROID_SDK_ROOT% location if necessary - -if "%ANDROID_SDK_ROOT%" == "" set "ANDROID_SDK_ROOT=C:\Android\android-sdk" -if "%ANDROID_NDK_VERSION%" == "" set "ANDROID_NDK_VERSION=27.0.12077973" -if "%ANDROID_CMAKE_VERSION%" == "" set "ANDROID_CMAKE_VERSION=3.22.1" -if "%ANDROID_HOME%" == "" set "ANDROID_HOME=%ANDROID_SDK_ROOT%" -if "%ANDROID_NDK%" == "" set "ANDROID_NDK=%ANDROID_SDK_ROOT%\ndk\%ANDROID_NDK_VERSION%" -if "%ANDROID_NDK_HOME%" == "" set "ANDROID_NDK_HOME=%ANDROID_NDK%" -REM Consider using %ANDROID_NDK_ROOT% environment variable - -REM Install Android tools if necessary -call tools\setup-buildtools-android.cmd - -set "PATH=%ANDROID_SDK_ROOT%\cmake\%ANDROID_CMAKE_VERSION%\bin;%ANDROID_NDK%;%PATH%" - -echo Building SDK -pushd .\lib\android_build -call .\gradlew.bat maesdk:assemble app:assemble %* -popd - -echo Building Tests -pushd .\lib\android_build -call .\gradlew.bat maesdk:test %* -popd - -popd +@echo off +pushd "%~dp0" + +REM Users may override the default %ANDROID_SDK_ROOT% location if necessary + +if "%ANDROID_SDK_ROOT%" == "" set "ANDROID_SDK_ROOT=C:\Android\android-sdk" +if "%ANDROID_NDK_VERSION%" == "" set "ANDROID_NDK_VERSION=27.0.12077973" +if "%ANDROID_CMAKE_VERSION%" == "" set "ANDROID_CMAKE_VERSION=3.22.1" +if "%ANDROID_HOME%" == "" set "ANDROID_HOME=%ANDROID_SDK_ROOT%" +if "%ANDROID_NDK%" == "" set "ANDROID_NDK=%ANDROID_SDK_ROOT%\ndk\%ANDROID_NDK_VERSION%" +if "%ANDROID_NDK_HOME%" == "" set "ANDROID_NDK_HOME=%ANDROID_NDK%" +REM Consider using %ANDROID_NDK_ROOT% environment variable + +REM Install Android tools if necessary +call tools\setup-buildtools-android.cmd +if errorlevel 1 exit /b %ERRORLEVEL% + +set "PATH=%ANDROID_SDK_ROOT%\cmake\%ANDROID_CMAKE_VERSION%\bin;%ANDROID_NDK%;%PATH%" + +echo Building SDK +pushd .\lib\android_build +call .\gradlew.bat maesdk:assemble app:assemble %* +popd + +echo Building Tests +pushd .\lib\android_build +call .\gradlew.bat maesdk:test %* +popd + +popd diff --git a/cmake/MatsdkFetchCurl.cmake b/cmake/MatsdkFetchCurl.cmake index ea10d86d7..249f37b8e 100644 --- a/cmake/MatsdkFetchCurl.cmake +++ b/cmake/MatsdkFetchCurl.cmake @@ -36,7 +36,6 @@ function(matsdk_fetch_curl out_target) INSTALL_MBEDTLS_HEADERS MBEDTLS_FATAL_WARNINGS USE_SHARED_MBEDTLS_LIBRARY - LINK_WITH_PTHREAD BUILD_CURL_EXE BUILD_EXAMPLES BUILD_LIBCURL_DOCS @@ -82,7 +81,12 @@ function(matsdk_fetch_curl out_target) set(${option} ON) endforeach() + set(CURL_CA_BUNDLE none) + set(CURL_CA_PATH none) + set(CURL_CA_EMBED "") + if(MATSDK_CURL_TLS_BACKEND_UPPER STREQUAL "MBEDTLS") + set(LINK_WITH_PTHREAD ON) set(USE_STATIC_MBEDTLS_LIBRARY ON) set(CURL_USE_MBEDTLS ON) set(MBEDTLS_CONFIG_FILE "") @@ -96,6 +100,9 @@ function(matsdk_fetch_curl out_target) foreach(target mbedtls mbedx509 mbedcrypto) matsdk_configure_fetched_static_target("${target}") + target_compile_definitions("${target}" PUBLIC + MBEDTLS_THREADING_C + MBEDTLS_THREADING_PTHREAD) endforeach() set(MBEDTLS_INCLUDE_DIR "${matsdk_mbedtls_SOURCE_DIR}/include") @@ -125,6 +132,26 @@ function(matsdk_fetch_curl out_target) message(FATAL_ERROR "The embedded static CURL::libcurl target was not created.") endif() + set(_matsdk_curl_config "${matsdk_curl_BINARY_DIR}/lib/curl_config.h") + if(NOT EXISTS "${_matsdk_curl_config}") + message(FATAL_ERROR + "The embedded curl configuration was not generated: ${_matsdk_curl_config}") + endif() + file(READ "${_matsdk_curl_config}" _matsdk_curl_config_contents) + foreach(definition CURL_CA_BUNDLE CURL_CA_PATH) + string(REGEX REPLACE + "#define ${definition} \"[^\"]*\"" + "/* #undef ${definition} */" + _matsdk_curl_config_contents + "${_matsdk_curl_config_contents}") + endforeach() + if(_matsdk_curl_config_contents MATCHES + "#define CURL_CA_(BUNDLE|PATH)") + message(FATAL_ERROR + "Embedded curl retained a build-time certificate authority path.") + endif() + file(WRITE "${_matsdk_curl_config}" "${_matsdk_curl_config_contents}") + matsdk_configure_fetched_static_target(libcurl_static) set(_matsdk_fetched_curl_targets libcurl_static) diff --git a/docs/embedding-with-cmake.md b/docs/embedding-with-cmake.md index 7a3d08a33..6cce81468 100644 --- a/docs/embedding-with-cmake.md +++ b/docs/embedding-with-cmake.md @@ -40,10 +40,31 @@ set(MATSDK_ZLIB_PROVIDER VENDORED CACHE STRING "" FORCE) # SYSTEM or VENDORED `MINIMAL` builds the feature-stripped SQLite amalgamation. `VENDORED` builds the unstripped vendored dependency. `SYSTEM` consumes the canonical -`SQLite::SQLite3` / `ZLIB::ZLIB` targets or uses `find_package()`. `AUTO` +`SQLite3::SQLite3` / `ZLIB::ZLIB` targets or uses `find_package()`. `AUTO` preserves platform defaults: system dependencies on desktop/Apple source builds and vendored dependencies on Windows/Android source builds. +Recommended packaged-library policy: + +| Platform | SQLite | zlib | HTTP/TLS | +| --- | --- | --- | --- | +| macOS/iOS | `SYSTEM` (`libsqlite3`) | `SYSTEM` (`libz`) | Apple-native HTTP | +| Linux, self-contained | `MINIMAL` | `VENDORED` | `FETCH` + `MBEDTLS` | +| Linux, host-managed | host-selected | host-selected | `SYSTEM`; the host selects curl's TLS backend | +| Windows | `MINIMAL` | `VENDORED` | WinHTTP | +| Android | `MINIMAL`, or `NONE` with Room | `VENDORED` | Java/JNI by default | + +Apple's SQLite and zlib entries are system libraries: consumers link them but +do not ship private copies. A Linux host such as Foundry Local that already +standardizes on libcurl/OpenSSL should provide `CURL::libcurl` and select +`MATSDK_CURL_PROVIDER=SYSTEM`; other self-contained Linux consumers can use the +SDK's pinned curl/mbedTLS build. + +When multiple embedded SDK copies use the same system SQLite runtime, each +consumer must set `skipSqliteInitAndShutdown` to `"true"` and leave SQLite's +process-wide lifetime to the host. This is the required configuration for +coexisting Apple libraries that all link the system `libsqlite3`. + ## Non-vcpkg dependency selection When the CPP11 PAL uses the curl HTTP transport outside vcpkg, the SDK normally diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 321ed6b8c..e775caf08 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -299,7 +299,8 @@ target_compile_definitions(matsdk_internal_config INTERFACE USE_BOND _WINDOWS _USRDLL - WINVER=_WIN32_WINNT_WIN7) + WINVER=_WIN32_WINNT_WIN10 + _WIN32_WINNT=_WIN32_WINNT_WIN10) target_compile_options(matsdk_internal_config INTERFACE /U_MBCS) if(MATSDK_USE_WININET) target_compile_definitions(matsdk_internal_config INTERFACE HAVE_MAT_WININET_HTTP_CLIENT) @@ -688,7 +689,7 @@ elseif(PAL_IMPLEMENTATION STREQUAL "WIN32") else() target_link_libraries(mat PRIVATE winhttp) endif() - target_link_libraries(mat PRIVATE crypt32) + target_link_libraries(mat PRIVATE crypt32 uuid) elseif(APPLE) target_link_libraries(mat PUBLIC "-framework CoreFoundation" diff --git a/lib/http/HttpClient_WinHttp.cpp b/lib/http/HttpClient_WinHttp.cpp index 0efe64c28..9230f9277 100644 --- a/lib/http/HttpClient_WinHttp.cpp +++ b/lib/http/HttpClient_WinHttp.cpp @@ -1532,33 +1532,17 @@ unsigned HttpClient_WinHttp::s_nextRequestId = 0; HttpClient_WinHttp::HttpClient_WinHttp() { - // WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY (Windows 8.1+) resolves the proxy - // without depending on a logged-on interactive user or that user's + // Resolve the proxy without depending on a logged-on interactive user or that user's // Internet Explorer settings -- unlike WinInet's // INTERNET_OPEN_TYPE_PRECONFIG, which requires one. This is why WinHTTP, // not WinInet, is Microsoft's documented recommendation for services and - // other non-interactive processes. On an older OS that rejects this access - // type, fall back to the machine-wide WinHTTP proxy configuration. This is - // the documented pre-Windows-8.1 behavior and avoids bypassing enterprise - // proxies entirely. Only fall back for the compatibility error; other - // failures should not be hidden by a second, unrelated WinHttpOpen call. + // other non-interactive processes. HINTERNET session = ::WinHttpOpen( NULL, WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, WINHTTP_FLAG_ASYNC); if (session == nullptr) { - DWORD dwError = ::GetLastError(); - if (dwError == ERROR_INVALID_PARAMETER) - { - LOG_WARN("WinHttpOpen(AUTOMATIC_PROXY) is unsupported; retrying with default proxy"); - session = ::WinHttpOpen( - NULL, WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, - WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, WINHTTP_FLAG_ASYNC); - } - else - { - LOG_WARN("WinHttpOpen(AUTOMATIC_PROXY) failed: %lu", dwError); - } + LOG_WARN("WinHttpOpen(AUTOMATIC_PROXY) failed: %lu", ::GetLastError()); } // WinHTTP otherwise permits an unlimited number of connections per origin. // Keep transport concurrency aligned with the SDK's default pending-upload diff --git a/lib/pal/desktop/NetworkDetector.cpp b/lib/pal/desktop/NetworkDetector.cpp index f1a90e5b8..41ce75ad2 100644 --- a/lib/pal/desktop/NetworkDetector.cpp +++ b/lib/pal/desktop/NetworkDetector.cpp @@ -8,9 +8,6 @@ #pragma comment(lib, "runtimeobject.lib") -// This macro is required for DEFINE_GUID below to declare a local instance of IID_INetworkCostManager GUID -#define INITGUID - #include "NetworkDetector.hpp" #include @@ -19,12 +16,6 @@ #include "utils/Utils.hpp" #include "pal/PAL.hpp" -// Define a GUID that is only available in Windows 8.x+ SDK . We are using Windows 7.1A SDK for Win32 SDK build, -// so we cannot easily add an extra dependency on Windows 8 or later functionality project-wide. It'd be error-prone, -// because when we have all Windows 8+ features - we might fall into temptation of using that features that would -// break Windows 7.1 compatibility. We cannot afford breaking Windows 7.1 compatibility at this time. -DEFINE_GUID(IID_INetworkCostManager2, 0xdcb00008, 0x570f, 0x4a9b, 0x8d, 0x69, 0x19, 0x9f, 0xdb, 0xa5, 0x72, 0x3b); - #define NETDETECTOR_START WM_USER+1 #define NETDETECTOR_STOP WM_USER+2 @@ -151,7 +142,7 @@ namespace MAT_NS_BEGIN DWORD dwCost = NLM_CONNECTION_COST_UNKNOWN; INetworkCostManager* pNetworkCostManager = NULL; - hr = pNlm->QueryInterface(IID_INetworkCostManager2, (void**)&pNetworkCostManager); + hr = pNlm->QueryInterface(IID_INetworkCostManager, (void**)&pNetworkCostManager); if (hr != S_OK) { return result; } @@ -465,27 +456,8 @@ namespace MAT_NS_BEGIN /// /// Register for COM events and block-wait in RegisterAndListen /// -#pragma warning( push ) -#pragma warning(disable:28159) -#pragma warning(disable:4996) -#pragma warning(disable:6320) -// We must use GetVersionEx to retain backwards compat with Win 7 SP1 void NetworkDetector::run() { - // Check Windows version and if below Windows 8, then avoid running Network cost detection logic - OSVERSIONINFO osvi; - BOOL bIsWindows8orLater; - ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&osvi); - bIsWindows8orLater = ((osvi.dwMajorVersion >= 6) && (osvi.dwMinorVersion >= 2)) || (osvi.dwMajorVersion > 6); - // Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2) - if (!bIsWindows8orLater) - { - LOG_INFO("Running on Windows %d.%d without network detector...", osvi.dwMajorVersion, osvi.dwMinorVersion); - return; - } - __try { HRESULT hr = CoInitialize(nullptr); @@ -519,9 +491,10 @@ namespace MAT_NS_BEGIN Reset(); } } +#pragma warning(suppress:6320) // The constant filter intentionally handles any SEH failure from the COM stack. __except (EXCEPTION_EXECUTE_HANDLER) { - LOG_ERROR("Handled exception in network cost detection (Windows 7?)"); + LOG_ERROR("Handled exception in network cost detection"); } if (isCoInitialized) @@ -529,9 +502,7 @@ namespace MAT_NS_BEGIN CoUninitialize(); isCoInitialized = false; } - } -#pragma warning( pop ) /// /// Start network monitoring thread diff --git a/tests/headers/check_public_headers.cmd b/tests/headers/check_public_headers.cmd index 53860422c..4bb82cd69 100644 --- a/tests/headers/check_public_headers.cmd +++ b/tests/headers/check_public_headers.cmd @@ -51,8 +51,9 @@ if errorlevel 1 ( ) REM /W4 /WX matches ORT; /external:W0 suppresses platform/STL warnings so only our headers gate. -set "CXX_COMMON=/nologo /permissive- /W4 /WX /EHsc /experimental:external /external:anglebrackets /external:W0" -set "C_COMMON=/nologo /std:c11 /TC /W4 /WX /experimental:external /external:anglebrackets /external:W0" +set "WINDOWS_API_FLOOR=/DWINVER=0x0A00 /D_WIN32_WINNT=0x0A00" +set "CXX_COMMON=/nologo /permissive- /W4 /WX /EHsc /experimental:external /external:anglebrackets /external:W0 %WINDOWS_API_FLOOR%" +set "C_COMMON=/nologo /std:c11 /TC /W4 /WX /experimental:external /external:anglebrackets /external:W0 %WINDOWS_API_FLOOR%" set "FAIL=0" set "TOTAL=0" diff --git a/tools/build-common.sh b/tools/build-common.sh index 1ba0ecb56..b5de4da70 100644 --- a/tools/build-common.sh +++ b/tools/build-common.sh @@ -34,7 +34,10 @@ matsdk_try_buildtools_once() { if [ ! -f "$marker_file" ]; then if [ $# -gt 0 ]; then - "$@" || echo "$failure_message" + if ! "$@"; then + echo "$failure_message" + return 1 + fi fi matsdk_mark_buildtools_checked "$marker_file" fi diff --git a/tools/setup-buildtools-android.cmd b/tools/setup-buildtools-android.cmd index 429de7ac1..188bf073a 100644 --- a/tools/setup-buildtools-android.cmd +++ b/tools/setup-buildtools-android.cmd @@ -1,33 +1,64 @@ -if exist ".buildtools" ( - echo Skiping dependencies installation -) else ( - pushd "%~dp0" - where choco >NUL 2>NUL - if %ERRORLEVEL% neq 0 call "%~dp0\setup-choco.cmd" - - echo Installing dependencies [requires Admin / elevated Command prompt] - echo ANDROID_SDK_ROOT = %ANDROID_SDK_ROOT% - echo ANDROID_HOME = %ANDROID_HOME% - echo ANDROID_NDK = %ANDROID_NDK% - echo ANDROID_NDK_HOME = %ANDROID_NDK_HOME% - - if not exist "%USERPROFILE%\.android\repositories.cfg" ( - echo Creating default repositories.cfg ... - copy NUL "%USERPROFILE%\.android\repositories.cfg" - ) - - REM Use chocolatey for basic deps - choco install --no-progress -y android-sdk - choco install --no-progress -y ninja - - REM Use sdkmanager for additional deps - pushd %ANDROID_SDK_ROOT%\tools\bin - echo y | call sdkmanager.bat --include_obsolete --verbose --sdk_root=%ANDROID_SDK_ROOT% "platforms;android-28" "sources;android-28" - echo y | call sdkmanager.bat --include_obsolete --verbose --sdk_root=%ANDROID_SDK_ROOT% "platforms;android-29" "sources;android-29" - echo y | call sdkmanager.bat --include_obsolete --verbose --sdk_root=%ANDROID_SDK_ROOT% "build-tools;29.0.3" - echo y | call sdkmanager.bat --include_obsolete --verbose --sdk_root=%ANDROID_SDK_ROOT% "platform-tools" - echo y | call sdkmanager.bat --install --include_obsolete --verbose --sdk_root=%ANDROID_SDK_ROOT% "ndk-bundle" "cmake;%ANDROID_CMAKE_VERSION%" "ndk;%ANDROID_NDK_VERSION%" - popd - popd - copy NUL .buildtools +@echo off +set "BUILD_TOOLS_MARKER=.buildtools" +set "BUILD_TOOLS_MARKER_VERSION=android-cmake-%ANDROID_CMAKE_VERSION%-ndk-%ANDROID_NDK_VERSION%" +set "BUILD_TOOLS_MARKER_ACTUAL=" + +if not exist "%BUILD_TOOLS_MARKER%" goto install +set /p BUILD_TOOLS_MARKER_ACTUAL=<"%BUILD_TOOLS_MARKER%" +if /I not "%BUILD_TOOLS_MARKER_ACTUAL%"=="%BUILD_TOOLS_MARKER_VERSION%" goto install +if not exist "%ANDROID_SDK_ROOT%\cmake\%ANDROID_CMAKE_VERSION%\bin\cmake.exe" goto install +if not exist "%ANDROID_NDK%" goto install +echo Skipping dependencies installation +exit /b 0 + +:install +del "%BUILD_TOOLS_MARKER%" 2>NUL +pushd "%~dp0" +where choco >NUL 2>NUL +if errorlevel 1 call "%~dp0\setup-choco.cmd" +if errorlevel 1 goto install_failed + +echo Installing dependencies [requires Admin / elevated Command prompt] +echo ANDROID_SDK_ROOT = %ANDROID_SDK_ROOT% +echo ANDROID_HOME = %ANDROID_HOME% +echo ANDROID_NDK = %ANDROID_NDK% +echo ANDROID_NDK_HOME = %ANDROID_NDK_HOME% + +if not exist "%USERPROFILE%\.android\repositories.cfg" ( + echo Creating default repositories.cfg ... + copy NUL "%USERPROFILE%\.android\repositories.cfg" + if errorlevel 1 goto install_failed ) + +REM Use chocolatey for basic deps +call choco install --no-progress -y android-sdk +if errorlevel 1 goto install_failed +call choco install --no-progress -y ninja +if errorlevel 1 goto install_failed + +REM Use sdkmanager for additional deps +pushd "%ANDROID_SDK_ROOT%\tools\bin" +if errorlevel 1 goto install_failed +echo y | call .\sdkmanager.bat --include_obsolete --verbose --sdk_root="%ANDROID_SDK_ROOT%" "platforms;android-28" "sources;android-28" +if errorlevel 1 goto sdkmanager_failed +echo y | call .\sdkmanager.bat --include_obsolete --verbose --sdk_root="%ANDROID_SDK_ROOT%" "platforms;android-29" "sources;android-29" +if errorlevel 1 goto sdkmanager_failed +echo y | call .\sdkmanager.bat --include_obsolete --verbose --sdk_root="%ANDROID_SDK_ROOT%" "build-tools;29.0.3" +if errorlevel 1 goto sdkmanager_failed +echo y | call .\sdkmanager.bat --include_obsolete --verbose --sdk_root="%ANDROID_SDK_ROOT%" "platform-tools" +if errorlevel 1 goto sdkmanager_failed +echo y | call .\sdkmanager.bat --install --include_obsolete --verbose --sdk_root="%ANDROID_SDK_ROOT%" "ndk-bundle" "cmake;%ANDROID_CMAKE_VERSION%" "ndk;%ANDROID_NDK_VERSION%" +if errorlevel 1 goto sdkmanager_failed +popd +popd + +if not exist "%ANDROID_SDK_ROOT%\cmake\%ANDROID_CMAKE_VERSION%\bin\cmake.exe" exit /b 1 +if not exist "%ANDROID_NDK%" exit /b 1 +>"%BUILD_TOOLS_MARKER%" echo %BUILD_TOOLS_MARKER_VERSION% +exit /b 0 + +:sdkmanager_failed +popd +:install_failed +popd +exit /b 1