移植speexdsp到OpenHarmony标准系统⑥

268 篇文章 2 订阅
139 篇文章 0 订阅

九、准备好上传speexdsp至OpenHarmony仓库。

移植完成后,先将代码上传至sig仓中的contest仓

sig仓库是TPC仓库的孵化仓。代码先上sig仓,到时会直接平移到tpc仓。

上传的内容包括:

  • 原生库代码
    • (除了涉及需要修改原生库代码的部分,其他都不能上传,例如编译途中生成的中间文件)
  • BUILD.gn
  • README.Opensource
  • 库对外导出的所有api接口export_api.txt
  • 测试过的api接口tested_api.txt
  • 功能测试文档: 三方库_test_function.md
    • 内容至少包含罗列出库所有的功能,已测试过的功能,原生库测试逻辑的分析
  • 原生库分析文档: 三方库_analyse.md

文档命名不要用中文,如果涉及到编码问题的话,到时候会出现乱码,一般建议不用中文命名!!!

提供OAT.xml文件

OAT开源扫描

  • OAT(OSS Audit Tool)是OpenHarmony社区的自动化开源审视工具,用于帮助开发人员基于自定义的规则自动扫描开源仓代码,识别不符合预定规则的代码并输出扫描报告。
  • OAT下载地址:https://gitee.com/openharmony-sig/tools_oat

工具使用

编译构建:

  • 在linux上安装好javaMaven后,下载OAT工具源码,执行mvn package完成构建。

  • 编译构建成功

在父目录下添加OAT.xml,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.

    This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.

-->

<configuration>
    <oatconfig>
        <licensefile>COPYING</licensefile>
        <policylist>
            <policy name="projectPolicy" desc="">
                <!--policyitem type="compatibility" name="GPL-2.0+" path="abc/.*" desc="Process that runs independently, invoked by the X process."/-->
                <policyitem type="license" name="*" path=".*" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter" desc=""/>
            </policy>
        </policylist>
        <filefilterlist>
            <filefilter name="defaultFilter" desc="Files not to check">
                <filteritem type="filepath" name=".*" desc="原生库文件"/>
            </filefilter>
            <filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
                <!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
                <!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
                <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
                <filteritem type="filepath" name=".*" desc="原生库代码"/>
            </filefilter>
            <filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies">
                <!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
                <!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
                <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
                <filteritem type="filepath" name=".*" desc="原生库代码"/>
            </filefilter>
            <filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies">
                <!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
                <!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
                <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
            </filefilter>
            <filefilter name="readmeFileNamePolicyFilter" desc="Filters for README file policies">
                <!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
                <!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
                <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->

            </filefilter>
            <filefilter name="readmeOpenSourcefileNamePolicyFilter" desc="Filters for README.OpenSource file policies">
                <!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
                <!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
                <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
            </filefilter>
            <filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
                <!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
                <!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
                <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
            </filefilter>

        </filefilterlist>
        <licensematcherlist>
            <!--licensematcher name="uvwxyz License" desc="If the scanning result is InvalidLicense, you can define matching rules here. Note that quotation marks must be escaped.">
                <licensetext name="
                    uvwxyz license textA xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
				 " desc=""/>
                <licensetext name="
                    uvwxyz license textB xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
				 " desc=""/>
            </licensematcher-->
        </licensematcherlist>
    </oatconfig>
</configuration>

在speexdsp根目录下新建空白的OAT_report.text文件,执行命令:

Java –jar ohos_ossaudittool-1.0.jar –s src_dir –r report_file –n selfcheck
  • ohos_ossaudittool-1.0.jar 工具包名,需要带实际路径

  • -s 指定需要检查的代码目录,src_dir 改成要检查的项目路径

  • -r 指定报告输出文件的路径,检查完成后可查看此文件中列出的问题,按指导文档修复

  • report_file

  • -n 检查任务的名称,任意指定,本地检查使用不上。

例如笔者执行的语句为:

sudo java -Dfile.encoding=UTF-8 -jar /home/jiajiahao/Desktop/tools_oat-master/target/ohos_ossaudittool-1.0.jar -s /home/jiajiahao/Desktop/gitee_speexdsp -r /home/jiajiahao/Desktop/gitee_speexdsp/OAT_report.text -n nameOfRepo

扫描结果

执行完上述命令后,OAT_report.text生成内容如下:

同时在speexdsp父目录下生成log文件夹

  • LicenseFile.txt位于OAT工具运行目录的log目录下,此文件记录扫描目录下所有疑似许可证的文件

原生库通过make或者cmake时生成的一些配置文件。如比较通用的config.h配置文件,config.h文件为原生库生成文件,原则上也不做修改,为了避免文件上仓进行代码扫码,可以将文件文件修改后缀名(config.h.in)。相关文档中需要将配置文件使用方法说明。

