中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助

源码迁移命令参考

源码迁移功能分析用户C/C++/ASM/Fortran/Go/解释型语言软件的可迁移性。

命令功能

在终端环境下分析用户C/C++/ASM/Fortran/Go/解释型语言软件的可迁移性。

如果用户所处的环境Glibc版本低于2.28,则无法使用最新的汇编文件自动翻译功能,如有需要,请按照以下步骤进行操作:

  • 可连接外网:在“PATH/porting/devkitplugins/all_asm/bin”下执行bash addAsmLibraries.sh即可。若使用RPM安装方式,则PATH为/usr/local/devkit;若使用解压压缩包方式安装,则PATH为解压路径。
  • 无法连接外网:需手动创建tmp/rpm目录,把rpm包放至“DevKit/devkitplugins/all_asm/tmp/rpm”目录下,然后在“DevKit/devkitplugins/all_asm/bin”下执行bash addAsmLibraries.sh即可。

命令格式

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}]

参数说明

表1 参数说明

参数

参数选项

参数说明

-h/--help

-

获取帮助信息。

-i/--input-path

-

待扫描源码的文件夹或压缩包所在路径,若存在多个扫描路径需使用空格分割。

例如:/home/test1 /home/test2。

-c/--cmd

-

源码的构建命令,需使用单/双引号引起来。若命令包含空格,需使用单引号。

说明:
  • 当待扫描源码类型包含c/c++/asm/fortran/go时,则必须指定构建命令。
  • 命令行工具源码构建命令不支持设置变量和export环境变量。

    例如:"CFLAGS='-O0 -g';make"或"export CFLAGS='-O0 -g';make"。

-s/--source-type

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

待扫描源码类型,默认为'c,c++,asm'。

interpreted为解释型语言,目前支持的解释型语言包括Python、Java和Scala。

-t/--target-os

详见-h帮助信息。

迁移的目标操作系统,如果用户不输入则默认为当前操作系统。

-p/--compiler

详见-h帮助信息。

编译器版本,c/c++/asm和go语言使用相同的编译器版本。默认为目标操作系统附带的编译器版本。

-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代码的编译器版本,默认为flang2.5.0.1。

-b/--build-tool

make/cmake/automake/go

构建工具,默认make。只有在待扫描源码类型中没有c/c++/asm/fortran并且包含go时可以选go。

-o/--output

-

扫描报告的存放路径,默认存放在当前执行路径下,报告名称为特性名称_时间戳。

--set-timeout

-

任务超时时间,单位为分钟,若执行时间超过超时时间则退出执行。默认无超时时间,任务将持续执行直到结束。

-l/--log-level

0/1/2/3

设置日志级别,默认为1。
  • 0:日志级别为DEBUG。
  • 1:日志级别为INFO。
  • 2:日志级别为WARNING。
  • 3:日志级别为ERROR。

-r/--report-type

all/json/html/csv

扫描报告的格式,默认为all。
  • all:生成JSON、HTML、CSV三种格式报告。
  • json:生成JSON格式报告。
  • html:生成HTML格式报告。
  • csv:生成CSV格式报告。

--ignore

/opt/ignore_rules.json

可通过配置屏蔽扫描规则文件,屏蔽不影响扫描结果的信息。默认读取工具路径下的ignore_rules.json文件,具体格式请参见屏蔽扫描规则文件说明(--ignore)

--macro

-

自定义x86平台宏。输入自定义宏时,多个宏之间请用“;”进行分割。

--keep-going

True/False

发现arm/arm64/aarch64关键字是否继续扫描。

  • True
  • False

使用示例

此处以分析TestData工程代码并输出CSV格式、JSON格式、HTML格式的分析报告为例,请根据实际情况将“/home/TestData/”替换成实际需要扫描的代码路径。

devkit porting src-mig -i /home/TestData/wtdbg2-2.5 -c "make"

返回信息如下,并输出报告。

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

不同的目标操作系统支持的SO库不一样,所以分析报告会有差异。

屏蔽扫描规则文件说明(--ignore)

可通过ignore_rules.json文件配置屏蔽扫描规则,配置完成后重新扫描文件,扫描报告中将不会展示该扫描项。配置示例如下:

{
        "src_list": [
                "-march",
                "-mpopcnt",
        ],
        "lib_list": [
                "libz.so.1"
        ]
}
  • lib_list:需要屏蔽的依赖文件列表。
  • src_list:需要屏蔽的源码文件关键字列表。

输出说明

表2 输出说明

参数

说明

Scanned time

扫描时间。

Configuration

Task name

源码迁移任务名称。

Scanned time

扫描时间。

Source Code File Path

扫描的源码文件存放路径。

Target OS

目标操作系统。

Target OS Kernel Version

内核版本。

Compiler Version

编译器版本。

Build Tool

构建工具。

Software make command

编译命令。

Interpreted(Python, Java, Scala)

分析对象是否包括解释型语言文件。

  • True:是
  • False:否

Go

分析对象是否包括Go语言文件。

  • True:是
  • False:否

Custom x86 Macros

自定义x86宏。

Summary

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

显示兼容鲲鹏平台的文件数、待修改文件数和依赖库文件总数。

Source Need Migrated

源码是否需要迁移。

  • Yes
  • No

Total xx rules and xx suggestions.

显示规则以及建议总数。

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

显示C/C++文件总数,Makefile/CMakeLists.txt/Automake相关文件总数以及需要迁移的文件个数。

Total xx lines C/C++/Makefile/CMakeLists.txt/Automake code need to be migrated.

显示源码总行数以及需要迁移的内联汇编代码行数。

Scanned xx pure assembly files, xx pure assembly files to be migrated.

显示全汇编文件总数以及需要迁移的汇编文件个数和汇编代码行数。

Scanned x Go files, total x Go files xx lines need to be migrated.

显示Go文件总数以及需要迁移的Go文件个数和Go代码行数。

Scanned xx python files, total xx files xx lines need to be migrated.

显示Python文件总数以及需要迁移的Python文件个数和Python代码行数。

Scanned xx java files, total xx files xx lines need to be migrated.

显示Java文件总数以及需要迁移的Java文件个数和Java代码行数。

Scanned xx scala files, total xx files xx lines need to be migrated.

显示Scala文件总数以及需要迁移的Scala文件个数和Scala代码行数。

Estimated transplant workload: xx person/months.(C/C++/Fortran/Go, 500

Line/PM; ASM, 250Line/PM)

显示源码迁移预估人力(x/人月)。

预估标准:1人月迁移工作量=500行C/C++/Fortran/Go源代码,或250行汇编代码。

Architecture-related Dependencies

显示依赖库文件扫描的详细信息:

  • File Name:文件名称。
  • File Type:文件类型。
  • Analysis Results:分析结果。
  • Handling Suggestions:处理建议。
  • URL:下载地址。

Source files scan details are as follows

显示源文件分析报告的详细信息:

  • filename:扫描文件全路径。
  • filetype:扫描文件的类型。
  • line number:函数在文件中的行号。
  • rows:函数在文件中的总行数。
  • category:关键字所属类型。
  • keyword:关键字名称。
  • suggestion:迁移建议或者提示建议。
  • description:关键字用法描述。
  • modification_level:修改级别。
  • reason:原因分析。