OpenHarmony BUILD.gn中执行脚本

离北况归
发布于 2025-7-23 16:21
浏览
0收藏

在OpenHarmony编译构建中笔者经常遇到这样的场景——需要执行sh脚本完成某些操作。笔者将OpenHarmony BUILD.gn中执行脚本的方法分享如下:

前置知识点

1.能够把自定义的子系统加入OpenHarmony源码的编译构建,请参考:https://ost.51cto.com/posts/17750中关于自定义子系统的部分

开发环境

  • OpenHarmony源码5.0.0版本

步骤

1.首先新建一个BUILD.gn

import("//build/ohos.gni")

exec_script("install.sh")

# 脚本如果需要参数则写成
# path= rebase_path("//xxx/xxx/xxxx/libomxil_bellagio")
# exec_script("install.sh", [ "$path" ])

config("public_config") {
....
}

ohos_static_library("omxbase") {
....
}

2.添加脚本执行权限,在5.0.0/build/core/gn/ohos_exec_script_allowlist.gni中加入该BUILD.gn的路径即可

具体实现可以参考
https://gitee.com/openharmony/third_party_libnl

已于2025-7-23 16:21:37修改
收藏
回复
举报
回复
    相关推荐