Android-differences between Compiling different libraries and compiling scripts

Source: Internet
Author: User

We often compile different libraries in different scenarios, and often cooperate with third parties. The other party provides static libraries, dynamic libraries, and configuration files, you may also need to provide the database to the other party and take this opportunity to summarize some of the situations used. The android. mk below is written in some templates. It may not be necessary for modules, but it does not matter. You can add them directly if necessary.


1. compile and generate a dynamic library

Local_path: = $ (call my-DIR)
Include $ (clear_vars)

# [Optional, user, Eng]
# Eng = required
# Optinal = No install on target
Local_module_tags: = ENG

# This is the target being built.
Local_module: = libxxx

# Target install path.
Local_module_path: = $ (target_out_shared_libraries)

# All of the source files that we will compile.
Local_src_files: = \
Xxx. c
YYY. cpp

# All of the shared libraries we link against.
Local_shared_libraries: = \
Libcutils \
Libutils \
Liblog \

# No static libraries.
Local_static_libraries: = \

# Also need other headers.
Local_c_includes + = \
Frameworks/base/include /\

# No specia compiler flags.
Local_cflags + =-d_cplusplus

# Don't prelink this library. For more efficient code, you may want
# To add this library to the prelink map and set this to true.
Local_prelink_module: = false

Include $ (build_shared_library)


2. Compile the static library

Last name: include $ (build_shared_library)

Changed:

Include $ (build_static_library)


3. compile and generate executable files

The last sentence is modified

Include $ (build_executable)


4. compile and generate a jar package:

Local_path: = $ (call my-DIR)

# The Library
#===================================================== ==================================
Include $ (clear_vars)

Local_module: = libandroidtest
Local_module_tags: = ENG

Local_src_files: = \
$ (Call all-subdir-Java-files)

Local_src_files + = \
$ (Call all-Java-files-under, ../Gen)

# Local_src_files + = \
Android/NET/telecast/inetworkservicemanager. aidl \
### Android. mk files that are not added to the framework/base cannot be compiled online. You can generate aidl java files in advance and compile them in the gen directory.

Include $ (build_java_library)


5. You only need to copy a file to the directory without using the intermediate compilation result.

Include $ (clear_vars)

Local_module: = libandroidtest. xml
Local_module_tags: = ENG

Local_module_class: = etc

# This will install the file in/system/etc/Permissions
#
Local_module_path: = $ (target_out_etc)/Permissions

Local_src_files: = $ (local_module)

Include $ (build_prebuilt)


6. Similar to five, but other libraries need to compile OBJ in the middle, which is very important to the static library.

Local_path: = $ (call my-DIR)
Include $ (clear_vars)
$ (Call add-prebuilt-files, static_libraries, libchfp.)

Or write it:

Local_path: = $ (call my-DIR)

# Include $ (clear_vars)
# Local_module_tags: = ENG
# $ (Call add-prebuilt-files, static_libraries, libchfp.)

Include $ (clear_vars)
Local_src_files: = libchfp.
Local_built_module_stem: = libchfp.
Local_module_suffix: = lib
Local_module: = libchfp
Local_module_class: = static_libraries
Local_module_tags: = optional
Include $ (build_prebuilt)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.