关于openharmony:啃论文俱乐部移植speexdsp到OpenHarmony标准系统⑥

184次阅读

共计 7637 个字符,预计需要花费 20 分钟才能阅读完成。

  • 大家好!我来自南京,在 OpenHarmony 成长打算啃论文俱乐部,与 华为、软通能源、润和软件、拓维信息、深开鸿 等公司一起,学习和钻研 操作系统技术
    从往年 1 月 11 日退出 OpenHarmony 俱乐部曾经有靠近 8 个月工夫了。笔者始终在思考啃论文给我带来了些什么,通过啃论文能为 OpenHarmony 做些什么。笔者利用大二升大三寒假两个月工夫移植了 Speexdsp 这个三方库到 OpenHarmony 规范零碎,而对于后面的问题我仿佛找到了答案,现将啃论文和三方库移植分享教训如下:

因为想要分享的内容较多,为防止读者姥爷们失去看上来的急躁,分享将以连载的形式进行。

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

本期为 移植 speexdsp 到 OpenHarmony 规范零碎 的第⑥期,次要内容如下:


speexdsp 移植后已提交至 openhamrony sig 仓库:https://gitee.com/openharmony…


九、筹备好上传 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…

工具应用

编译构建:

  • 在 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": "[email protected]",
        "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 "[email protected]"(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 是对此次提交行为进行备注.

推送本地批改到账号仓库

当初须要将本地仓库的批改内容推送到 gitee 上 fork 后的集体仓库,应用 git push 命令来实现这个动作。

git push origin master
  • origin 指的是本人的仓库对应的原始近程服务器地址;
  • master 标识的是想要提交的分支。
  • 能够应用 git remote - v 查看配置的近程服务器;
  • git branch - a 查看所有的分支。

进入本人的账号上面,查看这个仓库,发现曾经产生了变动。从集体账号仓库下向官网仓库下提交 PR。

进入集体账号的该仓库下,点击减少 PR 即可开始提交 PR。

提交 pr 时,push 的文件超过 100 个文件,在 pr 页面只显示 100个。

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

正文完
 0