diff --git a/.github/workflows/build-windows-vs2019.yaml b/.github/workflows/build-windows-vs2022.yaml similarity index 75% rename from .github/workflows/build-windows-vs2019.yaml rename to .github/workflows/build-windows-vs2022.yaml index a454fb59c..a8a18394e 100644 --- a/.github/workflows/build-windows-vs2019.yaml +++ b/.github/workflows/build-windows-vs2022.yaml @@ -1,4 +1,4 @@ -name: C/C++ CI on Windows (vs2019) +name: C/C++ CI on Windows (vs2022) on: push: @@ -16,7 +16,7 @@ on: jobs: build: - runs-on: windows-2019 + runs-on: windows-2022 name: Build steps: @@ -29,7 +29,7 @@ jobs: env: SKIP_ARM_BUILD: 1 SKIP_ARM64_BUILD: 1 - PlatformToolset: v142 - VSTOOLS_VERSION: vs2019 + PlatformToolset: v143 + VSTOOLS_VERSION: vs2022 shell: cmd run: build-all.bat diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 5dc91e80c..d36a50b39 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -17,7 +17,7 @@ on: jobs: analyze: name: Analyze - runs-on: windows-2019 + runs-on: windows-2022 permissions: contents: read actions: read @@ -28,7 +28,7 @@ jobs: matrix: # Override automatic language detection by changing the below list # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] - language: ['cpp', 'csharp', 'javascript', 'python'] + language: ['cpp', 'javascript', 'python'] # Learn more... # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection @@ -47,18 +47,17 @@ jobs: # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # Autobuild attempts to build any compiled languages (C/C++, or Java). # If this step fails, then you should remove it and run the build manually (see below) - # - name: Autobuild - # uses: github/codeql-action/autobuild@v3 - - name: Build + - name: Build C++ env: SKIP_ARM_BUILD: 1 SKIP_ARM64_BUILD: 1 - PlatformToolset: v142 - VSTOOLS_VERSION: vs2019 + PlatformToolset: v143 + VSTOOLS_VERSION: vs2022 + WindowsSDKVersion: 10.0.22621.0 shell: cmd - if: matrix.language == 'cpp' || matrix.language == 'csharp' + if: matrix.language == 'cpp' run: build-all.bat # ℹ️ Command-line programs to run using the OS shell. diff --git a/.github/workflows/test-win-latest.yml b/.github/workflows/test-win-latest.yml index 5f2780401..760c88fb0 100644 --- a/.github/workflows/test-win-latest.yml +++ b/.github/workflows/test-win-latest.yml @@ -27,7 +27,7 @@ jobs: matrix: arch: [Win32, x64] build: [Release, Debug] - os: [windows-2019] + os: [windows-2022] steps: diff --git a/README.md b/README.md index 6c8978858..892eb5d62 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ Other resources to learn how to setup the build system: | Ubuntu 18.04 LTS | GCC 7.5.x | | Windows 10 | Android Studio/Gradle | | Windows Server 2016 | Visual Studio 2017 (vc141) | - | Windows Server 2019 | Visual Studio 2019 (vc142) | + | Windows Server 2022 | Visual Studio 2022 (vc143) | ## Target Platforms @@ -96,7 +96,8 @@ Other resources to learn how to setup the build system: | Windows 10.x | :white_check_mark: | | | Windows Server 2012 | :white_check_mark: | | | Windows Server 2016 | :white_check_mark: | | - | Windows Server 2019 | :white_check_mark: | :white_check_mark: | + | Windows Server 2019 | :white_check_mark: | | + | Windows Server 2022 | :white_check_mark: | :white_check_mark: | * **Supported** - these platforms are known to work well with the SDK in production. diff --git a/build-cmake-clang-vs2022.cmd b/build-cmake-clang-vs2022.cmd new file mode 100644 index 000000000..00197c980 --- /dev/null +++ b/build-cmake-clang-vs2022.cmd @@ -0,0 +1,81 @@ +@echo off + +set VSTOOLS_VERSION=vs2022 +cd %~dp0 + +echo Update all public submodules... +git -c submodule."lib/modules".update=none submodule update --init --recursive + +if DEFINED GIT_PULL_TOKEN ( + rd /s /q lib\modules + git clone https://%GIT_PULL_TOKEN%:x-oauth-basic@github.com/microsoft/cpp_client_telemetry_modules.git lib\modules +) + +call tools\vcvars.cmd + +setlocal enableextensions +setlocal enabledelayedexpansion +set ROOT=%~dp0 + +REM ******************************************************************** +REM Use cmake +REM ******************************************************************** +set "PATH=C:\Program Files\CMake\bin\;%PATH%" + +REM ******************************************************************** +REM Use clang compiler +REM ******************************************************************** +set CLANG_PATH="C:\Program Files\LLVM\bin" +set CC=%CLANG_PATH%\clang.exe +set CXX=%CLANG_PATH%\clang++.exe +set LLVM_VER=ClangCL + +REM ******************************************************************** +REM Set output directory, clean and/or create as-needed +REM ******************************************************************** +set OUTDIR=%ROOT%\Solutions\out +if "%1" == "clean" ( + @rmdir /s /q %OUTDIR% +) +if not exist "%OUTDIR%" mkdir %OUTDIR% + +REM ******************************************************************** +REM Build all deps using MSVC - Visual Studio 2022 (17) +REM ******************************************************************** +if "%1" == "nodeps" goto NODEPS +call tools\build-deps.cmd +:NODEPS + +cd %OUTDIR% + +REM ******************************************************************** +REM Invoke the build script +REM ******************************************************************** +set CMAKE_PACKAGE_TYPE=tgz +for %%a in ( m32 m64 ) do ( + for %%c in ( Release ) do ( + if "%%a"=="m32" ( + set ARCH=Win32 + set ARCH_GEN= Win32 + ) + if "%%a"=="m64" ( + set ARCH=x64 + set ARCH_GEN= x64 + ) + @mkdir %OUTDIR%\%%c\!ARCH! + cd %OUTDIR%\%%c\!ARCH! + set "CFLAGS=-%%a" + set "CXXFLAGS=-%%a -Wc++11-compat-pedantic -Wno-c++98-compat -Wno-everything" + cmake -G"Visual Studio 17 2022" -A !ARCH_GEN! ^ + -T"%LLVM_VER%" ^ + -DTARGET_ARCH=!ARCH! ^ + -DBUILD_SHARED_LIBS=OFF ^ + -DCMAKE_BUILD_TYPE=%%c ^ + -DCMAKE_PACKAGE_TYPE=%CMAKE_PACKAGE_TYPE% ^ + -DDEFAULT_PAL_IMPLEMENTATION=WIN32 ^ + %ROOT% + cmake --build . --config %%c -- /p:Configuration=%%c + ) +) + +cd %ROOT% \ No newline at end of file diff --git a/docs/cpp-start-windows.md b/docs/cpp-start-windows.md index dbdfda0aa..ef5850d84 100644 --- a/docs/cpp-start-windows.md +++ b/docs/cpp-start-windows.md @@ -16,7 +16,7 @@ If your project requires the Universal Telemetry Client (a.k.a. UTC) to send tel ## **Windows prerequisites and dependencies for building from source** -* Visual Studio 2017 or 2019 (2019 is recommended). +* Visual Studio 2019 or 2022 (2022 is recommended). * C++ Dev Tools ## **Option 1: Build the SDK from source using Visual Studio** @@ -58,11 +58,11 @@ Make sure you can build a simple "Hello World" using CMake before proceeding to To build SDK using cmake with clang on Windows, run: -```build-cmake-clang-vs2017.cmd``` +```build-cmake-clang-vs2019.cmd``` or -```build-cmake-clang-vs2019.cmd``` +```build-cmake-clang-vs2022.cmd``` depending on what Visual Studio version you are using. @@ -113,6 +113,6 @@ More examples can be found under *examples* folder. - [CMake Tutorial](https://cmake.org/cmake/help/latest/guide/tutorial/index.html) - [Runtime Library Variants: static vs dynamic runtime](https://www.oreilly.com/library/view/c-cookbook/0596007612/ch01s24.html) -If you encounter troubles building the project, please refer to our CI/Build pipeline settings [here](../.github/workflows/build-windows-vs2019.yaml). This pipeline runs on a standard GitHub image with a standard Visual Studio 2019 installation. If you are still stuck, please log your build question as [GitHub issue](https://github.com/microsoft/cpp_client_telemetry/issues) with labels `question` and `build infra`. We would be glad to help and adjust documentation accordingly. +If you encounter troubles building the project, please refer to our CI/Build pipeline settings [here](../.github/workflows/build-windows-vs2022.yaml). This pipeline runs on a standard GitHub image with a standard Visual Studio 2022 installation. If you are still stuck, please log your build question as [GitHub issue](https://github.com/microsoft/cpp_client_telemetry/issues) with labels `question` and `build infra`. We would be glad to help and adjust documentation accordingly. If you find that some documentation is incorrect, please send a PR to fix it. We ❤️ community contributions!