提供README.OpenSource文件

README.Opensource的格式如下:

[
    {
      "Name": "",				## 库名
      "License": "",			## 开源协议
      "License File": ",		## 开源文件,一般开源项目都会自带该文件
      "Version Number": "",		## 库的版本
      "Owner": "",				## 作者
      "Upstream URL": "",		## 开源库的地址
      "Description": ""			## 库的描述
    }
]

speexdsp的README.OpenSource文件如下:

[
    {
        "Name": "speexdsp",
        "License": "BSD-3-Clause",
        "License File": "COPYING",
        "Version Number": "1.2.1",
        "Owner": "2692032597@qq.com",
        "Upstream URL": "https://speex.org/",
        "Description": "Speexdsp is a speech processing library that goes along with the Speex codec"
    }
]

提供库的分析文档

三方库分析文档如下:

一、确定库实现方式
例如:C/C++/JS/JAVA

二.依赖分析
例如:当前库依赖其他三方库,如下

1)库名1,库仓库地址

2)库名2,库仓库地址

三、license以及版权
例如:一般在license文件或者COPYING中,Apache License V2.0

四、最新一次版本
xx年xx月xx日,版本号xxx

五、功能点分析
(罗列出该库所支持的功能)

六、代码规模
(统计库代码总行数,包括.h/.hpp/.c/.cpp/.cc 等代码相关文件)

提供功能测试文档

文档中需罗列出

  • 库所有的功能
  • 已测试过的功能
  • 原生库测试逻辑的分析

提供导出的api接口列表

1、 导出库对外暴露的所有api接口的列表
2、导出库对外暴露的已测试api接口的列表

十、上传speexdsp至OpenHarmony仓库

配置个人信息

打开git bash,依次输入以下命令:

git config --global user.name "xxxx"   (配置用户名,xxxx为账号用户名,即个人空间地址)
git config --global user.email "xxxxxx@xxx"  (gitee 账号邮箱与签署DCO 的邮箱保持一致即可) 
git config --list         (查看配置情况)
git config --global credential.helper store (解决每次git pull都要输入账号信息的问题)

克隆仓库内容到本地

到个人账号点击并进入contest仓库, fork该仓库:

进入到clone界面,复制clone的链接地址。

执行如下语句:

git clone https://gitee.com/xxxxx/contest.git --depth=1
  • –depth=1意思是只clone当前仓库最新版本,省去一些历史log,避免仓库历史记录过于庞大花费太多clone时间。

  • clone完毕之后,即可在本地目录下看到这个clone的仓库。本地目录所在位置是根据git bash的位置决定的,比如在桌面启动git bash,则clone的仓库会出现在桌面。

利用git lfs机制添加特殊文件

提交三方库时候,文档中有PDF文件时就需要使用利用git lfs机制

git lfs track xxx/xxx.pdf  // 声明该特殊文件到git lfs机制

git add .gitattributes // 添加配置文件

git add xxx/xxx.pdf // 添加具体特殊文件到暂存区中

git lfs ls-files  // 确认相关test_lfs.a 文件是否已经添加到lfs 机制中。

git  add *   //将变更文件加入到暂存区

git commit -s -m  "add xxxxxxxx"  //将暂存区内容签名并提交到本地
  • -s是签名表明这次提交者签名(signoff)
  • -m是对此次提交行为进行备注.
git commit --amend

推送本地修改到账号仓库

现在需要将本地仓库的修改内容推送到gitee上fork后的个人仓库,使用git push命令来完成这个动作。

git push origin master
  • origin指的是自己的仓库对应的原始远程服务器地址;
  • master标识的是想要提交的分支。
  • 可以使用 git remote -v查看配置的远程服务器;
  • git branch -a查看所有的分支。

为了帮助到大家能够更有效的学习OpenHarmony 开发的内容,下面特别准备了一些相关的参考学习资料:

OpenHarmony 开发环境搭建:https://qr18.cn/CgxrRy

《OpenHarmony源码解析》:https://qr18.cn/CgxrRy

  • 搭建开发环境
  • Windows 开发环境的搭建
  • Ubuntu 开发环境搭建
  • Linux 与 Windows 之间的文件共享
  • ……

系统架构分析:https://qr18.cn/CgxrRy

  • 构建子系统
  • 启动流程
  • 子系统
  • 分布式任务调度子系统
  • 分布式通信子系统
  • 驱动子系统
  • ……

OpenHarmony 设备开发学习手册:https://qr18.cn/CgxrRy

OpenHarmony面试题(内含参考答案):https://qr18.cn/CgxrRy

  • 25
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值