Skip to content

Commit 6afed82

Browse files
Set openssl cmake paths on Windows (#18)
* Set openssl cmake paths on Windows * Fix ssh, bump version * Try use static libs * Another attempt * Make copy of library for debug mode * Copy openssl pdb * Use jom * Single task --------- Co-authored-by: Thad House <thadhouse1@gmail.com>
1 parent 8e06cb8 commit 6afed82

File tree

3 files changed

+43
-23
lines changed

3 files changed

+43
-23
lines changed

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import org.gradle.internal.os.OperatingSystem
22

33
plugins {
44
id "maven-publish"
5+
id "de.undercouch.download" version "5.4.0"
56
}
67

78
// Project Version
8-
ext.pub_version = "0.95-7"
9+
ext.pub_version = "0.95-8"
910

1011
static def get_platform() {
1112
def platform

libssh.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ types.each { type ->
4343
args "-DOPENSSL_CRYPTO_LIBRARY=${project.openssl_install}/lib/libcrypto.a"
4444
args "-DOPENSSL_SSL_LIBRARY=${project.openssl_install}/lib/libssl.a"
4545
args "-DOPENSSL_INCLUDE_DIR=${project.openssl_install}/include"
46+
} else if (project.platform.contains("windows")) {
47+
args "-DOPENSSL_ROOT_DIR=${project.openssl_install}"
4648
}
4749

4850
args "-DBUILD_SHARED_LIBS=OFF", "-DWITH_ZLIB=OFF", "-DWITH_EXAMPLES=OFF",
@@ -117,6 +119,13 @@ types.each { type ->
117119
// Add libraries to merge.
118120
args "$ssl_libs/libcrypto.lib"
119121
args "$ssh_libs/ssh.lib"
122+
123+
doLast {
124+
copy {
125+
from "$ssl_libs/ossl_static.pdb"
126+
into "$ssh_libs"
127+
}
128+
}
120129
} else if (project.platform.contains("osx")) {
121130
// Use libtool to merge libraries.
122131
executable "libtool"

openssl.gradle

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,25 @@ task prepareOpenSSLDirectories {
66
}
77
}
88

9+
project.tasks.create("downloadJom", Download) {
10+
src 'https://qt.mirror.constant.com/official_releases/jom/jom_1_1_3.zip'
11+
dest buildDir
12+
overwrite false
13+
}
14+
15+
project.tasks.create("unzipJom", Copy) {
16+
dependsOn downloadJom
17+
from zipTree("$buildDir/jom_1_1_3.zip")
18+
into "$buildDir/jom"
19+
}
20+
921
// Runs the configure step.
1022
project.tasks.create("configureOpenSSL", Exec) {
1123
// OpenSSL is configured with Perl. We want to build static libraries and specify
1224
// a custom installation location.
1325
executable "perl"
1426
def configureLocation = project.file("$project.openssl_dir/Configure")
15-
args configureLocation, "no-shared", "--prefix=${project.openssl_install}", "--libdir=lib"
27+
args configureLocation, "no-shared", "no-tests", "--prefix=${project.openssl_install}", "--libdir=lib"
1628
workingDir project.openssl_build_dir
1729

1830
// Add the arch specifier for Windows.
@@ -24,6 +36,8 @@ project.tasks.create("configureOpenSSL", Exec) {
2436
} else {
2537
args "VC-WIN64A"
2638
}
39+
args "/FS"
40+
dependsOn unzipJom
2741
} else if (project.platform == "osx-arm64") {
2842
args "darwin64-arm64-cc"
2943
environment "ARCHFLAGS", "-arch arm64"
@@ -55,39 +69,35 @@ project.tasks.create("configureOpenSSL", Exec) {
5569
dependsOn prepareOpenSSLDirectories
5670
}
5771

58-
def make = project.platform.contains("windows") ? "nmake" : "make"
72+
def make = project.platform.contains("windows") ? "$buildDir/jom/jom.exe" : "make"
5973

6074
// Runs the build step.
6175
project.tasks.create("buildOpenSSL", Exec) {
6276
// Make sure that we are configured.
6377
dependsOn "configureOpenSSL"
6478

65-
// OpenSSL is built with make on UNIX and nmake on Windows.
66-
executable make
67-
workingDir project.openssl_build_dir
68-
69-
// UNIX supports building with multiple workers.
70-
if (!project.platform.contains("windows"))
71-
args "-j${project.processors}"
72-
}
73-
74-
// Runs the install step.
75-
project.tasks.create("installOpenSSL", Exec) {
76-
// Make sure that we have built.
77-
dependsOn "buildOpenSSL"
78-
79-
// OpenSSL is installed with make on UNIX and nmake on Windows.
79+
// OpenSSL is built with make on UNIX and jom on Windows.
8080
executable make
81-
args "install_sw"
81+
args "install_dev"
8282
workingDir project.openssl_build_dir
8383

84-
// UNIX supports installing with multiple workers.
85-
if (!project.platform.contains("windows"))
86-
args "-j${project.processors}"
84+
args "-j${project.processors}"
8785
}
8886

8987
// Create a "mega-task" that builds everything.
9088
project.tasks.create("openSSL") {
91-
dependsOn "installOpenSSL"
89+
dependsOn "buildOpenSSL"
9290
outputs.dir(project.openssl_install)
91+
92+
if (project.platform.contains("windows")) {
93+
doLast {
94+
copy {
95+
from "$project.openssl_install/lib/libcrypto.lib"
96+
from "$project.openssl_install/lib/libssl.lib"
97+
into "$project.openssl_install/lib"
98+
rename("libcrypto.lib", "libcryptod.lib")
99+
rename("libssl.lib", "libssld.lib")
100+
}
101+
}
102+
}
93103
}

0 commit comments

Comments
 (0)