我要评分
获取效率
正确性
完整性
易理解

Source Code Porting

The source code porting function analyzes the portability of software written in C/C++/ASM/Fortran/Go or an interpreted language.

Command Function

Analyzes the portability of software written in C/C++/ASM/Fortran/Go or an interpreted language on a terminal.

The latest function of automatic assembly translation is not available if the Glibc version in your environment is earlier than 2.28. To use this function, perform the following operation:

  • With Internet connection: Run bash addAsmLibraries.sh in the PATHporting/devkitplugins/all_asm/bin directory. If you install the tool using the RPM installation package, PATH is /usr/local/devkit. If you install the tool by decompressing the package, PATH is the decompression path.
  • Without Internet connection: Manually create a tmp/rpm directory, save the RPM package to the DevKit/devkitplugins/all_asm/tmp/rpm directory, and run bash addAsmLibraries.sh in the DevKit/devkitplugins/all_asm/bin directory.

Syntax

devkit porting src-mig {-i INPUT_PATH | --input INPUT_PATH} {-c 'command' | --cmd 'command'} [-s {c|c++|asm|fortran|go| interpreted}* | --source-type {c|c++|asm|fortran|go| interpreted}*] [-t targe_os | --target-os targe_os] [-p compiler_version | --compiler compiler_version] [-f  fortran-compiler-version | --fortran-compiler fortran-compiler-version] [-o OUTPUT_PATH | --output OUTPUT_PATH] [-b {make,cmake,automake,go} | --build-tool {make,cmake,automake,go}] [-r {all,json,html,csv} | --report-type {all,json,html,csv}] [-l {0,1,2,3} | --log-level {0,1,2,3}] [--set-timeout TIMEOUT] [--ignore ignore_file] [--macro MACRO] [--keep-going {True,False}]

Parameter Description

Table 1 Parameter description

Parameter

Option

Description

-h/--help

-

Obtains help information.

-i/--input-path

-

Path to the source code folder or package to be scanned. Use spaces to separate multiple paths.

Example: /home/test1 /home/test2

-c/--cmd

-

