facebook / infer

A static analyzer for Java, C, C++, and Objective-C
http://fbinfer.com/
MIT License
14.8k stars 2k forks source link

Android NDK C++Analysis #1756

Open chongbo2013 opened 1 year ago

chongbo2013 commented 1 year ago

How should I analyze Android ndk cmake based projects,thank u.pls

shankkyy commented 9 months ago

I would like to contribute on this issue please assign me this issue @chongbo2013

shankkyy commented 9 months ago

you may follow the steps to analyze ndk cmake based projects

Project Design:

Begin by understanding the task's registry structure. Normal parts incorporate source code, CMakeLists.txt documents, header records, and assemble scripts. Search for the high level CMakeLists.txt document, which fills in as the passage point for the CMake construct process.

Conditions:

Distinguish the outer libraries and conditions utilized in the venture. These may incorporate outsider libraries, framework libraries, and other NDK parts. Check in the event that the venture utilizes CMake's find_package or target_link_libraries orders to oversee conditions. Construct Framework: Figure out which Android construct framework is being utilized. Android tasks can utilize either Gradle or CMake as their construct framework. Assuming that it's CMake-based, you'll see CMakeLists.txt records all through the task.

CMake Arrangement:

Assess the CMakeLists.txt documents, beginning with the high level one. This document characterizes the undertaking settings, including compiler banners, source records, and target properties. Audit any custom CMake macros or capabilities utilized inside the task. Android.mk Documents (if present): Some NDK undertakings might in any case incorporate Android.mk records for heritage support. These records portray how to assemble local code. On the off chance that they exist, concentrate on them to comprehend how they add to the form cycle. Source Code: Look at the source code documents, particularly the local C/C++ code. Comprehend the reason and usefulness of each source document. Focus on any JNI (Java Local Point of interaction) code assuming that the venture incorporates local code with Java code. Construct Cycle: Figure out how the undertaking is assembled. Regularly, CMake creates fabricate scripts for the chose assemble framework (e.g., Ninja, Makefiles). Find out more about the form targets and how they are arranged in the CMakeLists.txt documents. Aggregation Banners and Choices: Check for compiler banners and choices determined in the CMakeLists.txt documents. These banners can influence code streamlining, troubleshooting, and similarity. Troubleshooting and Logging: Comprehend how the task handles troubleshooting and signing in local code. Search for troubleshoot images and logging explanations. Testing: On the off chance that the task incorporates unit tests or joining tests, investigate how they are designed and run. CMake frequently upholds testing systems like Google Test. IDE Combination: Assuming you're utilizing a coordinated improvement climate (IDE) like Android Studio or Visual Studio with the Android NDK module, ensure the task is set up for consistent turn of events and troubleshooting. Adaptation Control: Check assuming the undertaking utilizes variant control frameworks like Git. Understanding the commit history can give experiences into project improvement. Documentation: Search for project documentation, README records, or remarks inside the codebase. These assets can give significant setting and utilization guidelines. Assemble Variations: In the event that the task has numerous form variations (e.g., discharge, troubleshoot, various designs), comprehend how to switch among them and their separate arrangements. Construct and Run: At last, form and run the undertaking to guarantee it capabilities true to form. Address any form or runtime issues as they emerge.