• 大家好!我来自南京,在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语音品质适配应用层机制钻研综述