From b6f26818a93dda947898940af3e552cb683ac938 Mon Sep 17 00:00:00 2001 From: Lev Stipakov Date: Mon, 9 May 2022 13:56:37 +0300 Subject: [PATCH 1/6] Use vcpkg manifest and cmake presets Manifest is a convenient way to automatically install dependencies. Since we have to support both OpenSSL 1.1.1 (for OpenVPN 2.5) and OpenSSL 3 (for coming OpenVPN 2.6) and manifest file name is hardcoded, we create two manifests and put them into different directories. To simplify build process, define configuration presets for arch (x86/x64/arm64), debug/release and oss1.1.1/ossl3. This way building is greatly simplified: cmake -S . --preset x64-debug-ossl3 cmake --build --preset x64-debug-ossl3 Update GitHub Actions script accordingly. Signed-off-by: Lev Stipakov --- .github/workflows/msbuild.yml | 55 +++---- .gitignore | 3 +- CMakeLists.txt | 12 ++ CMakePresets.json | 173 +++++++++++++++++++++++ vcpkg_manifests/openssl_1.1.1/vcpkg.json | 14 ++ vcpkg_manifests/openssl_3/vcpkg.json | 7 + 6 files changed, 224 insertions(+), 40 deletions(-) create mode 100644 CMakePresets.json create mode 100644 vcpkg_manifests/openssl_1.1.1/vcpkg.json create mode 100644 vcpkg_manifests/openssl_3/vcpkg.json diff --git a/.github/workflows/msbuild.yml b/.github/workflows/msbuild.yml index 7403258..1abe1eb 100644 --- a/.github/workflows/msbuild.yml +++ b/.github/workflows/msbuild.yml @@ -6,60 +6,37 @@ jobs: msvc: strategy: matrix: - arch: [x86, amd64, amd64_arm64] - ossl: [openssl, openssl3] - include: - - arch: amd64_arm64 - triplet: arm64 - - arch: x86 - triplet: x86 - - arch: amd64 - triplet: x64 + arch: [x86, x64, arm64] + ossl: [ossl1.1.1, ossl3] env: # Indicates the location of the vcpkg as a Git submodule of the project repository. VCPKG_ROOT: ${{ github.workspace }}/vcpkg - SOLUTION_FILE_PATH: . - BUILD_CONFIGURATION: Release - VCPKG_OVERLAY_PORTS: '${{ github.workspace }}/openvpn/contrib/vcpkg-ports' - buildDir: '${{ github.workspace }}/build/' - name: "msvc - ${{matrix.triplet}} - ${{ matrix.ossl }}" - runs-on: windows-latest + name: 'msvc - ${{matrix.arch}} - ${{ matrix.ossl }}' + runs-on: windows-2019 steps: - uses: actions/checkout@v2 - uses: lukka/get-cmake@latest - - uses: ilammy/msvc-dev-cmd@v1 - with: - arch: ${{ matrix.arch }} - - name: Clone openvpn repo - uses: actions/checkout@v2 + - name: Restore artifacts, or setup vcpkg (do not install any package) + uses: lukka/run-vcpkg@v10 with: - repository: openvpn/openvpn - path: openvpn + vcpkgGitCommitId: "a5d6d145164e82e67fbf91a4a30f98699d30de63" + appendedCacheKey: "${{ matrix.arch }} - ${{ matrix.ossl }}" - - name: Install dependencies - uses: lukka/run-vcpkg@v7.4 + - name: Run CMake consuming CMakePreset.json and vcpkg.json by mean of vcpkg. + uses: lukka/run-cmake@v10 with: - vcpkgGitCommitId: 'b18b17865cfb6bd24620a00f30691be6775abb96' - vcpkgArguments: ${{ matrix.ossl }} - vcpkgTriplet: '${{ matrix.triplet }}-windows' + configurePreset: '${{ matrix.arch }}-release-${{ matrix.ossl }}' + buildPreset: '${{ matrix.arch }}-release-${{ matrix.ossl }}' - - name: Build - uses: lukka/run-cmake@v3 + - uses: actions/upload-artifact@v3 with: - useVcpkgToolchainFile: true - buildWithCMake: true - cmakeBuildType: ${{env.BUILD_CONFIGURATION}} - buildDirectory: ${{ env.buildDir }} - - - uses: actions/upload-artifact@v2 - with: - name: openvpn-gui_${{ matrix.triplet }}_${{ matrix.ossl }} + name: openvpn-gui_${{ matrix.arch }}_${{ matrix.ossl }} path: | - ${{ env.buildDir }}/*.exe - ${{ env.buildDir }}/*.dll + out/build/${{ matrix.arch }}-release-${{ matrix.ossl }}/*.dll + out/build/${{ matrix.arch }}-release-${{ matrix.ossl }}/*.exe mingw: strategy: diff --git a/.gitignore b/.gitignore index 1776075..b1c4b4f 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,5 @@ missing .vs x64 -Debug \ No newline at end of file +Debug +out \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index f34f4f5..befbf4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION 3.10) +if(NOT VCPKG_MANIFEST_DIR) + set(VCPKG_MANIFEST_DIR ${CMAKE_SOURCE_DIR}/vcpkg_manifests/openssl_3) +endif() + project(openvpn-gui C) add_executable(${PROJECT_NAME} WIN32 @@ -66,3 +70,11 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE UNICODE WIN32_LEAN_AND_MEAN HAVE_CONFIG_H) + +if(MSVC) + # work around msvc generator Debug/Release directory ugliness, doesn't apply for Ninja + set_target_properties(${PROJECT_NAME} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<0:> + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<0:> + ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<0:>) +endif(MSVC) \ No newline at end of file diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..73f3a94 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,173 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "base", + "hidden": true, + "binaryDir": "${sourceDir}/out/build/${presetName}", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": { + "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", + "type": "FILEPATH" + } + }, + "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { "hostOS": [ "Windows" ] } } + }, + { + "name": "ossl3", + "hidden": true, + "cacheVariables": { + "VCPKG_MANIFEST_DIR": "${sourceDir}/vcpkg_manifests/openssl_3" + } + }, + { + "name": "ossl1.1.1", + "hidden": true, + "cacheVariables": { + "VCPKG_MANIFEST_DIR": "${sourceDir}/vcpkg_manifests/openssl_1.1.1" + } + }, + { + "name": "x64", + "generator": "Ninja", + "hidden": true, + "architecture": { + "value": "x64", + "strategy": "external" + } + }, + { + "name": "arm64", + "generator": "Ninja", + "hidden": true, + "architecture": { + "value": "arm64", + "strategy": "external" + } + }, + { + "name": "x86", + "generator": "Visual Studio 16 2019", + "hidden": true, + "architecture": { + "value": "Win32" + } + }, + { + "name": "debug", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "release", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "x64-debug-ossl3", + "inherits": [ "base", "ossl3", "x64", "debug" ] + }, + { + "name": "x64-debug-ossl1.1.1", + "inherits": [ "base", "ossl1.1.1", "x64", "debug" ] + }, + { + "name": "arm64-debug-ossl3", + "inherits": [ "base", "ossl3", "arm64", "debug" ] + }, + { + "name": "arm64-debug-ossl1.1.1", + "inherits": [ "base", "ossl1.1.1", "arm64", "debug" ] + }, + { + "name": "x86-debug-ossl3", + "inherits": [ "base", "ossl3", "x86", "debug" ] + }, + { + "name": "x86-debug-ossl1.1.1", + "inherits": [ "base", "ossl1.1.1", "x86", "debug" ] + }, + { + "name": "x64-release-ossl3", + "inherits": [ "base", "ossl3", "x64", "release" ] + }, + { + "name": "x64-release-ossl1.1.1", + "inherits": [ "base", "ossl1.1.1", "x64", "release" ] + }, + { + "name": "arm64-release-ossl3", + "inherits": [ "base", "ossl3", "arm64", "release" ] + }, + { + "name": "arm64-release-ossl1.1.1", + "inherits": [ "base", "ossl1.1.1", "arm64", "release" ] + }, + { + "name": "x86-release-ossl3", + "inherits": [ "base", "ossl3", "x86", "release" ] + }, + { + "name": "x86-release-ossl1.1.1", + "inherits": [ "base", "ossl1.1.1", "x86", "release" ] + } + ], + "buildPresets": [ + { + "name": "x64-release-ossl3", + "configurePreset": "x64-release-ossl3" + }, + { + "name": "x64-release-ossl1.1.1", + "configurePreset": "x64-release-ossl1.1.1" + }, + { + "name": "x86-release-ossl3", + "configurePreset": "x86-release-ossl3", + "configuration": "Release" + }, + { + "name": "x86-release-ossl1.1.1", + "configurePreset": "x86-release-ossl1.1.1", + "configuration": "Release" + }, + { + "name": "arm64-release-ossl3", + "configurePreset": "arm64-release-ossl3" + }, + { + "name": "arm64-release-ossl1.1.1", + "configurePreset": "arm64-release-ossl1.1.1" + }, + { + "name": "x64-debug-ossl3", + "configurePreset": "x64-debug-ossl3" + }, + { + "name": "x64-debug-ossl1.1.1", + "configurePreset": "x64-debug-ossl1.1.1" + }, + { + "name": "x86-debug-ossl3", + "configurePreset": "x86-debug-ossl3", + "configuration": "Debug" + }, + { + "name": "x86-debug-ossl1.1.1", + "configurePreset": "x86-debug-ossl1.1.1", + "configuration": "Debug" + }, + { + "name": "arm64-debug-ossl3", + "configurePreset": "arm64-debug-ossl3" + }, + { + "name": "arm64-debug-ossl1.1.1", + "configurePreset": "arm64-debug-ossl1.1.1" + } + ] +} diff --git a/vcpkg_manifests/openssl_1.1.1/vcpkg.json b/vcpkg_manifests/openssl_1.1.1/vcpkg.json new file mode 100644 index 0000000..a9764bb --- /dev/null +++ b/vcpkg_manifests/openssl_1.1.1/vcpkg.json @@ -0,0 +1,14 @@ +{ + "name": "openvpn-gui", + "version-string": "0.0.1", + "dependencies": [ + "openssl" + ], + "builtin-baseline": "4b766c1cd17205e1b768c4fadfd5f867c1d0510e", + "overrides": [ + { + "name": "openssl", + "version-string": "1.1.1n" + } + ] +} \ No newline at end of file diff --git a/vcpkg_manifests/openssl_3/vcpkg.json b/vcpkg_manifests/openssl_3/vcpkg.json new file mode 100644 index 0000000..96db2ed --- /dev/null +++ b/vcpkg_manifests/openssl_3/vcpkg.json @@ -0,0 +1,7 @@ +{ + "name": "openvpn-gui", + "version-string": "0.0.1", + "dependencies": [ + "openssl" + ] +} \ No newline at end of file From 307e043d7e10a8330096da482b116c2db489d0d5 Mon Sep 17 00:00:00 2001 From: Lev Stipakov Date: Mon, 9 May 2022 15:43:30 +0300 Subject: [PATCH 2/6] build.rst: add MSVC build instructions Signed-off-by: Lev Stipakov --- BUILD.rst | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/BUILD.rst b/BUILD.rst index 71db598..8fd2634 100644 --- a/BUILD.rst +++ b/BUILD.rst @@ -1,3 +1,46 @@ +How to build with MSVC +====================== + +This is the recommended way of building openvpn-gui on Windows, which is also used when doing OpenVPN Windows releases. + +Prerequisites +------------- + + - Visual Studio 2019 (build tools should be enough, also 2022 will likely work) + - CMake + - vcpkg (add the environment variable ``VCPKG_ROOT`` which points to vcpkg installation) + +Build steps +----------- + +Run inside MSVC command prompt: + +.. code-block:: + + c:\Temp\openvpn-gui>cmake -S . --preset x64-release-ossl3 + c:\Temp\openvpn-gui>cmake --build --preset x64-release-ossl3 + +To see all presets, run: + +.. code-block:: + + C:\Users\lev\Projects\openvpn-gui>cmake -S c:\Users\lev\Projects\openvpn-gui --list-presets + Available configure presets: + "x64-debug-ossl3" + "x64-debug-ossl1.1.1" + "arm64-debug-ossl3" + "arm64-debug-ossl1.1.1" + "x86-debug-ossl3" + "x86-debug-ossl1.1.1" + "x64-release-ossl3" + "x64-release-ossl1.1.1" + "arm64-release-ossl3" + "arm64-release-ossl1.1.1" + "x86-release-ossl3" + "x86-release-ossl1.1.1" + +You could also open CMake project from MSVC IDE and build from there. + How to build using Cygwin ========================= From 09aa7ef73031b0beeb42f59a70440b09f4568f2a Mon Sep 17 00:00:00 2001 From: Lev Stipakov Date: Wed, 25 May 2022 14:06:48 +0300 Subject: [PATCH 3/6] CMakePresets.json: use MSVC generator for ARM64 builds Sadly, CMake/Ninja combo doesn't work well for ARM64 (similar to https://stackoverflow.com/questions/47581784/building-a-x86-application-with-cmake-ninja-and-clang-on-x64-windows) - it silently produces x64 binaries instead of arm64. Switch to slower MSVC generator. Signed-off-by: Lev Stipakov --- CMakePresets.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 73f3a94..f48ccbf 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -38,11 +38,10 @@ }, { "name": "arm64", - "generator": "Ninja", + "generator": "Visual Studio 16 2019", "hidden": true, "architecture": { - "value": "arm64", - "strategy": "external" + "value": "arm64" } }, { From a85bba9654848903d7a12bc7009d9f6ff8049459 Mon Sep 17 00:00:00 2001 From: Lev Stipakov Date: Thu, 26 May 2022 16:56:34 +0300 Subject: [PATCH 4/6] CMakePresets: fix arm64 debug/release config Signed-off-by: Lev Stipakov --- CMakePresets.json | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index f48ccbf..693574f 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -136,11 +136,13 @@ }, { "name": "arm64-release-ossl3", - "configurePreset": "arm64-release-ossl3" + "configurePreset": "arm64-release-ossl3", + "configuration": "Release" }, { "name": "arm64-release-ossl1.1.1", - "configurePreset": "arm64-release-ossl1.1.1" + "configurePreset": "arm64-release-ossl1.1.1", + "configuration": "Release" }, { "name": "x64-debug-ossl3", @@ -162,11 +164,13 @@ }, { "name": "arm64-debug-ossl3", - "configurePreset": "arm64-debug-ossl3" + "configurePreset": "arm64-debug-ossl3", + "configuration": "Debug" }, { "name": "arm64-debug-ossl1.1.1", - "configurePreset": "arm64-debug-ossl1.1.1" + "configurePreset": "arm64-debug-ossl1.1.1", + "configuration": "Debug" } ] } From 271648c6c3d37d789205d8b6a1cdabbc100b3ad0 Mon Sep 17 00:00:00 2001 From: Lev Stipakov Date: Mon, 30 May 2022 15:53:02 +0300 Subject: [PATCH 5/6] cmake: replace Ninja generator with MSVC Ninja makes build slightly faster but requires running "x64" developer command prompt, not the "default" one. Without that, cmake silenly produces x86 binaries and it might take a while to find out the reason. To avoid confusion, switch back to MSVC generator. Signed-off-by: Lev Stipakov --- CMakePresets.json | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 693574f..df4efd0 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -5,6 +5,7 @@ "name": "base", "hidden": true, "binaryDir": "${sourceDir}/out/build/${presetName}", + "generator": "Visual Studio 16 2019", "cacheVariables": { "CMAKE_TOOLCHAIN_FILE": { "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", @@ -29,16 +30,13 @@ }, { "name": "x64", - "generator": "Ninja", "hidden": true, "architecture": { - "value": "x64", - "strategy": "external" + "value": "x64" } }, { "name": "arm64", - "generator": "Visual Studio 16 2019", "hidden": true, "architecture": { "value": "arm64" @@ -46,7 +44,6 @@ }, { "name": "x86", - "generator": "Visual Studio 16 2019", "hidden": true, "architecture": { "value": "Win32" @@ -118,11 +115,13 @@ "buildPresets": [ { "name": "x64-release-ossl3", - "configurePreset": "x64-release-ossl3" + "configurePreset": "x64-release-ossl3", + "configuration": "Release" }, { "name": "x64-release-ossl1.1.1", - "configurePreset": "x64-release-ossl1.1.1" + "configurePreset": "x64-release-ossl1.1.1", + "configuration": "Release" }, { "name": "x86-release-ossl3", @@ -146,11 +145,13 @@ }, { "name": "x64-debug-ossl3", - "configurePreset": "x64-debug-ossl3" + "configurePreset": "x64-debug-ossl3", + "configuration": "Debug" }, { "name": "x64-debug-ossl1.1.1", - "configurePreset": "x64-debug-ossl1.1.1" + "configurePreset": "x64-debug-ossl1.1.1", + "configuration": "Debug" }, { "name": "x86-debug-ossl3", From 8f3c7a0b388499503876cd364587b7c80fa5e5d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuli=20Sepp=C3=A4nen?= Date: Tue, 31 May 2022 11:51:57 +0000 Subject: [PATCH 6/6] Bump version to 11.29 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Samuli Seppänen --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d623f8b..0b14637 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ dnl 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA AC_PREREQ(2.59) define([_GUI_VERSION_MAJOR], [11]) -define([_GUI_VERSION_MINOR], [27]) +define([_GUI_VERSION_MINOR], [29]) AC_INIT([OpenVPN GUI],[_GUI_VERSION_MAJOR],[openvpn-devel@lists.sourceforge.net],[openvpn-gui],[https://github.com/openvpn/openvpn-gui/]) AC_DEFINE([PACKAGE_VERSION_RESOURCE], [_GUI_VERSION_MAJOR,_GUI_VERSION_MINOR,0,0], [Version in windows resource format]) AC_DEFINE([PACKAGE_VERSION_RESOURCE_STR], ["_GUI_VERSION_MAJOR._GUI_VERSION_MINOR.0.0"], [Version as a string])