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.
Important Notes
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:
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.
- With Internet connection: Run bash addAsmLibraries.sh in the PATH/porting/devkitplugins/all_asm/bin directory.
- Without Internet connection: Manually create a tmp/rpm directory, save the RPM package to the PATH/porting/devkitplugins/all_asm/tmp/rpm directory, and run bash addAsmLibraries.sh in the PATH/porting/devkitplugins/all_asm/bin directory.
Syntax
1 | 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 target_os | --target-os target_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] [--ignore-path IGNORE_PATH] [--macro MACRO] [--keep-going {True,False}] |
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 ('). |
-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/flang4.0.0/flang4.1.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.
|
-r/--report-type |
all/json/html/csv |
Scan report format, which defaults to all.
|
--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). |
--ignore-path |
- |
Path to the source file or folder to be masked. If there are multiple paths, separate them with spaces. Example: /home/jar /home/ear /home/a.cpp |
--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.
|
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 porting src-mig -i /home/TestData/wtdbg2-2.5 -c "make" |
The following information is displayed and a report is generated:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | Using the local system as target os: openeuler20.03sp1 Scanned time: 2024-12-12 15:37:45 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: Adaptable for Compatibility: 0, To be Modified: 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_20241119012038_7e6a_zh.json /home/DevKit_Software/src-mig_20241119012038_7e6a_zh.csv /home/DevKit_Software/src-mig_20241119012038_7e6a.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:
1 2 3 4 5 6 7 8 9 | { "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
Parameter |
Description |
|---|---|
Configuration |
Task name, report generation time, source file storage path, target OS, target OS kernel version, compiler version, build tool, compile command, user-defined x86 macro, and porting result. |
Architecture-related Dependencies |
Displays the SO files.
|
Source Files to Be Ported |
Number of source files to be ported and number of code lines to be modified. You can click View Suggested Source Code in the Operation column to view the suggestions. The file types include C/C++ source file, Fortran, makefile, Python, Go, Java, Scala, and ASM file. You can filter files to view specific file types. The file paths are sorted based on Unicode, and the code lines to be modified are sorted in sequence. |