1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.base.library_loader;
7 import org.chromium.base.annotations.SuppressFBWarnings;
10 public class NativeLibraries {
12 * IMPORTANT NOTE: The variables defined here must _not_ be 'final'.
14 * The reason for this is very subtle:
16 * - This template is used to generate several distinct, but similar
17 * files used in different contexts:
19 * o .../gen/templates/org/chromium/base/library_loader/NativeLibraries.java
21 * This file is used to build base.jar, which is the library
22 * jar used by chromium projects. However, the
23 * corresponding NativeLibraries.class file will _not_ be part
24 * of the final base.jar.
26 * o .../$PROJECT/native_libraries_java/NativeLibraries.java
28 * This file is used to build an APK (e.g. $PROJECT
29 * could be 'content_shell_apk'). Its content will depend on
30 * this target's specific build configuration, and differ from
31 * the source file above.
33 * - During the final link, all .jar files are linked together into
34 * a single .dex file, and the second version of NativeLibraries.class
35 * will be put into the final output file, and used at runtime.
37 * - If the variables were defined as 'final', their value would be
38 * optimized out inside of 'base.jar', and could not be specialized
39 * for every chromium program. This, however, doesn't apply to arrays of
40 * strings, which can be defined as final.
42 * This exotic scheme is used to avoid injecting project-specific, or
43 * even build-specific, values into the base layer. E.g. this is
44 * how the component build is supported on Android without modifying
45 * the sources of each and every Chromium-based target.
48 #if defined(ENABLE_CHROMIUM_LINKER_LIBRARY_IN_ZIP_FILE) && \
49 !defined(ENABLE_CHROMIUM_LINKER)
50 #error "Must have ENABLE_CHROMIUM_LINKER to enable library in zip file"
53 // Set to true to enable the use of the Chromium Linker.
54 #if defined(ENABLE_CHROMIUM_LINKER)
55 public static boolean sUseLinker = true;
57 public static boolean sUseLinker = false;
60 #if defined(ENABLE_CHROMIUM_LINKER_LIBRARY_IN_ZIP_FILE)
61 public static boolean sUseLibraryInZipFile = true;
63 public static boolean sUseLibraryInZipFile = false;
66 #if defined(ENABLE_CHROMIUM_LINKER_TESTS)
67 public static boolean sEnableLinkerTests = true;
69 public static boolean sEnableLinkerTests = false;
72 // This is the list of native libraries to be loaded (in the correct order)
73 // by LibraryLoader.java. The base java library is compiled with no
74 // array defined, and then the build system creates a version of the file
75 // with the real list of libraries required (which changes based upon which
76 // .apk is being built).
77 // TODO(cjhopman): This is public since it is referenced by NativeTestActivity.java
78 // directly. The two ways of library loading should be refactored into one.
79 public static final String[] LIBRARIES =
80 #if defined(NATIVE_LIBRARIES_LIST)
81 NATIVE_LIBRARIES_LIST;
86 // This is the expected version of the 'main' native library, which is the one that
87 // implements the initial set of base JNI functions including
88 // base::android::nativeGetVersionName()
89 static String sVersionNumber =
90 #if defined(NATIVE_LIBRARIES_VERSION_NUMBER)
91 NATIVE_LIBRARIES_VERSION_NUMBER;