1*635a8641SAndroid Build Coastguard Worker// Copyright 2014 The Chromium Authors. All rights reserved. 2*635a8641SAndroid Build Coastguard Worker// Use of this source code is governed by a BSD-style license that can be 3*635a8641SAndroid Build Coastguard Worker// found in the LICENSE file. 4*635a8641SAndroid Build Coastguard Worker 5*635a8641SAndroid Build Coastguard Workerpackage org.chromium.base.library_loader; 6*635a8641SAndroid Build Coastguard Worker 7*635a8641SAndroid Build Coastguard Workerpublic class NativeLibraries { 8*635a8641SAndroid Build Coastguard Worker /** 9*635a8641SAndroid Build Coastguard Worker * IMPORTANT NOTE: The variables defined here must _not_ be 'final'. 10*635a8641SAndroid Build Coastguard Worker * 11*635a8641SAndroid Build Coastguard Worker * The reason for this is very subtle: 12*635a8641SAndroid Build Coastguard Worker * 13*635a8641SAndroid Build Coastguard Worker * - This template is used to generate several distinct, but similar 14*635a8641SAndroid Build Coastguard Worker * files used in different contexts: 15*635a8641SAndroid Build Coastguard Worker * 16*635a8641SAndroid Build Coastguard Worker * o .../gen/templates/org/chromium/base/library_loader/NativeLibraries.java 17*635a8641SAndroid Build Coastguard Worker * 18*635a8641SAndroid Build Coastguard Worker * This file is used to build base.jar, which is the library 19*635a8641SAndroid Build Coastguard Worker * jar used by chromium projects. However, the 20*635a8641SAndroid Build Coastguard Worker * corresponding NativeLibraries.class file will _not_ be part 21*635a8641SAndroid Build Coastguard Worker * of the final base.jar. 22*635a8641SAndroid Build Coastguard Worker * 23*635a8641SAndroid Build Coastguard Worker * o .../$PROJECT/native_libraries_java/NativeLibraries.java 24*635a8641SAndroid Build Coastguard Worker * 25*635a8641SAndroid Build Coastguard Worker * This file is used to build an APK (e.g. $PROJECT 26*635a8641SAndroid Build Coastguard Worker * could be 'content_shell_apk'). Its content will depend on 27*635a8641SAndroid Build Coastguard Worker * this target's specific build configuration, and differ from 28*635a8641SAndroid Build Coastguard Worker * the source file above. 29*635a8641SAndroid Build Coastguard Worker * 30*635a8641SAndroid Build Coastguard Worker * - During the final link, all .jar files are linked together into 31*635a8641SAndroid Build Coastguard Worker * a single .dex file, and the second version of NativeLibraries.class 32*635a8641SAndroid Build Coastguard Worker * will be put into the final output file, and used at runtime. 33*635a8641SAndroid Build Coastguard Worker * 34*635a8641SAndroid Build Coastguard Worker * - If the variables were defined as 'final', their value would be 35*635a8641SAndroid Build Coastguard Worker * optimized out inside of 'base.jar', and could not be specialized 36*635a8641SAndroid Build Coastguard Worker * for every chromium program. This, however, doesn't apply to arrays of 37*635a8641SAndroid Build Coastguard Worker * strings, which can be defined as final. 38*635a8641SAndroid Build Coastguard Worker * 39*635a8641SAndroid Build Coastguard Worker * This exotic scheme is used to avoid injecting project-specific, or 40*635a8641SAndroid Build Coastguard Worker * even build-specific, values into the base layer. E.g. this is 41*635a8641SAndroid Build Coastguard Worker * how the component build is supported on Android without modifying 42*635a8641SAndroid Build Coastguard Worker * the sources of each and every Chromium-based target. 43*635a8641SAndroid Build Coastguard Worker */ 44*635a8641SAndroid Build Coastguard Worker 45*635a8641SAndroid Build Coastguard Worker public static final int CPU_FAMILY_UNKNOWN = 0; 46*635a8641SAndroid Build Coastguard Worker public static final int CPU_FAMILY_ARM = 1; 47*635a8641SAndroid Build Coastguard Worker public static final int CPU_FAMILY_MIPS = 2; 48*635a8641SAndroid Build Coastguard Worker public static final int CPU_FAMILY_X86 = 3; 49*635a8641SAndroid Build Coastguard Worker 50*635a8641SAndroid Build Coastguard Worker#if defined(ENABLE_CHROMIUM_LINKER_LIBRARY_IN_ZIP_FILE) && \ 51*635a8641SAndroid Build Coastguard Worker !defined(ENABLE_CHROMIUM_LINKER) 52*635a8641SAndroid Build Coastguard Worker#error "Must have ENABLE_CHROMIUM_LINKER to enable library in zip file" 53*635a8641SAndroid Build Coastguard Worker#endif 54*635a8641SAndroid Build Coastguard Worker 55*635a8641SAndroid Build Coastguard Worker // Set to true to enable the use of the Chromium Linker. 56*635a8641SAndroid Build Coastguard Worker#if defined(ENABLE_CHROMIUM_LINKER) 57*635a8641SAndroid Build Coastguard Worker public static boolean sUseLinker = true; 58*635a8641SAndroid Build Coastguard Worker#else 59*635a8641SAndroid Build Coastguard Worker public static boolean sUseLinker = false; 60*635a8641SAndroid Build Coastguard Worker#endif 61*635a8641SAndroid Build Coastguard Worker 62*635a8641SAndroid Build Coastguard Worker#if defined(ENABLE_CHROMIUM_LINKER_LIBRARY_IN_ZIP_FILE) 63*635a8641SAndroid Build Coastguard Worker public static boolean sUseLibraryInZipFile = true; 64*635a8641SAndroid Build Coastguard Worker#else 65*635a8641SAndroid Build Coastguard Worker public static boolean sUseLibraryInZipFile = false; 66*635a8641SAndroid Build Coastguard Worker#endif 67*635a8641SAndroid Build Coastguard Worker 68*635a8641SAndroid Build Coastguard Worker#if defined(ENABLE_CHROMIUM_LINKER_TESTS) 69*635a8641SAndroid Build Coastguard Worker public static boolean sEnableLinkerTests = true; 70*635a8641SAndroid Build Coastguard Worker#else 71*635a8641SAndroid Build Coastguard Worker public static boolean sEnableLinkerTests = false; 72*635a8641SAndroid Build Coastguard Worker#endif 73*635a8641SAndroid Build Coastguard Worker 74*635a8641SAndroid Build Coastguard Worker // This is the list of native libraries to be loaded (in the correct order) 75*635a8641SAndroid Build Coastguard Worker // by LibraryLoader.java. The base java library is compiled with no 76*635a8641SAndroid Build Coastguard Worker // array defined, and then the build system creates a version of the file 77*635a8641SAndroid Build Coastguard Worker // with the real list of libraries required (which changes based upon which 78*635a8641SAndroid Build Coastguard Worker // .apk is being built). 79*635a8641SAndroid Build Coastguard Worker // TODO(cjhopman): This is public since it is referenced by NativeTestActivity.java 80*635a8641SAndroid Build Coastguard Worker // directly. The two ways of library loading should be refactored into one. 81*635a8641SAndroid Build Coastguard Worker public static final String[] LIBRARIES = 82*635a8641SAndroid Build Coastguard Worker#if defined(NATIVE_LIBRARIES_LIST) 83*635a8641SAndroid Build Coastguard Worker NATIVE_LIBRARIES_LIST; 84*635a8641SAndroid Build Coastguard Worker#else 85*635a8641SAndroid Build Coastguard Worker {}; 86*635a8641SAndroid Build Coastguard Worker#endif 87*635a8641SAndroid Build Coastguard Worker 88*635a8641SAndroid Build Coastguard Worker // This is the expected version of the 'main' native library, which is the one that 89*635a8641SAndroid Build Coastguard Worker // implements the initial set of base JNI functions including 90*635a8641SAndroid Build Coastguard Worker // base::android::nativeGetVersionName() 91*635a8641SAndroid Build Coastguard Worker static String sVersionNumber = 92*635a8641SAndroid Build Coastguard Worker#if defined(NATIVE_LIBRARIES_VERSION_NUMBER) 93*635a8641SAndroid Build Coastguard Worker NATIVE_LIBRARIES_VERSION_NUMBER; 94*635a8641SAndroid Build Coastguard Worker#else 95*635a8641SAndroid Build Coastguard Worker ""; 96*635a8641SAndroid Build Coastguard Worker#endif 97*635a8641SAndroid Build Coastguard Worker 98*635a8641SAndroid Build Coastguard Worker public static int sCpuFamily = 99*635a8641SAndroid Build Coastguard Worker#if defined(ANDROID_APP_CPU_FAMILY_ARM) 100*635a8641SAndroid Build Coastguard Worker CPU_FAMILY_ARM; 101*635a8641SAndroid Build Coastguard Worker#elif defined(ANDROID_APP_CPU_FAMILY_X86) 102*635a8641SAndroid Build Coastguard Worker CPU_FAMILY_X86; 103*635a8641SAndroid Build Coastguard Worker#elif defined(ANDROID_APP_CPU_FAMILY_MIPS) 104*635a8641SAndroid Build Coastguard Worker CPU_FAMILY_MIPS; 105*635a8641SAndroid Build Coastguard Worker#else 106*635a8641SAndroid Build Coastguard Worker CPU_FAMILY_UNKNOWN; 107*635a8641SAndroid Build Coastguard Worker#endif 108*635a8641SAndroid Build Coastguard Worker 109*635a8641SAndroid Build Coastguard Worker} 110