1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ndkports 18 19 import java.io.File 20 21 object : Port() { 22 override val name = "openssl" 23 override val version = "1.1.1g" 24 override val mavenVersion = "$version-alpha-1" 25 override val prefabVersion = CMakeCompatibleVersion(1, 1, 1, 7) 26 27 override val license = License( 28 "Dual OpenSSL and SSLeay License", 29 "https://www.openssl.org/source/license-openssl-ssleay.txt" 30 ) 31 32 override val modules = listOf( 33 Module("crypto"), 34 Module("ssl") 35 ) 36 configurenull37 override fun configure( 38 toolchain: Toolchain, 39 sourceDirectory: File, 40 buildDirectory: File, 41 installDirectory: File, 42 workingDirectory: File 43 ): Result<Unit, String> { 44 buildDirectory.mkdirs() 45 return executeProcessStep( 46 listOf( 47 sourceDirectory.resolve("Configure").absolutePath, 48 "android-${toolchain.abi.archName}", 49 "-D__ANDROID_API__=${toolchain.api}", 50 "--prefix=${installDirectory.absolutePath}", 51 "--openssldir=${installDirectory.absolutePath}", 52 "shared" 53 ), 54 buildDirectory, 55 additionalEnvironment = mapOf( 56 "ANDROID_NDK" to toolchain.ndk.path.absolutePath, 57 "PATH" to "${toolchain.binDir}:${System.getenv("PATH")}" 58 ) 59 ) 60 } 61 buildnull62 override fun build( 63 toolchain: Toolchain, 64 buildDirectory: File 65 ): Result<Unit, String> = 66 executeProcessStep( 67 listOf( 68 "make", 69 "-j$ncpus", 70 "SHLIB_EXT=.so" 71 ), buildDirectory, 72 additionalEnvironment = mapOf( 73 "ANDROID_NDK" to toolchain.ndk.path.absolutePath, 74 "PATH" to "${toolchain.binDir}:${System.getenv("PATH")}" 75 ) 76 ) 77 78 override fun install( 79 toolchain: Toolchain, 80 buildDirectory: File, 81 installDirectory: File 82 ): Result<Unit, String> = 83 executeProcessStep( 84 listOf("make", "install_sw", "SHLIB_EXT=.so"), buildDirectory, 85 additionalEnvironment = mapOf( 86 "ANDROID_NDK" to toolchain.ndk.path.absolutePath, 87 "PATH" to "${toolchain.binDir}:${System.getenv("PATH")}" 88 ) 89 ) 90 } 91