Code Monkey home page Code Monkey logo

android-cmake-project's Introduction

android-cmake-project

We can read and modify android native C/C++ code through this project. We can compile our own Android C/C++ code to run on Android devices. Of course, all of this is based on CLion, thanks to the CLion team.

  • Automatically finds the path to the module.
  • Automatically parses the module's android.mk or android.bp file.
  • Automatic resolution of module dependencies.
  • Automatically adds the module and its dependent module's C/C++ source files.
  • So you can use CLion's auto-jump feature. This is a great help for us to read the code.
  • I configured toolchian to compile our own C/C++ programs and to rely on Android's native libraries.

For Android.mk:

  • Only simple built-in functions for makefiles are supported

For Android.bp:

  • Some bp file styles are not supported.

May later use soong to solve these problems.

Test Environment

  • Android N/O/P/Q source tree
  • Ubuntu 16.04
  • Windows 10 && Android NDK R21
  • Clion 2019.3.2

Depend

  • Fully compiled android source tree
  • Linux: ${your android source path}/prebuilts/clang/host/linux-x86/clang-xxxxxx
  • Windows: Android NDK

Description

  • .idea
    I ignored some folders by default. They defined in .idea/misc.xml.

How to use it

cp -r $(path)/android-cmake-project/.idea $(android_source_tree)/
ln -s $(path)/android-cmake-project/CMakeModule $(android_source_tree)/CMakeModule
ln -s $(path)/android-cmake-project/CMakeLists.txt $(android_source_tree)/CMakeLists.txt

Configure your own environment

android-cmake-project/CMakeModule/android.env.cmake

Property value description
TARGET_BOARD_HARDWARE string Fill in the string you got through get_build_var
ANDROID_LUNCH string Your own android lunch target
ANDROID_SDK_VERSION string 19-29...
ANDROID_TARGET_ARCH arm/arm64 lunch target arch, form TARGET_ARCH
ANDROID_ARCH_VARIANT string armv7-a,armv8-a,... form TARGET_ARCH_VARIANT
ANDROID_CPU_VARIANT string cortex-a53,... form TARGET_CPU_VARIANT
ANDROID_ABI arm64-v8a/armeabi-v7a Compile to generate binary abi
ANDROID_NDK path android ndk path
ANDROID_CLANG_VERSION string clang-4691093(Android p)

android-cmake-project/CMakeModule/android.module.cmake

# load libsurfaceflinger(SHARED LIB) and its dependencies
parseAndroidMK(libsurfaceflinger ${MK_SHARED})
# load init(EXECABLE) and its dependencies
parseAndroidMK(init ${MK_EXECAB})
Property description
MK_EXECAB module of execable target
MK_SHARED string of shared libs target
MK_STATIC string of static libs target

Why do you need it

It can help CLion to generate the file map correctly. pic It can conveniently help us develop our own Android Native Service. 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.