Porting Source Code Using Command Lines
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 /DevKit-CLI-24.0.RC1-Linux-Kunpeng/porting/devkitplugins/all_asm/bin directory.
- 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-to-source-code -c,--cmd 'string of compiling command line' [-s,--source-type {c|c++|asm|fortran|go| interpreted}*] [-t,--target-os target-os] [-p,--compiler compiler-version] [-f,--fortran-compiler fortran-compiler-version] [-o,--output path-to-output] [-b,--build-tool {make,cmake,automake,go}] [-r,--report-type {all/json/html/csv}] [-l,--log-level {0,1,2,3} ] [--set-timeout time-limit-for-task] [--ignore path-to ignore-file] [--micro MICRO] [--keep-going {True,False}]
Parameter Description
Parameter |
Option |
Description |
|---|---|---|
-i/--input-path |
path |
Path to the source code folder or package to be scanned. Use commas (,) to separate multiple paths. This parameter is mandatory. Example: /home/test1,/home/test2 |
-c/--cmd |
cmd |
Source code build command, which must be enclosed in single or double quotation marks. If the command contains spaces, use single quotation marks ('). This parameter is optional. Example: 'make all' |
-s/--source-type |
c,c++,asm,fortran,go,interpreted |
Type of the source code to be scanned. This parameter is optional. |
-t/--target-os |
target-os |
Target OS to which source code is ported. This parameter is optional. If this parameter is not specified, the current OS is used by default. Example: bclinux7.7 |
-p/--compiler |
gcc,clang |
Compiler version. This parameter is optional. The default value is the default GCC version of the selected target OS. Example: gcc7.8.5 |
-f/--fortran-compiler |
flang-ver |
Compiler version of the Fortran code. This parameter is optional. The default value is flang2.5.0.1. |
-b/--build-tool |
make,cmake,automake,go |
Build tool name. This parameter is optional. The default value is make. You can select go only when --source-type does not contain c/c++/asm/fortran and contains go. |
-o/--output |
path-to-output |
Path and file name of the scan report. This parameter is optional. By default, scan reports are stored in the current execution path. A scan report name is in the format of Function name_Timestamp_4-digit UUID. |
--set-timeout |
time |
Command line timeout period. This parameter is optional. By default, there is no timeout period. |
-l/--log-level |
0,1,2,3 |
Log level. This parameter is optional. The options are 0 (DEBUG), 1 (INFO), 2 (WARNING), and 3 (ERROR). The default is 1 (INFO). |
-r/--report-type |
all,json,html,csv |
Format of the scan report. This parameter is optional. The default value is all, which meaning that JSON, CSV, and HTML reports will be generated. |
--ignore |
/opt/ignore.json |
Masks scan rule information. This parameter is optional. |
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 wtdbg2-2.5 -c "make"
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.)
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: /opt/DevKit-CLI-24.0.RC1-Linux-Kunpeng/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: YES
Summary:
Compatible: 0, To be Verified: 0, Total Dependencies: 0
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:
/opt/DevKit-CLI-24.0.RC1-Linux-Kunpeng/src-mig_20240229014159_918c.json
/opt/DevKit-CLI-24.0.RC1-Linux-Kunpeng/src-mig_20240229014159_918c.csv
/opt/DevKit-CLI-24.0.RC1-Linux-Kunpeng/src-mig_20240229014159_918c.html
The analysis reports vary with the target OS because different OSs support different SO libraries.
Output Description
Parameter |
Description |
|
|---|---|---|
Scanned time |
Time when the code was scanned. |
|
Configuration |
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.
|
|
Go |
Indicates whether the analysis object includes a Go language 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 |
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:
|
|