Home | History | Annotate | Download | only in conscrypt
      1 //
      2 // Copyright (C) 2016 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 //
     18 // Definitions for building the Conscrypt Java library, native code,
     19 // and associated tests.
     20 //
     21 
     22 // Conscrypt is divided into modules.
     23 //
     24 // The structure is:
     25 //
     26 //   constants/
     27 //       src/gen             # Generates NativeConstants.java.
     28 //   common/
     29 //       src/main/java       # Common Java source for all platforms.
     30 //       src/jni/
     31 //            main           # Common C++ source for all platforms.
     32 //            unbundled      # C++ source used for OpenJDK and unbundled Android.
     33 //   android/
     34 //       src/main/java       # Java source for unbundled Android.
     35 //   openjdk/
     36 //       src/main/java       # Java source for OpenJDK.
     37 //       src/test
     38 //            java/          # Java source for common tests.
     39 //            resources/     # Support files for tests
     40 //   platform/
     41 //       src/main/java       # Java source for bundled Android.
     42 //       src/test
     43 //            java/          # Java source for bundled tests.
     44 //
     45 
     46 cc_defaults {
     47     name: "conscrypt_global",
     48 
     49     cflags: [
     50         "-Wall",
     51         "-Wextra",
     52         "-Werror",
     53         "-Wunused",
     54     ],
     55 
     56     srcs: [
     57         "common/src/jni/main/cpp/conscrypt/compatibility_close_monitor.cc",
     58         "common/src/jni/main/cpp/conscrypt/jniload.cc",
     59         "common/src/jni/main/cpp/conscrypt/jniutil.cc",
     60         "common/src/jni/main/cpp/conscrypt/native_crypto.cc",
     61         "common/src/jni/main/cpp/conscrypt/netutil.cc",
     62         "common/src/jni/main/cpp/conscrypt/trace.cc",
     63     ],
     64 
     65     local_include_dirs: [
     66         "common/src/jni/main/include",
     67     ],
     68 
     69     compile_multilib: "both",
     70     stl: "c++_static",
     71 }
     72 
     73 cc_defaults {
     74     name: "conscrypt_unbundled-jni-defaults",
     75 
     76     local_include_dirs: [
     77         "common/src/jni/unbundled/include",
     78     ],
     79 
     80     shared_libs: [
     81         "liblog",
     82     ],
     83 
     84     static_libs: [
     85         "libssl",
     86         "libcrypto",
     87     ],
     88 
     89     sdk_version: "9",
     90 }
     91 
     92 cc_library {
     93     name: "libconscrypt_jni",
     94     defaults: [
     95         "conscrypt_global",
     96         "conscrypt_unbundled-jni-defaults",
     97     ],
     98 }
     99 
    100 cc_library_host_shared {
    101     name: "libconscrypt_openjdk_jni",
    102     defaults: ["conscrypt_global"],
    103 
    104     cflags: [
    105         "-DCONSCRYPT_OPENJDK",
    106     ],
    107 
    108     local_include_dirs: [
    109         "common/src/jni/unbundled/include",
    110     ],
    111 
    112     static_libs: [
    113         "libssl",
    114         "libcrypto",
    115     ],
    116 
    117     // TODO: b/26097626. ASAN breaks use of this library in JVM.
    118     // Re-enable sanitization when the issue with making clients of this library
    119     // preload ASAN runtime is resolved. Without that, clients are getting runtime
    120     // errors due to unresolved ASAN symbols, such as
    121     // __asan_option_detect_stack_use_after_return.
    122     sanitize: {
    123         never: true,
    124     },
    125 
    126     stl: "libc++_static",
    127 }
    128 
    129 cc_binary_host {
    130     name: "conscrypt_generate_constants",
    131     srcs: ["constants/src/gen/cpp/generate_constants.cc"],
    132     cflags: [
    133         "-Wall",
    134         "-Werror",
    135     ],
    136     shared_libs: [
    137         "libcrypto",
    138         "libssl",
    139     ],
    140 }
    141 
    142 genrule {
    143     name: "conscrypt_generated_constants",
    144     out: ["org/conscrypt/NativeConstants.java"],
    145     cmd: "$(location conscrypt_generate_constants) > $(out)",
    146     tools: ["conscrypt_generate_constants"],
    147 }
    148 
    149 // Create the conscrypt library without jarjar for tests
    150 java_library_static {
    151     name: "conscrypt-nojarjar",
    152     host_supported: true,
    153     hostdex: true,
    154 
    155     srcs: [
    156         "common/src/main/java/**/*.java",
    157         ":conscrypt_generated_constants",
    158     ],
    159 
    160     target: {
    161         android: {
    162             srcs: ["platform/src/main/java/**/*.java"],
    163         },
    164         host: {
    165             srcs: ["openjdk/src/main/java/**/*.java"],
    166             javacflags: ["-XDignore.symbol.file"],
    167         },
    168     },
    169 
    170     no_framework_libs: true,
    171 
    172     required: ["libjavacrypto"],
    173     java_version: "1.7",
    174 }
    175 
    176 // Create the conscrypt library by running jarjar on conscrypt-nojarjar
    177 java_library {
    178     name: "conscrypt",
    179     host_supported: true,
    180     hostdex: true,
    181     no_framework_libs: true,
    182     static_libs: ["conscrypt-nojarjar"],
    183     required: ["libjavacrypto"],
    184     target: {
    185         android: {
    186             jarjar_rules: "jarjar-rules.txt",
    187         },
    188     },
    189 }
    190 
    191 // A guaranteed unstripped version of conscrypt.
    192 // The build system may or may not strip the conscrypt jar, but this one will
    193 // not be stripped. See b/24535627.
    194 java_library {
    195     name: "conscrypt-testdex",
    196     no_framework_libs: true,
    197     required: ["libjavacrypto"],
    198     static_libs: ["conscrypt-nojarjar"],
    199     jarjar_rules: "jarjar-rules.txt",
    200 }
    201 
    202 // Platform conscrypt crypto JNI library
    203 cc_defaults {
    204     name: "libjavacrypto-defaults",
    205 
    206     cflags: [
    207         "-Wall",
    208         "-Wextra",
    209         "-Werror",
    210         "-Wunused",
    211         "-fvisibility=hidden",
    212     ],
    213 
    214     srcs: ["common/src/jni/main/cpp/**/*.cc"],
    215     include_dirs: [
    216         "libcore/luni/src/main/native",
    217     ],
    218     local_include_dirs: ["common/src/jni/main/include"],
    219 }
    220 
    221 // Platform conscrypt crypto JNI library
    222 cc_library_shared {
    223     name: "libjavacrypto",
    224     host_supported: true,
    225     defaults: ["libjavacrypto-defaults"],
    226 
    227     cflags: ["-DJNI_JARJAR_PREFIX=com/android/"],
    228     shared_libs: [
    229         "libcrypto",
    230         "libjavacore",
    231         "liblog",
    232         "libnativehelper",
    233         "libssl",
    234     ],
    235 
    236     target: {
    237         darwin: {
    238             enabled: false,
    239         },
    240     },
    241 }
    242 
    243 // Unbundled Conscrypt jar
    244 java_library_static {
    245     name: "conscrypt_unbundled",
    246 
    247     srcs: [
    248         "common/src/main/java/**/*.java",
    249         "android/src/main/java/**/*.java",
    250         ":conscrypt_generated_constants",
    251     ],
    252 
    253     libs: ["conscrypt-stubs"],
    254 
    255     sdk_version: "current",
    256     java_version: "1.7",
    257 }
    258 
    259 // Stub library for unbundled builds
    260 java_library_static {
    261     name: "conscrypt-stubs",
    262 
    263     srcs: ["android-stub/src/main/java/**/*.java"],
    264 
    265     sdk_version: "current",
    266     java_version: "1.7",
    267 }
    268 
    269 // Static unbundled Conscrypt crypto JNI library
    270 cc_library_static {
    271     name: "libconscrypt_static",
    272     defaults: ["libjavacrypto-defaults"],
    273 
    274     cflags: [
    275         "-DJNI_JARJAR_PREFIX=com/google/android/gms/",
    276         "-DCONSCRYPT_UNBUNDLED",
    277         "-DSTATIC_LIB",
    278     ],
    279 
    280     local_include_dirs: ["common/src/jni/unbundled/include"],
    281 
    282     static_libs: [
    283         "libssl",
    284         "libcrypto",
    285     ],
    286     sdk_version: "9",
    287     stl: "c++_shared",
    288 }
    289