Create Polyspace Analysis Configuration Based on Android Builds
You can run a Polyspace® analysis and check for bugs or prove absence of run-time errors in C/C++ code in Android® applications. The most efficient approach to analyze Android applications is to create Polyspace analysis modules based on the existing modularization in your source code. You can then analyze a relatively smaller individual module instead of the entire codebase.
This topic describes in brief the steps for creating a Polyspace analysis module based on the modularization in the Android codebase.
Prerequisites
This topic assumes that you are familiar with building an Android application. For more information on:
Setting up an Android build, see Anrdoid Build
Downloading the Android source, see Download the Android Source
The topic also assumes that your Android repository contains a list of modules specified in a file. The file is typically named .repo/project.list
.
Step 1: Export JSON Compilation Database
Generate and export a compilation database file corresponding to the Android build.
Open a terminal and navigate to the root of your Android repository.
Enter these or equivalent commands to generate a CCDB file:
Here,source build/envsetup.sh lunch <targetDeviceName> export SOONG_GEN_COMPDB=1 m nothing
<targetDeviceName>
is the name of the target for which you are building. The CCDB filecompile_commands.json
is generated in a folder such as<rootPath>/out/soong/development/ide/compdb/
, where<rootPath>
is relative to the root path of the repository.
Step 2: Create Polyspace Analysis Module
Create Polyspace analysis modules corresponding to the modules listed in your Android repository.
To create the Polyspace analysis modules, run the polyspace-configure
command with the CCDB file and the file with the list of Android repo modules as argument. Use one of these approaches:
Generate one Polyspace options file per module:
This command generates one Polyspace options file per module listed in the filepolyspace-configure -module-list <fileWithModuleList> -compilation-database <ccdbFile> -output-options-path <optionFilesPath>
<fileWithModuleList>
(see Prerequisites). The sources and compilation options for the module are extracted from the CCDB file<ccdbFile>
. The options files are stored in the folder specified by<optionFilesPath>
and each options file is named<moduleFolder>.psopts
after the module folder name<moduleFolder>
.Generate one Polyspace project file (
.psprjx
file) per module:This command generates one Polyspace project per module listed in the filepolyspace-configure -module-list <fileWithModuleList> -compilation-database <ccdbFile> -output-platform-project <projectWorkspace>
<fileWithModuleList>
. The sources and compilation options for the module are extracted from the CCDB file<ccdbFile>
. The projects are linked from the workspace<projectWorkspace>
and each project file is named<moduleFolder>.psprjx
after the module folder name<moduleFolde>
.
Step 3: Run Polyspace Analysis on Module
Run a Polyspace analysis on a module using the corresponding options file or project:
Build the module so that any file that is generated during build is available for the Polyspace analysis.
Run Polyspace Bug Finder™ or Polyspace Code Prover™ on the module using the corresponding project or options file. For more information, see: