Scanning Source Code in the Terminal Tool
Function
Analyzes the portability of C/C++/ASM/Fortran/Go/interpreted language software.
Syntax
1 | /opt/DevKit/tools/devkit sourcescan -S/--source <source dir> -C/--compiler <compiler> --fc-ver <gfortran version> --c <true/false> --go <true/false> --interpreted <true/false> -T/--tools <constructtools> --cmd <cmd> -m <MACRO> --tos <target os> |
/opt/DevKit/tools/ is the directory for storing the tool. Replace it with the actual directory.
Parameter Description
Argument |
Parameter |
Description |
|---|---|---|
-S/--source |
SOURCE_DIR |
Path of the source file to be scanned. This parameter is mandatory. The path must be a full path. Example: /path/to/sourcecode NOTE:
|
-C/--compiler |
compiler |
Compiler version. This parameter is optional. Example: bisheng compiler2.5.0.1 The default compiler versions of the target OSs are as follows:
The tool supports the following GCC versions:
NOTE:
If the specified compiler version is BiSheng Compiler 2.5.0, see the following example: -C 'bisheng compiler2.5.0' |
--fc-ver |
fortran_compiler_version |
Fortran compiler version. This parameter is optional. Example: gfortran7 The tool supports the following Fortran compiler versions:
|
--c |
|
Scans C, C++, and ASM files. This parameter is optional. |
--go |
|
Scans Go files. This parameter is optional. |
--interpreted |
|
Scans interpreted language files. This parameter is optional. Python, Java, and Scala are supported. |
-T/--tools |
tools |
Build tool and CLI. Default value: make This parameter is optional. The options are:
|
--cmd |
CMD |
Complete software build command to be used. The build command must contain the "make" field. This parameter is mandatory. Example: 'make all'
|
-m/--macro |
MACRO |
Custom x86 macros. This parameter is optional. Use semicolons (;) to separate multiple custom macros. |
--tos |
tos |
Name and version of the target Linux OS. This parameter is mandatory. Example: CentOS 7.6 The tool supports the following OSs:
|
Example
The following demonstrates how to analyze the TestData project code and generate analysis reports in CSV, JSON, and HTML formats. Replace /home/TestData/ with the actual code path to be scanned.
1 | ./devkit sourcescan -S /home/TestData --cmd 'make all' --tos openeuler22.03 -C 'bisheng compiler2.5.0.1' |
The following information is displayed. Input the password of the common user in the interactive prompts. (The password is required when the user is used for the first time.)
1 2 3 4 5 | Task is running. Progress: 100%... Source code porting analysis succeeded. Successfully downloaded the report to /opt/DevKit/tools/report/sourcescan/20230607114650/report.csv. Successfully downloaded the report to /opt/DevKit/tools/report/sourcescan/20230607114650/report.json. Successfully downloaded the report to /opt/DevKit/tools/report/sourcescan/20230607114650/report.html. |
- By default, the generated analysis report is saved in ./report/yyyymmddhhmmss/ in the storage path of the terminal tool.
- The analysis reports vary with the target OS because different OSs support different SO libraries.
Output Description
Parameter |
Description |
|
|---|---|---|
Scanned time |
Time when the file was scanned. |
|
Configuration |
Source Code File Path |
Directory where the scanned source file is stored. |
Target OS |
Target OS. |
|
Target OS Kernel Version |
Kernel version. |
|
Compiler Version |
Compiler version. |
|
Build Tool |
Build tool. |
|
Software make command |
Compile command. |
|
Interpreted(Python,Java,Scala) |
Indicates whether the analysis object includes an interpreted language file.
|
|
Go |
Indicates whether the analysis object includes a Go file.
|
|
Custom x86 Macros |
Custom x86 macros. |
|
Summary |
Compatible: x, To be Verified: x, Total Dependencies: x |
Number of files compatible with the Kunpeng platform, number of files to be verified, and number of dependency library files. |
Source Need Migrated |
Indicates whether the source code needs to be ported.
|
|
Scanned xx C/C++/Fortran files, xx Makefile/CMakeLists.txt/Automake related files, total xx files need to be migrated. |
Total number of C/C++/Fortran files, number of Makefile/CMakeLists.txt/Automake related files, and number of files to be ported. |
|
Total xx lines C/C++/Makefile/CMakeLists.txt/Automake code and xx lines embedding ASM code need to be migrated. |
Total lines of source code and lines of inline assembly code to be ported. |
|
Scanned xx pure assembly files, xx pure assembly files to be migrated. |
Total number of pure assembly files, number of pure assembly files to be ported, and lines of assembly code to be ported. |
|
Scanned x Go files, total x Go files xx lines need to be migrated. |
Total number of Go files, number of Go files to be ported, and number of lines of code to be ported. |
|
Scanned xx python files, total xx files xx lines need to be migrated. |
Total number of Python files, number of Python files to be ported, and lines of Python code to be ported. |
|
Scanned xx java files, total xx files xx lines need to be migrated. |
Total number of Java files, number of Java files to be ported, and lines of Java code to be ported. |
|
Scanned xx scala files, total xx files xx lines need to be migrated. |
Total number of Scala files, number of Scala files to be ported, and lines of Scala code to be ported. |
|
Estimated transplant workload: xx person/months.(C/C++/Fortran/Go, 500 Line/PM; ASM, 250Line/PM) |
Estimated manpower (x person months) for source code porting. Baseline workload: 1 person month = 500 lines of C, C++, Fortran, or Go source code or 250 lines of assembly code |
|
Architecture-related Dependencies |
Detailed information about the dependency library files scanned:
|
|
Source files scan details are as follows: |
Details of the source code analysis report:
|
|