Skip to content

Commit

Permalink
Return back Windows (msvc) support
Browse files Browse the repository at this point in the history
* revert splitting lib directory
  • Loading branch information
whyoleg committed Jan 9, 2024
1 parent e3f8fab commit 376942c
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 61 deletions.
98 changes: 58 additions & 40 deletions .github/workflows/build.main.kts
Original file line number Diff line number Diff line change
@@ -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.*
Expand All @@ -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<Pair<String, Boolean>>
val profiles: List<Pair<String, BuildKind>>
)

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,
)
)
)
Expand All @@ -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(
Expand All @@ -105,6 +120,7 @@ workflow(
),
sourceFile = __FILE__.toPath(),
) {
//val version = "3.2.0"
val version = expr("inputs.version")
val jobs = configurations.map { configuration ->
job(
Expand All @@ -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(
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}'
Expand Down Expand Up @@ -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 }}'
Expand Down Expand Up @@ -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 }}'
Expand Down
31 changes: 21 additions & 10 deletions packages/openssl3/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
7 changes: 7 additions & 0 deletions profiles/windows-x64
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include(base)
[settings]
os=Windows
arch=x86_64
compiler=msvc
compiler.version=193
compiler.runtime=dynamic

0 comments on commit 376942c

Please sign in to comment.