From 376942cad2c8eba68e9bdc119f842e9fe876fee1 Mon Sep 17 00:00:00 2001 From: Oleg Yukhnevich Date: Mon, 8 Jan 2024 23:17:23 +0200 Subject: [PATCH] Return back Windows (msvc) support * revert splitting lib directory --- .github/workflows/build.main.kts | 98 +++++++++++++++++++------------- .github/workflows/build.yaml | 22 +++---- packages/openssl3/conanfile.py | 31 ++++++---- profiles/windows-x64 | 7 +++ 4 files changed, 97 insertions(+), 61 deletions(-) create mode 100644 profiles/windows-x64 diff --git a/.github/workflows/build.main.kts b/.github/workflows/build.main.kts index ceeda0c..66bab3b 100755 --- a/.github/workflows/build.main.kts +++ b/.github/workflows/build.main.kts @@ -1,6 +1,7 @@ #!/usr/bin/env kotlin @file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.8.0") +@file:Suppress("PropertyName") import io.github.typesafegithub.workflows.actions.actions.* import io.github.typesafegithub.workflows.domain.* @@ -10,56 +11,69 @@ import io.github.typesafegithub.workflows.dsl.* import io.github.typesafegithub.workflows.dsl.expressions.* import io.github.typesafegithub.workflows.yaml.* +val LinuxRunner = Ubuntu2004 +val MacosRunner = MacOSLatest +val WindowsRunner = WindowsLatest + class Configuration( val name: String, val runnerType: RunnerType, - // 'profile name' to 'supports shared' - val profiles: List> + val profiles: List> ) +enum class BuildKind( + val buildDynamic: Boolean, + val buildStatic: Boolean +) { + Dynamic(true, false), + Static(false, true), + Both(true, true) +} + val configurations = listOf( Configuration( name = "macos", - runnerType = MacOSLatest, + runnerType = MacosRunner, profiles = listOf( - "tvos-simulator-arm64" to false, - "tvos-simulator-x64" to false, - "tvos-device-arm64" to false, - - "watchos-simulator-arm64" to false, - "watchos-simulator-x64" to false, - "watchos-device-arm32" to false, - "watchos-device-arm64" to false, - "watchos-device-arm64_32" to false, - - "ios-device-arm64" to false, - "ios-simulator-arm64" to false, - "ios-simulator-x64" to false, - - "macos-x64" to true, - "macos-arm64" to true, + "tvos-simulator-arm64" to BuildKind.Static, + "tvos-simulator-x64" to BuildKind.Static, + "tvos-device-arm64" to BuildKind.Static, + + "watchos-simulator-arm64" to BuildKind.Static, + "watchos-simulator-x64" to BuildKind.Static, + "watchos-device-arm32" to BuildKind.Static, + "watchos-device-arm64" to BuildKind.Static, + "watchos-device-arm64_32" to BuildKind.Static, + + "ios-device-arm64" to BuildKind.Static, + "ios-simulator-arm64" to BuildKind.Static, + "ios-simulator-x64" to BuildKind.Static, + + "macos-x64" to BuildKind.Both, + "macos-arm64" to BuildKind.Both, ) ), Configuration( name = "linux", - runnerType = Ubuntu2004, + runnerType = LinuxRunner, profiles = listOf( - "android-arm64" to true, - "android-arm32" to true, - "android-x64" to true, - "android-x86" to true, + "android-arm64" to BuildKind.Both, + "android-arm32" to BuildKind.Both, + "android-x64" to BuildKind.Both, + "android-x86" to BuildKind.Both, - "linux-x64" to true, - "linux-arm64" to true, + "linux-x64" to BuildKind.Both, + "linux-arm64" to BuildKind.Both, - "wasm" to false, + "wasm" to BuildKind.Static, ) ), Configuration( name = "windows", - runnerType = WindowsLatest, + runnerType = WindowsRunner, profiles = listOf( - "mingw-x64" to true + "mingw-x64" to BuildKind.Both, + "windows-x64" to BuildKind.Dynamic, ) ) ) @@ -86,6 +100,7 @@ fun conanCommand(profile: String, version: String, shared: String, command: Stri workflow( name = "Build", on = listOf( +// Push(), WorkflowDispatch( inputs = mapOf( "version" to WorkflowDispatch.Input( @@ -105,6 +120,7 @@ workflow( ), sourceFile = __FILE__.toPath(), ) { + //val version = "3.2.0" val version = expr("inputs.version") val jobs = configurations.map { configuration -> job( @@ -114,29 +130,31 @@ workflow( ) { uses(action = CheckoutV4(submodules = true)) uses(action = SetupPythonV5(pythonVersion = "3.x")) + run(command = "pip install conan") run(command = "conan profile detect") - if (configuration.runnerType == Ubuntu2004) { + if (configuration.runnerType == LinuxRunner) { run(command = "sudo apt update") run(command = "sudo apt install g++-8-aarch64-linux-gnu g++-8") } - configuration.profiles.forEach { (profile, supportsShared) -> - if (supportsShared) { + configuration.profiles.forEach { (profile, buildKind) -> + if (buildKind.buildDynamic) { run(command = conanCreateCommand(profile, version, "True")) run(command = conanInstallCommand(profile, version, "True")) } - run(command = conanCreateCommand(profile, version, "False")) - run(command = conanInstallCommand(profile, version, "False")) + if (buildKind.buildStatic) { + run(command = conanCreateCommand(profile, version, "False")) + run(command = conanInstallCommand(profile, version, "False")) + } } - listOf( - "build/openssl3/*/dynamicLib", - "build/openssl3/*/staticLib", - "build/openssl3/*/include", - ).forEach { path -> - run(command = "tar -rvf ${configuration.name}.tar $path") + when (configuration.runnerType) { + WindowsRunner -> listOf("lib", "include", "bin") + else -> listOf("lib", "include") + }.forEach { folder -> + run(command = "tar -rvf ${configuration.name}.tar build/openssl3/*/$folder") } uses( diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1466df5..9e92059 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -91,12 +91,10 @@ jobs: - id: 'step-33' run: 'conan install packages/openssl3 --output-folder build/openssl3/macos-arm64 --version=${{ inputs.version }} -pr:b default -pr:h profiles/macos-arm64 -o "*:shared=False"' - id: 'step-34' - run: 'tar -rvf macos.tar build/openssl3/*/dynamicLib' + run: 'tar -rvf macos.tar build/openssl3/*/lib' - id: 'step-35' - run: 'tar -rvf macos.tar build/openssl3/*/staticLib' - - id: 'step-36' run: 'tar -rvf macos.tar build/openssl3/*/include' - - id: 'step-37' + - id: 'step-36' uses: 'actions/upload-artifact@v4' with: name: 'openssl-macos-${{ inputs.version }}' @@ -175,12 +173,10 @@ jobs: - id: 'step-31' run: 'conan install packages/openssl3 --output-folder build/openssl3/wasm --version=${{ inputs.version }} -pr:b default -pr:h profiles/wasm -o "*:shared=False"' - id: 'step-32' - run: 'tar -rvf linux.tar build/openssl3/*/dynamicLib' + run: 'tar -rvf linux.tar build/openssl3/*/lib' - id: 'step-33' - run: 'tar -rvf linux.tar build/openssl3/*/staticLib' - - id: 'step-34' run: 'tar -rvf linux.tar build/openssl3/*/include' - - id: 'step-35' + - id: 'step-34' uses: 'actions/upload-artifact@v4' with: name: 'openssl-linux-${{ inputs.version }}' @@ -211,12 +207,16 @@ jobs: - id: 'step-7' run: 'conan install packages/openssl3 --output-folder build/openssl3/mingw-x64 --version=${{ inputs.version }} -pr:b default -pr:h profiles/mingw-x64 -o "*:shared=False"' - id: 'step-8' - run: 'tar -rvf windows.tar build/openssl3/*/dynamicLib' + run: 'conan create conan-center-index/recipes/openssl/3.x.x --build=missing --version=${{ inputs.version }} -pr:b default -pr:h profiles/windows-x64 -o "*:shared=True"' - id: 'step-9' - run: 'tar -rvf windows.tar build/openssl3/*/staticLib' + run: 'conan install packages/openssl3 --output-folder build/openssl3/windows-x64 --version=${{ inputs.version }} -pr:b default -pr:h profiles/windows-x64 -o "*:shared=True"' - id: 'step-10' - run: 'tar -rvf windows.tar build/openssl3/*/include' + run: 'tar -rvf windows.tar build/openssl3/*/lib' - id: 'step-11' + run: 'tar -rvf windows.tar build/openssl3/*/include' + - id: 'step-12' + run: 'tar -rvf windows.tar build/openssl3/*/bin' + - id: 'step-13' uses: 'actions/upload-artifact@v4' with: name: 'openssl-windows-${{ inputs.version }}' diff --git a/packages/openssl3/conanfile.py b/packages/openssl3/conanfile.py index a7d33af..117794e 100644 --- a/packages/openssl3/conanfile.py +++ b/packages/openssl3/conanfile.py @@ -13,18 +13,29 @@ def requirements(self): self.requires("openssl/" + str(self.version)) def generate(self): - libs = ["libcrypto", "libssl"] dep = self.dependencies["openssl"] includedir = dep.cpp_info.includedirs[0] libdir = dep.cpp_info.libdirs[0] + bindir = dep.cpp_info.bindirs[0] - # get headers from static build, to be consistent (TBD if it's a good solution) - if not self.options.shared: - copy(self, "*.h", includedir, join(self.build_folder, "include")) + copy(self, "*.h", includedir, join(self.build_folder, "include")) - for lib in libs: - copy(self, lib + ".a", libdir, join(self.build_folder, "staticLib")) - else: - for lib in libs: - for ext in ["dll.a", "3.dylib", "dylib", "so.3", "so"]: - copy(self, lib + "." + ext, libdir, join(self.build_folder, "dynamicLib")) + for libName in ["libcrypto", "libssl"]: + for ext in [ + # mingw dynamic + "dll.a", + # windows dynamic + "lib", + # macos dynamic + "dylib", "3.dylib", + # linux dynamic + "so.3", "so", + # macos/linux/mingw static + "a" + ]: + copy(self, libName + "." + ext, libdir, join(self.build_folder, "lib")) + + # windows only + for binName in ["libcrypto-3-x64", "libssl-3-x64"]: + for ext in ["dll"]: + copy(self, binName + "." + ext, bindir, join(self.build_folder, "bin")) diff --git a/profiles/windows-x64 b/profiles/windows-x64 new file mode 100644 index 0000000..22fac20 --- /dev/null +++ b/profiles/windows-x64 @@ -0,0 +1,7 @@ +include(base) +[settings] +os=Windows +arch=x86_64 +compiler=msvc +compiler.version=193 +compiler.runtime=dynamic \ No newline at end of file