Source code build command, which must be enclosed in single or double quotation marks. If the command contains spaces, use single quotation marks (').

NOTE:
  • If the source file to be scanned contains C/C++/ASM/Fortran/Go code, specify the build command.
  • The source code build command in the command line tool does not support variable setting and environment variable export.

    Example: "CFLAGS='-O0 -g';make" or "export CFLAGS='-O0 -g';make"

-s/--source-type

c/c++/asm/fortran/go/interpreted

Type of the source code to be scanned, which defaults to 'c,c++,asm'.

The supported interpreted languages are Python, Java, and Scala.

-t/--target-os

See the -h help information.

Target OS. If this parameter is not set, the current OS is used by default.

-p/--compiler

See the -h help information.

Compiler version. C, C++, ASM, and Go use the same compiler version. The default value is the compiler version included in the target OS.

-f/--fortran-compiler

flang2.1.0/flang2.3.0/flang2.4.0/flang2.5.0/flang2.5.0.1/flang3.0.0/flang3.1.0/flang3.2.0/gfortran7/gfortran8/gfortran9

Fortran code compiler version, which defaults to flang2.5.0.1.

-b/--build-tool

make/cmake/automake/go

Build tool, which defaults to make. You can select go only when the source file to be scanned contains Go code but no C/C++/ASM/Fortran code.

-o/--output

-

Path for storing scan reports. By default, scan reports are stored in the current execution path. A report name is the format of Feature name_Timestamp.

--set-timeout

-

Timeout interval of a task, in minutes. If the execution duration exceeds the timeout interval, the task exits. By default, there is no timeout interval. The task will be executed until it is complete.

-l/--log-level

0/1/2/3

Log level, which defaults to 1.
  • 0: DEBUG
  • 1: INFO
  • 2: WARNING
  • 3: ERROR

-r/--report-type

all/json/html/csv

Scan report format, which defaults to all.
  • all: generates reports in JSON, HTML, and CSV formats.
  • json: generates a report only in JSON format.
  • html: generates a report only in HTML format.
  • csv: generates a report only in CSV format.

--ignore

/opt/ignore_rules.json

You can configure the masking rule file to mask scan items that will not affect the scan result. By default, the ignore_rules.json file in the tool path is read. For details about the file format, see Masking Rule File (--ignore).

--macro

-

Custom x86 macros. Separate multiple macros with semicolons (;).

--keep-going

True/False

Indicates whether to continue the scan when the keyword arm, arm64, or aarch64 is found.

  • True
  • False

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 porting src-mig -i /home/TestData/wtdbg2-2.5 -c "make"

The following information is displayed and a report is generated:

Using the local system as target os: openeuler20.03sp1
Scanned time: 20240229094159
Configuration:
    Check the related source files according to the build command
    Scan code path: /home/TestData/wtdbg2-2.5/
    Compiler: GCC 4.8.5
    Interpreted(Python, Java, Scala): False
    Go: False
    Target OS: openeuler20.03sp1, kernel: 4.19.90
    Software make command: make
    Source Need Migrated: Need Migrated
 
Summary:
    Compatible: 0, To be Verified: 0, Total Dependencies: 0
    Total 5 rules and 10 suggestions.
    Scanned 32 C/C++ files, 1 Makefile/CMakeLists.txt/Automake related files, total 3 files need to be migrated.
    Total 13 lines C/C++/Makefile/CMakeLists.txt/Automake code need to be migrated.
    Scanned 0 pure assembly files, no pure assembly files to be migrated.
    Scanned 0 Go files, no Go files to be migrated.
    Scanned 0 python files, no python files to be migrated.
    Scanned 0 java files, no java files to be migrated.
    Scanned 0 scala files, no scala files to be migrated.
 
For the detailed information, please check:
/home/DevKit_Software/src-mig_20240229014159_918c.json
/home/DevKit_Software/src-mig_20240229014159_918c.csv
/home/DevKit_Software/src-mig_20240229014159_918c.html

The analysis reports vary with the target OS because different OSs support different SO libraries.

Masking Rule File (--ignore)

You can edit the ignore_rules.json file to configure what to mask in scans. After that, masked scan items will not be displayed in scan reports. See the example configuration:

{
        "src_list": [
                "-march",
                "-mpopcnt",
        ],
        "lib_list": [
                "libz.so.1"
        ]
}
  • lib_list: list of dependency files to be masked.
  • src_list: list of source file keywords to be masked.

Output Report

Table 2 Output description

Parameter

Description

Scanned time

Time when the code was scanned.

Configuration

Task name

Name of the source code porting task.

Scanned time

Time when the code was scanned.

Source Code File Path

Directory where the scanned source code is stored.

Target OS

Target OS.

Target OS Kernel Version

Kernel version of the target OS.

Compiler Version

Compiler version.

Build Tool

Build tool name.

Software make command

Compile command.

Interpreted(Python, Java, Scala)

Indicates whether the analysis object includes an interpreted language file.

  • True: yes
  • False: no

Go

Indicates whether the analysis object includes a Go language file.

  • True: yes
  • False: no

Custom x86 Macros

Custom x86 macros.

Summary

Adaptable for Compatibility: x, To be Modified: x, Total Dependencies: x

Number of files compatible with the Kunpeng platform, number of files to be modified, and number of dependency library files.

Source Need Migrated

Indicates whether the source code needs to be ported.

  • Yes
  • No

Total xx rules and xx suggestions.

Total number of rules and suggestions.

Scanned xx C/C++ files, xx Makefile/CMakeLists.txt/Automake related files, total xx files need to be migrated.

Total number of C and C++ files, total number of Makefile, CMakeLists.txt, and Automake files, and the number of files to be ported.

Total xx lines C/C++/Makefile/CMakeLists.txt/Automake 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
  • suggestion: porting suggestion.
  • description: description of the keyword usage.
  • modification_level: level of the modification.
  • reason: reason for the operation.