Use aidegen to import AOSP project to Clion and configure toolchains

Author: Season3266

1. Introduction of aidegen

Aidegen is a built-in tool in AOSP, which can import a certain project in the source code into the IDE, so that you can use the smart prompts of the IDE to improve coding efficiency. The projects in the source code do not exist independently, but also depend on various modules in other projects. aidegen will take the initiative to compile the corresponding modules, and at the same time organize these dependencies and import them into the IDE, so as to avoid problems caused by missing The problem of becoming popular due to dependence.

Two, aidegen usage

Before using aidegen, you first need to execute it in the AOSP root directory:

$ source build/envsetup.sh && lunch <TARGET>

Then you can use the aidegen command.

Aidegen is used as follows:

$ aidegen modulename -i [c/s/j] -p [clion path] -s [skip build]

modulename, module name, that is, the name field in Android.bp in the project
-i specifies the IDE, c = Clion, s = Android Studio, j = Intellij
-p specifies the IDE path, such as: /home/season/Applications/CLion
- s Whether to skip build, the project will be compiled when it is executed for the first time, after compiling once, you can add this flag to skip the compilation process

For example:

$ aidegen android.hardware.automotive.vehicle@V1-default-service -i c -p /home/season/Applications/CLion

After the above command is executed, the project android.hardware.automotive.vehicle@V1-default-service will be opened with CLion

3. Configure Clion toolchains

Under normal circumstances, after opening CLion, it will still become popular, prompting that various files cannot be found. At this time, you need to reconfigure the build toolchain, and configure the default build toolchain as CMake in the Android SDK and Compiler in the NDK.

1. Install Cmake and NDK

Open Android Studio SDK Manager, install Cmake and NDK:

You can choose any version to install.

2. Configure Clion toolchains

Open Clion settings, select Build, Execution, Deployment -> Toolchains:

Click the + sign to create a new Toolchains, fill in the Name casually, such as: System

Focus on setting the three options of CMake, C Compiler, and C++ Compiler, and set the path to CMake and NDK in the Android SDK directory.

For example:

CMake: 
/home/season/Android/Sdk/cmake/3.22.1/bin/cmake

C Compiler: 
/home/season/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang

C++ Compiler:
/home/season/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang++

3. Set up the project and use the new toolchains

Open Clion settings, select Build, Execution, Deployment -> CMake:

In the Toolchain column, drop down and select the Toolchain you just created, and save it

4.Reload Project

Click File -> Reload CMake Project to reload the project.

5. If you encounter a prompt: This file does not belong to any project target; code insight features might not work property; just add the file to CMakeList according to the prompt

Android study notes

Android Performance Optimization: https://qr18.cn/FVlo89
Android Vehicle: https://qr18.cn/F05ZCM
Android Reverse Security Study Notes: https://qr18.cn/CQ5TcL
Android Framework Principles: https://qr18.cn/AQpN4J
Android Audio and Video: https://qr18.cn/Ei3VPD
Jetpack (including Compose): https://qr18.cn/A0gajp
Kotlin: https://qr18.cn/CdjtAF
Gradle: https://qr18.cn/DzrmMB
OkHttp Source Code Analysis Notes: https://qr18.cn/Cw0pBD
Flutter: https://qr18.cn/DIvKma
Android Eight Knowledge Body: https://qr18.cn/CyxarU
Android Core Notes: https://qr21.cn/CaZQLo
Android Past Interview Questions: https://qr18.cn/CKV8OZ
2023 Latest Android Interview Question Collection: https://qr18.cn/CgxrRy
Android Vehicle Development Job Interview Exercises: https://qr18.cn/FTlyCJ
Audio and Video Interview Questions:https://qr18.cn/AcV6Ap

Guess you like

Origin blog.csdn.net/weixin_61845324/article/details/132083446