1def configs = [
2    [
3        label: "windows2012-openssl", arch: "x86", "vsversion": 2010
4    ],
5    [
6        label: "windows2012-openssl", arch: "x86_64", "vsversion": 2010
7    ],
8    [
9        label: "windows2012-openssl", arch: "x86", "vsversion": 2015
10    ],
11    [
12        label: "windows2012-openssl", arch: "x86_64", "vsversion": 2015
13    ],
14]
15
16script = """
17    wmic qfe
18    powershell "[Net.ServicePointManager]::SecurityProtocol = 'tls12'; wget 'https://www.openssl.org/source/openssl-1.1.1-latest.tar.gz' -OutFile 'openssl-latest.tar.gz'"
19    REM Next decompress the tarball using winrar. INUL disables error msgs, which are GUI prompts and therefore undesirable
20    "C:\\Program Files\\WinRAR\\WinRAR.exe" -INUL x openssl-latest.tar.gz
21    cd openssl-1*
22    REM The next line determines the name of the current directory. Batch is great.
23    FOR %%I IN (.) DO @SET CURRENTDIR=%%~nI%%~xI
24    if "%BUILDARCH%" == "x86" (
25        @SET BUILDARCHFLAG=x86
26        @SET OPENSSLARCHFLAG="VC-WIN32"
27    ) else (
28        @SET BUILDARCHFLAG=amd64
29        @SET OPENSSLARCHFLAG="VC-WIN64A"
30    )
31    if "%BUILDVSVERSION%" == "2010" (
32        call "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\vcvarsall.bat" %BUILDARCHFLAG%
33        echo "Building with VS 2010"
34    ) else (
35        call "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\vcvarsall.bat" %BUILDARCHFLAG%
36        echo "Building with VS 2015"
37    )
38    SET
39    perl Configure no-comp no-shared %OPENSSLARCHFLAG%
40    nmake
41    nmake test
42
43    if "%BUILDARCH%" == "x86" (
44        @SET FINALDIR="openssl-win32-%BUILDVSVERSION%"
45    ) else (
46        @SET FINALDIR="openssl-win64-%BUILDVSVERSION%"
47    )
48    mkdir %FINALDIR%
49    mkdir %FINALDIR%\\lib
50    move include %FINALDIR%\\include
51    move libcrypto.lib %FINALDIR%\\lib\\
52    move libssl.lib %FINALDIR%\\lib\\
53    "C:\\Program Files\\WinRAR\\WinRAR.exe" -INUL a %CURRENTDIR%-%BUILDVSVERSION%-%BUILDARCH%.zip %FINALDIR%\\include %FINALDIR%\\lib\\libcrypto.lib %FINALDIR%\\lib\\libssl.lib
54"""
55
56def build(label, vsversion, arch) {
57    node(label) {
58        try {
59            timeout(time: 30, unit: 'MINUTES') {
60                stage("Compile") {
61                    withEnv(["BUILDARCH=$arch", "BUILDVSVERSION=$vsversion"]) {
62                        bat script
63                    }
64                }
65                stage("Archive") {
66                    archiveArtifacts artifacts: "**/openssl-*.zip"
67                }
68            }
69        } finally {
70            deleteDir()
71        }
72    }
73}
74
75def builders = [:]
76
77for (config in configs) {
78    def vsversion = config["vsversion"]
79    def arch = config["arch"]
80    def label = config["label"]
81    builders["${vsversion}-${arch}"] = {
82        build(label, vsversion, arch)
83    }
84}
85
86parallel builders
87