啃论文俱乐部——移植speexdsp到OpenHarmony标准系统⑥ 原创 精华

离北况归
发布于 2022-9-12 18:50
浏览
3收藏
  • 大家好!我来自南京,在OpenHarmony成长计划啃论文俱乐部,与华为、软通动力、润和软件、拓维信息、深开鸿等公司一起,学习和研究操作系统技术
    从今年1月11日加入OpenHarmony俱乐部已经有接近8个月时间了。笔者一直在思考啃论文给我带来了些什么,通过啃论文能为OpenHarmony做些什么。笔者利用大二升大三暑假两个月时间移植了Speexdsp这个三方库到OpenHarmony标准系统,而关于前面的问题我似乎找到了答案,现将啃论文和三方库移植分享经验如下:

由于想要分享的内容较多,为避免读者姥爷们失去看下去的耐心,分享将以连载的方式进行。
下期预告:移植Speedsp到OHOS——VoIP语音质量适配应用层机制研究综述

往期回顾
啃论文俱乐部——移植speexdsp到OpenHarmony标准系统①
啃论文俱乐部——移植speexdsp到OpenHarmony标准系统②
啃论文俱乐部——移植speexdsp到OpenHarmony标准系统③
啃论文俱乐部——移植speexdsp到OpenHarmony标准系统④
啃论文俱乐部——移植speexdsp到OpenHarmony标准系统⑤

本期为移植speexdsp到OpenHarmony标准系统的第⑥期,主要内容如下:

@toc

啃论文俱乐部——移植speexdsp到OpenHarmony标准系统⑥-鸿蒙开发者社区


speexdsp移植后已提交至openhamrony sig仓库https://gitee.com/openharmony-sig/contest/tree/master/2022_OpenHarmony_thirdparty/speexdsp


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

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

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

啃论文俱乐部——移植speexdsp到OpenHarmony标准系统⑥-鸿蒙开发者社区

上传的内容包括:

  • 原生库代码
    • (除了涉及需要修改原生库代码的部分,其他都不能上传,例如编译途中生成的中间文件)
  • 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完成构建。

啃论文俱乐部——移植speexdsp到OpenHarmony标准系统⑥-鸿蒙开发者社区

  • 编译构建成功

啃论文俱乐部——移植speexdsp到OpenHarmony标准系统⑥-鸿蒙开发者社区

在父目录下添加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到OpenHarmony标准系统⑥-鸿蒙开发者社区

同时在speexdsp父目录下生成log文件夹
啃论文俱乐部——移植speexdsp到OpenHarmony标准系统⑥-鸿蒙开发者社区

  • 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该仓库:

啃论文俱乐部——移植speexdsp到OpenHarmony标准系统⑥-鸿蒙开发者社区

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

啃论文俱乐部——移植speexdsp到OpenHarmony标准系统⑥-鸿蒙开发者社区
执行如下语句:

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查看所有的分支。

进入自己的账号下面,查看这个仓库,发现已经发生了变化。从个人账号仓库下向官方仓库下提交PR。
啃论文俱乐部——移植speexdsp到OpenHarmony标准系统⑥-鸿蒙开发者社区
进入个人账号的该仓库下,点击增加PR即可开始提交PR。

啃论文俱乐部——移植speexdsp到OpenHarmony标准系统⑥-鸿蒙开发者社区

提交pr时,push的文件超过100个文件,在pr页面只显示100个。
啃论文俱乐部——移植speexdsp到OpenHarmony标准系统⑥-鸿蒙开发者社区

下期预告:移植Speedsp到OHOS——VoIP语音质量适配应用层机制研究综述

©著作权归作者所有,如需转载,请注明出处,否则将追究法律责任
已于2022-10-14 11:08:54修改
7
收藏 3
回复
举报
5条回复
按时间正序
/
按时间倒序
红叶亦知秋
红叶亦知秋

佩服楼主源源不断的创作动力

已于2022-9-13 10:09:48修改
1
回复
2022-9-13 10:06:47
离北况归
离北况归 回复了 红叶亦知秋
佩服楼主源源不断的创作动力

把自己了解的东西分享出来,为了吸引更多开发者。

1
回复
2022-9-13 12:24:58
红叶亦知秋
红叶亦知秋 回复了 离北况归
把自己了解的东西分享出来,为了吸引更多开发者。

必须为楼主点赞

回复
2022-9-13 16:24:31
有故事的王同学
有故事的王同学

sig仓平移到tpc仓只要等一段时间就可以了吗?

回复
2022-9-14 14:55:38
离北况归
离北况归 回复了 有故事的王同学
sig仓平移到tpc仓只要等一段时间就可以了吗?

这个工作由ohos官方的人完成,可以这么理解

回复
2022-9-14 15:22:11
回复
    相关推荐