|
| 1 | +task prepareOpenSSLDirectories { |
| 2 | + mustRunAfter clean |
| 3 | + doLast { |
| 4 | + mkdir project.openssl_arm_build_dir |
| 5 | + mkdir project.openssl_arm_install |
| 6 | + |
| 7 | + mkdir project.openssl_intel_build_dir |
| 8 | + mkdir project.openssl_intel_install |
| 9 | + } |
| 10 | +} |
| 11 | + |
| 12 | +// Runs the configure step. |
| 13 | +project.tasks.create("configureOpenSSLIntel", Exec) { |
| 14 | + // OpenSSL is configured with Perl. We want to build static libraries and specify |
| 15 | + // a custom installation location. |
| 16 | + executable "perl" |
| 17 | + def configureLocation = project.file("$project.openssl_dir/Configure") |
| 18 | + args configureLocation, "no-shared", "--prefix=${project.openssl_intel_install}", "--libdir=lib" |
| 19 | + workingDir project.openssl_intel_build_dir |
| 20 | + |
| 21 | + // Add the arch specifier for Windows. |
| 22 | + args "darwin64-x86_64-cc" |
| 23 | + environment "ARCHFLAGS", "-arch x86_64" |
| 24 | + |
| 25 | + dependsOn prepareOpenSSLDirectories |
| 26 | +} |
| 27 | + |
| 28 | +project.tasks.create("configureOpenSSLArm", Exec) { |
| 29 | + // OpenSSL is configured with Perl. We want to build static libraries and specify |
| 30 | + // a custom installation location. |
| 31 | + executable "perl" |
| 32 | + def configureLocation = project.file("$project.openssl_dir/Configure") |
| 33 | + args configureLocation, "no-shared", "--prefix=${project.openssl_arm_install}", "--libdir=lib" |
| 34 | + workingDir project.openssl_arm_build_dir |
| 35 | + |
| 36 | + // Add the arch specifier for Windows. |
| 37 | + args "darwin64-arm64-cc" |
| 38 | + environment "ARCHFLAGS", "-arch arm64" |
| 39 | + |
| 40 | + dependsOn prepareOpenSSLDirectories |
| 41 | +} |
| 42 | + |
| 43 | +def make = "make" |
| 44 | + |
| 45 | +// Runs the build step. |
| 46 | +project.tasks.create("buildOpenSSLIntel", Exec) { |
| 47 | + // Make sure that we are configured. |
| 48 | + dependsOn "configureOpenSSLIntel" |
| 49 | + |
| 50 | + // OpenSSL is built with make on UNIX and nmake on Windows. |
| 51 | + executable make |
| 52 | + workingDir project.openssl_intel_build_dir |
| 53 | + |
| 54 | + args "-j${project.processors}" |
| 55 | +} |
| 56 | + |
| 57 | +// Runs the build step. |
| 58 | +project.tasks.create("buildOpenSSLArm", Exec) { |
| 59 | + // Make sure that we are configured. |
| 60 | + dependsOn "configureOpenSSLArm" |
| 61 | + |
| 62 | + // OpenSSL is built with make on UNIX and nmake on Windows. |
| 63 | + executable make |
| 64 | + workingDir project.openssl_arm_build_dir |
| 65 | + |
| 66 | + args "-j${project.processors}" |
| 67 | +} |
| 68 | + |
| 69 | +// Runs the install step. |
| 70 | +project.tasks.create("installOpenSSLIntel", Exec) { |
| 71 | + // Make sure that we have built. |
| 72 | + dependsOn "buildOpenSSLIntel" |
| 73 | + |
| 74 | + // OpenSSL is installed with make on UNIX and nmake on Windows. |
| 75 | + executable make |
| 76 | + args "install_sw" |
| 77 | + workingDir project.openssl_intel_build_dir |
| 78 | + |
| 79 | + // UNIX supports installing with multiple workers. |
| 80 | + args "-j${project.processors}" |
| 81 | +} |
| 82 | + |
| 83 | +project.tasks.create("installOpenSSLArm", Exec) { |
| 84 | + // Make sure that we have built. |
| 85 | + dependsOn "buildOpenSSLArm" |
| 86 | + |
| 87 | + // OpenSSL is installed with make on UNIX and nmake on Windows. |
| 88 | + executable make |
| 89 | + args "install_sw" |
| 90 | + workingDir project.openssl_arm_build_dir |
| 91 | + |
| 92 | + args "-j${project.processors}" |
| 93 | +} |
| 94 | + |
| 95 | +project.tasks.create("copyOpenSSLHeaders", Copy) { |
| 96 | + dependsOn "installOpenSSLArm" |
| 97 | + dependsOn "installOpenSSLIntel" |
| 98 | + |
| 99 | + from "$project.openssl_arm_install/include" |
| 100 | + into "$project.openssl_install/include" |
| 101 | +} |
| 102 | + |
| 103 | +project.tasks.create("mergeCryptoBinaries", Exec) { |
| 104 | + dependsOn "installOpenSSLArm" |
| 105 | + dependsOn "installOpenSSLIntel" |
| 106 | + |
| 107 | + def output = project.file("$project.openssl_install/lib/libcrypto.a") |
| 108 | + outputs.file output |
| 109 | + |
| 110 | + def arm_input = project.file("$project.openssl_arm_install/lib/libcrypto.a") |
| 111 | + def intel_input = project.file("$project.openssl_intel_install/lib/libcrypto.a") |
| 112 | + |
| 113 | + inputs.file arm_input |
| 114 | + inputs.file intel_input |
| 115 | + |
| 116 | + executable 'lipo' |
| 117 | + |
| 118 | + args = [ |
| 119 | + '-create', |
| 120 | + arm_input, |
| 121 | + intel_input, |
| 122 | + '-output', |
| 123 | + output |
| 124 | + ] |
| 125 | +} |
| 126 | + |
| 127 | +project.tasks.create("mergeSSLBinaries", Exec) { |
| 128 | + dependsOn "installOpenSSLArm" |
| 129 | + dependsOn "installOpenSSLIntel" |
| 130 | + |
| 131 | + def output = project.file("$project.openssl_install/lib/libssl.a") |
| 132 | + outputs.file output |
| 133 | + |
| 134 | + def arm_input = project.file("$project.openssl_arm_install/lib/libssl.a") |
| 135 | + def intel_input = project.file("$project.openssl_intel_install/lib/libssl.a") |
| 136 | + |
| 137 | + inputs.file arm_input |
| 138 | + inputs.file intel_input |
| 139 | + |
| 140 | + executable 'lipo' |
| 141 | + |
| 142 | + args = [ |
| 143 | + '-create', |
| 144 | + arm_input, |
| 145 | + intel_input, |
| 146 | + '-output', |
| 147 | + output |
| 148 | + ] |
| 149 | +} |
| 150 | + |
| 151 | +// Create a "mega-task" that builds everything. |
| 152 | +project.tasks.create("openSSL") { |
| 153 | + dependsOn "copyOpenSSLHeaders" |
| 154 | + dependsOn "mergeSSLBinaries" |
| 155 | + dependsOn "mergeCryptoBinaries" |
| 156 | + outputs.dir(project.openssl_install) |
| 157 | +} |
0 commit comments