Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
f539434c
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f539434c
编写于
7月 05, 2022
作者:
A
Austin
提交者:
Gitee
7月 05, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update zh-cn/device-dev/porting/porting-thirdparty-cmake.md.
Signed-off-by:
N
Austin23
<
liaozhiqi7@huawei.com
>
上级
882d64ac
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
107 addition
and
107 deletion
+107
-107
zh-cn/device-dev/porting/porting-thirdparty-cmake.md
zh-cn/device-dev/porting/porting-thirdparty-cmake.md
+107
-107
未找到文件。
zh-cn/device-dev/porting/porting-thirdparty-cmake.md
浏览文件 @
f539434c
...
@@ -123,52 +123,52 @@ CMake方式可通过指定工具链进行交叉编译,修改并编译该库,
...
@@ -123,52 +123,52 @@ CMake方式可通过指定工具链进行交叉编译,修改并编译该库,
-
挂载成功后执行下列命令可列出用例所有条目:
-
挂载成功后执行下列命令可列出用例所有条目:
```
```
cd nfs
cd nfs
./cctest --list
./cctest --list
```
```
上述命令执行结果部分展示:
上述命令执行结果部分展示:
```
```
test-bignum/Assign<
test-bignum/Assign<
test-bignum/ShiftLeft<
test-bignum/ShiftLeft<
test-bignum/AddUInt64<
test-bignum/AddUInt64<
test-bignum/AddBignum<
test-bignum/AddBignum<
test-bignum/SubtractBignum<
test-bignum/SubtractBignum<
test-bignum/MultiplyUInt32<
test-bignum/MultiplyUInt32<
test-bignum/MultiplyUInt64<
test-bignum/MultiplyUInt64<
test-bignum/MultiplyPowerOfTen<
test-bignum/MultiplyPowerOfTen<
test-bignum/DivideModuloIntBignum<
test-bignum/DivideModuloIntBignum<
test-bignum/Compare<
test-bignum/Compare<
test-bignum/PlusCompare<
test-bignum/PlusCompare<
test-bignum/Square<
test-bignum/Square<
test-bignum/AssignPowerUInt16<
test-bignum/AssignPowerUInt16<
test-bignum-dtoa/BignumDtoaVariousDoubles<
test-bignum-dtoa/BignumDtoaVariousDoubles<
test-bignum-dtoa/BignumDtoaShortestVariousFloats<
test-bignum-dtoa/BignumDtoaShortestVariousFloats<
test-bignum-dtoa/BignumDtoaGayShortest<
test-bignum-dtoa/BignumDtoaGayShortest<
test-bignum-dtoa/BignumDtoaGayShortestSingle<
test-bignum-dtoa/BignumDtoaGayShortestSingle<
test-bignum-dtoa/BignumDtoaGayFixed<
test-bignum-dtoa/BignumDtoaGayFixed<
test-bignum-dtoa/BignumDtoaGayPrecision<
test-bignum-dtoa/BignumDtoaGayPrecision<
test-conversions/DoubleToShortest<
test-conversions/DoubleToShortest<
test-conversions/DoubleToShortestSingle<
test-conversions/DoubleToShortestSingle<
...
...
```
```
-
以test-bignum条目为例,执行下列命令开始测试:
-
以test-bignum条目为例,执行下列命令开始测试:
```
```
./cctest test-bignum
./cctest test-bignum
```
```
测试结果如下则表示通过:
测试结果如下则表示通过:
```
```
Ran 13 tests.
Ran 13 tests.
```
```
## 将该库编译添加到OpenHarmony工程中
## 将该库编译添加到OpenHarmony工程中
...
@@ -189,103 +189,103 @@ CMake方式可通过指定工具链进行交叉编译,修改并编译该库,
...
@@ -189,103 +189,103 @@ CMake方式可通过指定工具链进行交叉编译,修改并编译该库,
-
**新增的BUILD.gn文件实现如下,其他采用CMake方式可独立编译的三方库移植到OpenHarmony平台时只需修改路径即可**
。
-
**新增的BUILD.gn文件实现如下,其他采用CMake方式可独立编译的三方库移植到OpenHarmony平台时只需修改路径即可**
。
```
```
import("config.gni")
import("config.gni")
group("double-conversion") {
group("double-conversion") {
if (ohos_build_thirdparty_migrated_from_fuchisa == true) {
if (ohos_build_thirdparty_migrated_from_fuchisa == true) {
deps = [":make"]
deps = [":make"]
}
}
}
}
if (ohos_build_thirdparty_migrated_from_fuchisa == true) {
if (ohos_build_thirdparty_migrated_from_fuchisa == true) {
action("make") {
action("make") {
script = "//third_party/double-conversion/build_thirdparty.py"
script = "//third_party/double-conversion/build_thirdparty.py"
outputs = ["$root_out_dir/log_dc.txt"]
outputs = ["$root_out_dir/log_dc.txt"]
exec_path = rebase_path(rebase_path("./build", ohos_third_party_dir))
exec_path = rebase_path(rebase_path("./build", ohos_third_party_dir))
command = "rm * .* -rf && $CMAKE_TOOLS_PATH/cmake .. $CMAKE_FLAG $CMAKE_TOOLCHAIN_FLAG && make -j"
command = "rm * .* -rf && $CMAKE_TOOLS_PATH/cmake .. $CMAKE_FLAG $CMAKE_TOOLCHAIN_FLAG && make -j"
args = [
args = [
"--path=$exec_path",
"--path=$exec_path",
"--command=${command}"
"--command=${command}"
]
]
}
}
}
}
```
```
-
**新增的config.gni用于配置该库,实现如下,其他采用CMake方式可独立编译的三方库移植到OpenHarmony时只需修改CMAKE_FLAG的配置即可。**
-
**新增的config.gni用于配置该库,实现如下,其他采用CMake方式可独立编译的三方库移植到OpenHarmony时只需修改CMAKE_FLAG的配置即可。**
```
```
#CMAKE_FLAG: config compile feature
#CMAKE_FLAG: config compile feature
CMAKE_FLAG = "-DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=11"
CMAKE_FLAG = "-DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=11"
#toolchain:follow up-layer,depend on $ohos_build_compiler
#toolchain:follow up-layer,depend on $ohos_build_compiler
if (ohos_build_compiler == "clang") {
if (ohos_build_compiler == "clang") {
CMAKE_TOOLCHAIN_FLAG = "-DOHOS_SYSROOT_PATH=${ohos_root_path}prebuilts/lite/sysroot/"
CMAKE_TOOLCHAIN_FLAG = "-DOHOS_SYSROOT_PATH=${ohos_root_path}prebuilts/lite/sysroot/"
} else {
} else {
CMAKE_TOOLCHAIN_FLAG = ""
CMAKE_TOOLCHAIN_FLAG = ""
}
}
#CMake tools path,no need setting if this path already joined to $PATH.
#CMake tools path,no need setting if this path already joined to $PATH.
CMAKE_TOOLS_PATH = "setting CMake tools path..."
CMAKE_TOOLS_PATH = "setting CMake tools path..."
```
```
- **新增的build_thirdparty.py实现如下,其他采用CMake方式可独立编译的三方库移植到OpenHarmony时无需修改即可使用。**
- **新增的build_thirdparty.py实现如下,其他采用CMake方式可独立编译的三方库移植到OpenHarmony时无需修改即可使用。**
```
```
import os
import os
import sys
import sys
from subprocess import Popen
from subprocess import Popen
import argparse
import argparse
import shlex
import shlex
def cmd_exec(command):
def cmd_exec(command):
cmd = shlex.split(command)
cmd = shlex.split(command)
proc = Popen(cmd)
proc = Popen(cmd)
proc.wait()
proc.wait()
ret_code = proc.returncode
ret_code = proc.returncode
if ret_code != 0:
if ret_code != 0:
raise Exception("{} failed, return code is {}".format(cmd, ret_code))
raise Exception("{} failed, return code is {}".format(cmd, ret_code))
def main():
def main():
parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser()
parser.add_argument('--path', help='Build path.')
parser.add_argument('--path', help='Build path.')
parser.add_argument('--command', help='Build command.')
parser.add_argument('--command', help='Build command.')
parser.add_argument('--enable', help='enable python.', nargs='*')
parser.add_argument('--enable', help='enable python.', nargs='
*
')
args = parser.parse_args()
args = parser.parse_args()
if args.enable:
if args.enable:
if args.enable[0] == 'false':
if args.enable[0] == 'false':
return
return
if args.path:
if args.path:
curr_dir = os.getcwd()
curr_dir = os.getcwd()
os.chdir(args.path)
os.chdir(args.path)
if args.command:
if args.command:
if '&&' in args.command:
if '&&' in args.command:
command = args.command.split('&&')
command = args.command.split('&&')
for data in command:
for data in command:
cmd_exec(data)
cmd_exec(data)
else:
else:
cmd_exec(args.command)
cmd_exec(args.command)
os.chdir(curr_dir)
os.chdir(curr_dir)
if __name__ == '__main__':
if __name__ == '__main__':
sys.exit(main())
sys.exit(main())
```
```
- 在配置文件中添加开关控制该库编译,默认设为关闭
- 在配置文件中添加开关控制该库编译,默认设为关闭
在//build/lite/ohos_var.gni文件中添加下列配置:
在//build/lite/ohos_var.gni文件中添加下列配置:
```
```
declare_args() {
declare_args() {
ohos_build_thirdparty_migrated_from_fuchisa = true
ohos_build_thirdparty_migrated_from_fuchisa = true
}
}
```
```
3. 编译构建
3. 编译构建
-
手动单独构建:
手动单独构建:
执行下列命令
执行下列命令
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录