在OpenHarmony开发中,偶尔会遇到创建符号链接的需求,例如https://gitee.com/OpenHarmony_rk_equipment_transplantation/nodejs_OpenHarmony/tree/6.0r 中,需要将/system/bin/npm链接到/system/lib64/node_modules/npm/bin/npm-cli.js文件。

image.png

可以在BUILD.gn中使用symlink_path属性,声明需要链接的文件。

ohos_prebuilt_executable("npm") {
  source = "nodejs_22_19_0_oh_6_0_r_arm64-v8a/bin/npm"
  install_images = [
      "system",
  ]
  subsystem_name = "nodejs_oh"
  part_name = "nodejs"
  install_enable = true
  symlink_path = "/system/lib64/node_modules/npm/bin/npm-cli.js"
}

注意:还需要在b/build/ohos/images/mkimage/dac.txt中添加/system/lib64/node_modules/npm/bin/npm-cli.js的权限

image.png

Logo

社区规范:仅讨论OpenHarmony相关问题。

更多推荐