From eea1b41340e2cd88e8dced5dec607aab549bc517 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Fri, 7 Mar 2025 22:45:46 +0400 Subject: [PATCH] Add linux build. --- Patches/1.4.1/Patch005.patch | 22 ++++++ azure-pipelines.yml | 128 +++++++++++++++++++++++++++++++++-- 2 files changed, 146 insertions(+), 4 deletions(-) create mode 100644 Patches/1.4.1/Patch005.patch diff --git a/Patches/1.4.1/Patch005.patch b/Patches/1.4.1/Patch005.patch new file mode 100644 index 0000000..9f7e726 --- /dev/null +++ b/Patches/1.4.1/Patch005.patch @@ -0,0 +1,22 @@ +From 4331d31d113a75bbb8019d46577a1268966acb88 Mon Sep 17 00:00:00 2001 +From: Anton Vasiliev +Date: Sat, 8 Mar 2025 14:35:36 +0400 +Subject: [PATCH] Update minimum required CMake version. + +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 90899a4..7e025f2 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.9) ++cmake_minimum_required(VERSION 3.10) + + # If vcpkg present as submodule, bring in the toolchain + if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake ) +-- +2.48.1.windows.1 + diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0544dcb..753755f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -20,36 +20,43 @@ jobs: CMAKE_ADDITIONAL_PARAMETERS: -DUSE_CRYPTO=OpenSSL -DVCPKG_OVERLAY_TRIPLETS=$(Agent.BuildDirectory)\Source\triplets -DVCPKG_TARGET_TRIPLET=x64-windows-release -DVCPKG_HOST_TRIPLET=x64-windows-release CMAKE_PLATFORM: x64 MSBUILD_PLATFORM: x64 + x64_libsodium_dynamic_deps: matrixName: x64_libsodium_dynamic_deps CMAKE_ADDITIONAL_PARAMETERS: -DUSE_CRYPTO=libsodium -DVCPKG_MANIFEST_FEATURES=libsodium -DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON -DVCPKG_OVERLAY_TRIPLETS=$(Agent.BuildDirectory)\Source\triplets -DVCPKG_TARGET_TRIPLET=x64-windows-release -DVCPKG_HOST_TRIPLET=x64-windows-release CMAKE_PLATFORM: x64 MSBUILD_PLATFORM: x64 + x86_openssl_dynamic_deps: matrixName: x86_openssl_dynamic_deps CMAKE_ADDITIONAL_PARAMETERS: -DUSE_CRYPTO=OpenSSL -DVCPKG_OVERLAY_TRIPLETS=$(Agent.BuildDirectory)\Source\triplets -DVCPKG_TARGET_TRIPLET=x86-windows-release -DVCPKG_HOST_TRIPLET=x64-windows-release CMAKE_PLATFORM: win32 MSBUILD_PLATFORM: win32 + x86_libsodium_dynamic_deps: matrixName: x86_libsodium_dynamic_deps CMAKE_ADDITIONAL_PARAMETERS: -DUSE_CRYPTO=libsodium -DVCPKG_MANIFEST_FEATURES=libsodium -DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON -DVCPKG_OVERLAY_TRIPLETS=$(Agent.BuildDirectory)\Source\triplets -DVCPKG_TARGET_TRIPLET=x86-windows-release -DVCPKG_HOST_TRIPLET=x64-windows-release CMAKE_PLATFORM: win32 MSBUILD_PLATFORM: win32 + x64_openssl_static_deps: matrixName: x64_openssl_static_deps CMAKE_ADDITIONAL_PARAMETERS: -DUSE_CRYPTO=OpenSSL -DVCPKG_OVERLAY_TRIPLETS=$(Agent.BuildDirectory)\Source\triplets -DVCPKG_TARGET_TRIPLET=x64-windows-static-deps-md-release -DVCPKG_HOST_TRIPLET=x64-windows-release -DProtobuf_USE_STATIC_LIBS=ON CMAKE_PLATFORM: x64 MSBUILD_PLATFORM: x64 + x64_libsodium_static_deps: matrixName: x64_libsodium_static_deps CMAKE_ADDITIONAL_PARAMETERS: -DUSE_CRYPTO=libsodium -DVCPKG_MANIFEST_FEATURES=libsodium -DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON -DVCPKG_OVERLAY_TRIPLETS=$(Agent.BuildDirectory)\Source\triplets -DVCPKG_TARGET_TRIPLET=x64-windows-static-deps-md-release -DVCPKG_HOST_TRIPLET=x64-windows-release -DProtobuf_USE_STATIC_LIBS=ON CMAKE_PLATFORM: x64 MSBUILD_PLATFORM: x64 + x86_openssl_static_deps: matrixName: x86_openssl_static_deps CMAKE_ADDITIONAL_PARAMETERS: -DUSE_CRYPTO=OpenSSL -DVCPKG_OVERLAY_TRIPLETS=$(Agent.BuildDirectory)\Source\triplets -DVCPKG_TARGET_TRIPLET=x86-windows-static-deps-md-release -DVCPKG_HOST_TRIPLET=x64-windows-release -DProtobuf_USE_STATIC_LIBS=ON CMAKE_PLATFORM: win32 MSBUILD_PLATFORM: win32 + x86_libsodium_static_deps: matrixName: x86_libsodium_static_deps CMAKE_ADDITIONAL_PARAMETERS: -DUSE_CRYPTO=libsodium -DVCPKG_MANIFEST_FEATURES=libsodium -DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON -DVCPKG_OVERLAY_TRIPLETS=$(Agent.BuildDirectory)\Source\triplets -DVCPKG_TARGET_TRIPLET=x86-windows-static-deps-md-release -DVCPKG_HOST_TRIPLET=x64-windows-release -DProtobuf_USE_STATIC_LIBS=ON @@ -73,6 +80,7 @@ jobs: displayName: "Shallow clone GNS" inputs: script: | + git config --global init.defaultBranch main git init git remote add origin $(GNS_REPOSITORY_URL) git fetch --depth 1 origin $(GNS_COMMIT_HASH) @@ -86,10 +94,11 @@ jobs: displayName: "Apply patches" inputs: script: | - git apply $(Build.SourcesDirectory)\Patches\$(GNS_PATCH_SET)\Patch001.patch - git apply $(Build.SourcesDirectory)\Patches\$(GNS_PATCH_SET)\Patch002.patch - git apply $(Build.SourcesDirectory)\Patches\$(GNS_PATCH_SET)\Patch003.patch + git apply --whitespace=nowarn $(Build.SourcesDirectory)\Patches\$(GNS_PATCH_SET)\Patch001.patch + git apply --whitespace=nowarn $(Build.SourcesDirectory)\Patches\$(GNS_PATCH_SET)\Patch002.patch + git apply --whitespace=nowarn $(Build.SourcesDirectory)\Patches\$(GNS_PATCH_SET)\Patch003.patch git apply --whitespace=nowarn $(Build.SourcesDirectory)\Patches\$(GNS_PATCH_SET)\Patch004.patch + git apply --whitespace=nowarn $(Build.SourcesDirectory)\Patches\$(GNS_PATCH_SET)\Patch005.patch workingDirectory: $(Agent.BuildDirectory)\Source failOnStderr: true @@ -103,7 +112,7 @@ jobs: - task: MSBuild@1 inputs: - solution: '$(Agent.BuildDirectory)\Build\GameNetworkingSockets.sln' + solution: '$(Agent.BuildDirectory)\Build\GameNetworkingSockets.sln' platform: $(MSBUILD_PLATFORM) configuration: Release @@ -128,3 +137,114 @@ jobs: inputs: pathToPublish: '$(Agent.BuildDirectory)\Build\bin\Release' artifactName: $(matrixName) + +- job: build_linux_vcpkg + pool: + vmImage: 'ubuntu-22.04' + + strategy: + matrix: +# This does NOT produce libGameNetworkingSockets.so with dynamically linked protobuf and openssl. +# To link with dependencies dynamically, packages must be provided by the system and not with vckpg. +# x64_openssl_dynamic_deps: +# matrixName: x64_openssl_dynamic_deps +# CMAKE_ADDITIONAL_PARAMETERS: -DUSE_CRYPTO=OpenSSL + + x64_openssl_static_deps: + matrixName: x64_openssl_static_deps + CMAKE_ADDITIONAL_PARAMETERS: -DUSE_CRYPTO=OpenSSL -DProtobuf_USE_STATIC_LIBS=ON + + variables: + CMAKE_GENERATOR: Ninja + + steps: + - task: CmdLine@2 + displayName: "Install dependencies" + inputs: + script: | + sudo apt update + sudo apt upgrade --assume-yes + sudo apt install build-essential cmake ninja-build pkg-config --assume-yes + workingDirectory: $(Agent.BuildDirectory) + failOnStderr: false + + - task: CmdLine@2 + displayName: "Create directory structure" + inputs: + script: | + mkdir Source + mkdir Build + workingDirectory: $(Agent.BuildDirectory) + failOnStderr: true + + - task: CmdLine@2 + displayName: "Shallow clone GNS" + inputs: + script: | + git config --global init.defaultBranch main + git init + git remote add origin $(GNS_REPOSITORY_URL) + git fetch --depth 1 origin $(GNS_COMMIT_HASH) + git config --local advice.detachedHead false + git checkout FETCH_HEAD + git submodule update --init --depth 1 + workingDirectory: $(Agent.BuildDirectory)/Source + failOnStderr: false + + - task: CmdLine@2 + displayName: "Apply patches" + inputs: + script: | + git apply --whitespace=nowarn $(Build.SourcesDirectory)/Patches/$(GNS_PATCH_SET)/Patch001.patch + git apply --whitespace=nowarn $(Build.SourcesDirectory)/Patches/$(GNS_PATCH_SET)/Patch002.patch + git apply --whitespace=nowarn $(Build.SourcesDirectory)/Patches/$(GNS_PATCH_SET)/Patch003.patch + git apply --whitespace=nowarn $(Build.SourcesDirectory)/Patches/$(GNS_PATCH_SET)/Patch004.patch + git apply --whitespace=nowarn $(Build.SourcesDirectory)/Patches/$(GNS_PATCH_SET)/Patch005.patch + workingDirectory: $(Agent.BuildDirectory)/Source + failOnStderr: true + + - task: CmdLine@2 + displayName: "CMake generate solution" + inputs: + script: | + cmake -G "$(CMAKE_GENERATOR)" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES=Release -B Build -S Source -DCMAKE_TOOLCHAIN_FILE=$(VCPKG_INSTALLATION_ROOT)/scripts/buildsystems/vcpkg.cmake -DBUILD_STATIC_LIB=ON -DBUILD_TESTS=ON -DENABLE_ICE=OFF -DLTO=ON $(CMAKE_ADDITIONAL_PARAMETERS) + workingDirectory: $(Agent.BuildDirectory) + failOnStderr: true + + - task: CmdLine@2 + displayName: "Build with Ninja" + inputs: + script: | + ninja + workingDirectory: $(Agent.BuildDirectory)/Build/ + failOnStderr: true + + - task: CmdLine@2 + displayName: "List dependencies" + inputs: + script: | + objdump -p ./libGameNetworkingSockets.so + workingDirectory: $(Agent.BuildDirectory)/Build/bin + failOnStderr: true + + - task: CmdLine@2 + displayName: "Run connection tests" + inputs: + script: | + ./test_connection suite-quick + workingDirectory: $(Agent.BuildDirectory)/Build/bin + failOnStderr: true + + - task: CmdLine@2 + displayName: "Run cryptography tests" + inputs: + script: | + ./test_crypto + workingDirectory: $(Agent.BuildDirectory)/Build/bin + failOnStderr: true + + - task: PublishBuildArtifacts@1 + displayName: "Publish artifacts" + inputs: + pathToPublish: '$(Agent.BuildDirectory)/Build/bin' + artifactName: $(matrixName)