Rate This Document
Findability
Accuracy
Completeness
Readability

Scanning Source Code in the Terminal Tool

Function

Analyzes the portability of C/C++/ASM/Fortran/Go/interpreted language software.

Syntax

/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

Table 1 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:
  • The tool considers that a file does not need to be ported and thus does not scan the file by default if the path of the decompressed source file contains only the following keywords, or the keywords prefixed with an underscore (_), followed by an underscore (_), or followed by a file name extension. You can view the files that are not scanned in the porting.log file.
  • Keywords: PPC, PPC64, s390, s390x, powerpc, alpha, MIPS, itanium, WIN64, WIN32, BOOST_COMP_MSVC, arm, aarch64, sparc, sparc64
  • Only TAR, TAR.BZ, TAR.BZ2, TAR.GZ, TAR.XZ, TBZ, TBZ2, TGZ, TXZ, and ZIP packages can be uploaded. Only one package can be uploaded at a time. The size of the source package should be less than or equal to 1 GB. The decompressed file size should be less than or equal to half of the remaining drive space.
  • Only one folder can be uploaded at a time. The total size of files in the folder must be less than or equal to 1 GB.

-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:

  • BC-Linux 7.6: GCC 4.8.5
  • BC-Linux 7.7: GCC 4.8.5
  • CentOS 7.4: GCC 4.8.5
  • CentOS 7.5: GCC 4.8.5
  • CentOS 7.6: GCC 4.8.5
  • CentOS 7.7: GCC 4.8.5
  • CentOS 8.0: GCC 8.2.0
  • CentOS 8.1: GCC 8.3.0
  • CentOS 8.2: GCC 8.3.0
  • Deepin 15.2: GCC 6.3.0
  • Debian 10: GCC 8.3.0
  • EulerOS 2.8: GCC 7.3.0
  • iSoft 5.1: GCC 7.3.0
  • Kylin V10 SP1: GCC 7.3.0
  • Kylin V10 SP2: GCC 7.3.0
  • Kylin V10 SP3: GCC 7.3.0
  • KylinSecOS 3.4: GCC 7.3.0
  • LinxOS 6.0.90: GCC 6.3.0
  • NeoKylin V7U5: GCC 4.8.5
  • NeoKylin V7U6: GCC 4.8.5
  • openEuler 20.03: BiSheng Compiler 2.5.0
  • openEuler 20.03 SP1: GCC 7.3.0
  • openEuler 20.03 SP2: GCC 7.3.0
  • openEuler 20.03 SP3: GCC 7.3.0
  • openEuler 22.03: BiSheng Compiler 2.5.0
  • openEuler 22.03 SP1: GCC 10.3.0
  • SUSE SLES 15.1: GCC 7.4.0
  • Ubuntu 18.04.x: GCC 7.3.0
  • Ubuntu 20.04.x: GCC 9.3.0
  • UOS 20 SP1: GCC 8.3.0
  • UOS 20-1020e: GCC 7.3.0
  • UOS 20-1050e: GCC 7.3.0
  • uosEuler 20: GCC 7.3.0

The tool supports the following GCC versions:

  • GCC 4.8.5/4.9.3/5.1.0/5.2.0/5.3.0/5.4.0/5.5.0/6.1.0/6.2.0/6.3.0/6.4.0/6.5.0/7.1.0/7.2.0/7.3.0/7.4.0/8.1.0/8.2.0/8.3.0/9.1.0/9.2.0/9.3.0/10.1.0/10.2.0/10.3.0
  • BiSheng Compiler

    2.1.0/2.3.0/2.4.0/2.5.0/2.5.0.1

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:

  • GFORTRAN 7/8/9
  • FLANG 2.1.0/2.3.0/2.4.0/2.5.0/2.5.0.1

--c

  • true
  • false

Scans C/C++/ASM files.

This parameter is optional.

--go

  • true
  • false

Scans Go files.

This parameter is optional.

--interpreted

  • true
  • false

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:

  • make
  • cmake
  • automake
  • go

--cmd

CMD

Complete software build command to be used. The build command must contain the "make" field.

This parameter is mandatory.

Example: 'make all'

  • If -T/--tools is set to make, the build command must start with "make". Make supports -C and -f parameters. -C specifies the working directory. -f specifies the makefile.
  • If -T/--tools is set to cmake, the build command must start with "cmake". For details about the parameters supported by CMake, see the CMake 3.13.4 user guide on the official website.
  • If -T/--tools is set to automake, the build command must be make. Automake does not support parameters.

-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:

  • BC-Linux 7.6/7.7
  • CentOS 7.4/7.5/7.6/7.7/8.0/8.1/8.2
  • Deepin V15.2
  • Debian 10
  • EulerOS 2.8
  • iSoft 5.1
  • Kylin V10 SP1
  • Kylin V10 SP2
  • kylin V10 SP3
  • KylinSecOS 3.4
  • LinxOS 6.0.90
  • NeoKylin V7U5
  • NeoKylin V7U6
  • openEuler 20.03
  • openEuler 20.03 SP1
  • openEuler 20.03 SP2
  • openEuler 20.03 SP3
  • openEuler 22.03
  • openEuler 22.03 SP1
  • SUSE SLES 15.1
  • Ubuntu 18.04.x
  • Ubuntu 20.04.x
  • UOS 20 SP1
  • UOS20-1020e
  • UOS20-1050e
  • uosEuler 20
  • More

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.

./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.)

Task is running. Progress: 100%...
 Source code porting analysis succeeded.
Success to download report to  /home/report/sourcescan/20230607114650/report.csv
Success to download report to  /home/report/sourcescan/20230607114650/report.json
Success to download report to  /home/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

Table 2 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.

  • True
  • False

Go

Indicates whether the analysis object includes a Go file.

  • True
  • False

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.

  • Yes
  • No

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:

  • File Name
  • File Type
  • Analysis Results
  • Handling Suggestions
  • URL

Source files scan details are as follows:

Details of the source code analysis report:

  • filename: full path of the file scanned.
  • filetype: type of the file scanned.
  • line number: line number of a function in the file.
  • rows: total number of rows of a function in the file.
  • category: keyword type.
  • keyword: keyword
  • suggestion: porting suggestion.
  • description: description of the keyword usage.