源码迁移命令参考
源码迁移功能分析用户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}]
参数说明
参数 |
参数选项 |
参数说明 |
---|---|---|
-h/--help |
- |
获取帮助信息。 |
-i/--input-path |
- |
待扫描源码的文件夹或压缩包路径,若存在多个扫描路径需使用英文逗号分割。 |
-c/--cmd |
- |
源码的构建命令,需使用单/双引号引起来。若命令包含空格,需使用单引号。 说明:
当待扫描源码类型包含c/c++/asm/fortran/go时,则必须指定构建命令。 |
-s/--source-type |
c/c++/asm/fortran/go/ interpreted |
待扫描源码类型,默认为'c,c++,asm'。 |
-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。
|
-r/--report-type |
all/json/html/csv |
扫描报告的格式,默认为all。
|
--ignore |
/opt/ignore.json |
屏蔽扫描规则信息,默认读取工具路径下的ignore.json文件。 |
--macro |
- |
自定义x86平台宏。输入自定义宏时,多个宏之间请用“;”进行分割。 |
--keep-going |
True/False |
发现arm/arm64/aarch64关键字是否继续扫描。
|
使用示例
此处以分析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库不一样,所以分析报告会有差异。
输出说明
参数 |
说明 |
|
---|---|---|
Scanned time |
扫描时间。 |
|
Configuration |
Source Code File Path |
扫描的源码文件存放路径。 |
Target OS |
目标操作系统。 |
|
Target OS Kernel Version |
内核版本。 |
|
Compiler Version |
编译器版本。 |
|
Build Tool |
构建工具。 |
|
Software make command |
编译命令。 |
|
Interpreted(Python,Java,Scala) |
分析对象是否包括解释型语言文件。
|
|
Go |
分析对象是否包括Go语言文件。
|
|
Custom x86 Macros |
自定义x86宏。 |
|
Summary |
Compatible: x, To be Verified: x, Total Dependencies: x |
显示兼容鲲鹏平台的文件数,待验证文件数以及依赖库文件总数。 |
Source Need Migrated |
源码是否需要迁移。
|
|
Scanned xx C/C++/Fortran files, xx |
显示需要迁移的C/C++/Fortran文件和Makefile/CMakeLists.txt/Automake related文件总数以及文件个数。 |
|
Total xx lines C/C++/Makefile/CMakeLists.txt/Automake code and xx lines embedding ASM 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 |
显示依赖库文件扫描的详细信息:
|
|
Source files scan details are as follows |
显示源文件分析报告的详细信息:
|