移植BehaviorTree.CPP到OpenHarmony標準系統(tǒng)之一
作者:離北況歸 
  本篇將分享兩種移植方式,為 BehaviorTree.CPP 編寫B(tài)UILD.gn 進行Rom集成,移植后編譯出來的so和可執(zhí)行文件打包進入固件的方法,移植相關的文件ohos.build修改為bundle.json,ohos.build不再使用。
 
1、為BehaviorTree.CPP編寫B(tài)UILD.gn進行Rom集成
- Rom集成筆者開發(fā)環(huán)境:
 
- wsl2+ubuntu18.04
 - OpenHarmony 3.2 release 源碼
 - 潤和大禹200開發(fā)板
 
2、修改build/subsystem_config.json,新增子系統(tǒng)behaviortree定義
在源碼/build/subsystem_config.json中增加子系統(tǒng)behaviortree。
"behaviortree": {
    "path": "third_party/behaviortree",
    "name": "behaviortree"
  }3、修改vendor/hihope/rk3568/config.json文件將behaviortree添加至rk3568開發(fā)板
{
      "subsystem": "behaviortree",
      "components": [
        {
          "component": "behaviortree",
          "features": []
        }
      ]
    }4、在OpenHarmony標準系統(tǒng)源碼下third_party下放置BehaviorTree.CPP源碼
- BehaviorTree.CPP 源碼版本為4.1.1 :https://github.com/BehaviorTree/BehaviorTree.CPP/tree/4.1.1。
 - 并且文件夾名稱修改為behaviortree。
 
5、third_party/behaviortree目錄下添加bundle.json文件
- 特別說明:ohos.build不再使用,OpenHarmony源碼中全部使用bundle.json。
 - bundle.json文件:
 
{
  "name": "@ohos/behaviortree",
  "description": "",
  "version": "",
  "license": "",
  "publishAs": "",
  "segment": {
      "destPath": "third_party/behaviortree"
  },
  "dirs": {},
  "scripts": {},
  "readmePath": {
  },
  "component": {
      "name": "behaviortree",
      "subsystem": "behaviortree",
      "syscap": [],
      "features": [],
      "adapted_system_type": [],
      "rom": "",
      "ram": "",
      "deps": {
          "components": [],
          "third_party": []
      },
      "build": {
          "sub_component": [
            "http://third_party/behaviortree:lexy_file",
            "http://third_party/behaviortree:bt_sample_nodes",
            "http://third_party/behaviortree:behaviortree_cpp",
            "http://third_party/behaviortree:dummy_nodes_dyn",
            "http://third_party/behaviortree:crossdoor_nodes_dyn",
            "http://third_party/behaviortree:movebase_node_dyn",
            "http://third_party/behaviortree:t01_build_your_first_tree",
            "http://third_party/behaviortree:t02_basic_ports",
            "http://third_party/behaviortree:t03_generic_ports",
            "http://third_party/behaviortree:t05_crossdoor",
            "http://third_party/behaviortree:t04_reactive_sequence",
            "http://third_party/behaviortree:t06_subtree_port_remapping",
            "http://third_party/behaviortree:t07_load_multiple_xml",
            "http://third_party/behaviortree:t08_additional_node_args",
            "http://third_party/behaviortree:t09_scripting",
            "http://third_party/behaviortree:t10_observer",
            "http://third_party/behaviortree:t11_replace_rules",
            "http://third_party/behaviortree:ex01_wrap_legacy",
            "http://third_party/behaviortree:ex02_runtime_ports",
            "http://third_party/behaviortree:ex03_ncurses_manual_selector",
            "http://third_party/behaviortree:ex04_waypoints"
          ],
          "inner_kits": [],
          "test": []
      }
  }
}6、BehaviorTree.CPP編譯gn化,在third_party/behaviortree下添加BUILD.gn腳本文件
- third_party/behaviortree/BUILD.gn配置的模塊有
 
- so
 
- libbehaviortree_cpp.z.so
 - libmovebase_node_dyn.z.so
 - libcrossdoor_nodes_dyn.z.so
 - libdummy_nodes_dyn.z.so
 
- .a
 
- liblexy_file.a
 - libbt_sample_nodes.a
 
- 可執(zhí)行文件
 
- t01_build_your_first_tree
 - t02_basic_ports
 - t03_generic_ports
 - t04_reactive_sequence
 - t05_crossdoor
 - t06_subtree_port_remapping
 - t07_load_multiple_xml
 - t08_additional_node_args
 - t09_scripting
 - t10_observer
 - t11_replace_rules
 - ex01_wrap_legacy
 - ex02_runtime_ports
 - ex03_ncurses_manual_selector
 - ex04_waypoints
 
- 模塊之間的依賴關系
 
- libbehaviortree_cpp.z.so依賴lexy_file.a
 - libcrossdoor_nodes_dyn.z.so依賴libbehaviortree_cpp.z.so
 - libmovebase_node_dyn.z.so依賴libbehaviortree_cpp.z.so
 - 所有的可執(zhí)行文件都依賴libbt_sample_nodes.a和libbehaviortree_cpp.z.so
 
- third_party/behaviortree/BUILD.gn文件如下:
 
import("http://build/ohos.gni")  
##############################################################################
# 公共配置
config("public_config"){
    ldflags = [
       #"-lstdc++",
       #用-lc++替代-lstdc++
       "-lc++",
       "-Wl",
       "-lm",
       "-lc",
       "-lpthread",
    ]
}
##############################################################################
# liblexy_file.a
config("lexy_file_config"){
    #cflags_cc是用來存儲專門針對 C++ 語言編譯器的選項,只會被 C++ 編譯器使用。
    cflags_cc = [
       "-O3",
       "-DNDEBUG",  
       "-Wpedantic", 
       "-pedantic-errors", 
       "-Werror", 
       "-Wall", 
       "-Wextra", 
       "-Wconversion", 
       "-Wsign-conversion", 
       "-Wno-parentheses", 
       "-Wno-unused-local-typedefs", 
       "-Wno-array-bounds", 
       "-Wno-maybe-uninitialized", 
       "-Wno-restrict", 
       "-std=gnu++20",
    ]
}
ohos_static_library("lexy_file") {
    output_name = "lexy_file" # 可選,模塊輸出名
    sources = [
         "http://third_party/behaviortree/3rdparty/lexy/src/input/file.cpp",
    ]
    defines = [
    ]
    configs = [ 
         ":lexy_file_config", 
         ":public_config",
    ] 
    include_dirs = [
         "3rdparty/lexy/include",
    ]
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# libbt_sample_nodes.a
config("bt_sample_nodes_config"){
    #cflags_cc是用來存儲專門針對 C++ 語言編譯器的選項,只會被 C++ 編譯器使用。
     cflags_cc = [
        "-O3", 
        "-DNDEBUG",    
        "-Wpedantic",   
        "-std=gnu++17",
        # 為了消除編譯報錯添加的
        "-fexceptions",
        "-frtti",
        "-Wno-unused-function",
     ]
}
ohos_static_library("bt_sample_nodes") {
    sources = [
        "sample_nodes/crossdoor_nodes.cpp",
        "sample_nodes/dummy_nodes.cpp",
        "sample_nodes/movebase_node.cpp",
    ]
    defines = [
    ]
    configs = [ 
         ":bt_sample_nodes_config", 
         ":public_config",
    ] 
    include_dirs = [
         "include",
         "sample_nodes"
    ]
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# libbehaviortree_cpp.so
config("behaviortreecpp_config"){
    cflags_cc = [
        # 為了編譯libbehaviortree_cpp.so原生庫中添加的編譯器標志
        "-O3", 
        "-DNDEBUG",  
        "-fPIC",    
        "-Wpedantic",  
        "-Wall",  
        "-Wextra",  
        "-std=gnu++20",
        # 為了消除shared_library.cpp編譯報錯添加-fexceptions
        "-fexceptions",
        "-frtti",
        "-Wno-deprecated-volatile",
        "-Wno-unused-lambda-capture",
    ]
    include_dirs = [
         ".",
         "include",
         "3rdparty",
         "3rdparty/lexy/include",
    ]
}
ohos_shared_library("behaviortree_cpp") {
    output_name = "behaviortree_cpp" # 可選,模塊輸出名
    sources = [
        "src/action_node.cpp",
        "src/basic_types.cpp",
        "src/behavior_tree.cpp",
        "src/blackboard.cpp",
        "src/bt_factory.cpp",
        "src/decorator_node.cpp",
        "src/condition_node.cpp",
        "src/control_node.cpp",
        "src/shared_library.cpp",
        "src/tree_node.cpp",
        "src/script_parser.cpp",
        "src/json_export.cpp",
        "src/xml_parsing.cpp",
        "src/actions/test_node.cpp",
        "src/decorators/inverter_node.cpp",
        "src/decorators/repeat_node.cpp",
        "src/decorators/retry_node.cpp",
        "src/decorators/subtree_node.cpp",
        "src/decorators/delay_node.cpp",
        "src/controls/if_then_else_node.cpp",
        "src/controls/fallback_node.cpp",
        "src/controls/parallel_node.cpp",
        "src/controls/reactive_sequence.cpp",
        "src/controls/reactive_fallback.cpp",
        "src/controls/sequence_node.cpp",
        "src/controls/sequence_star_node.cpp",
        "src/controls/switch_node.cpp",
        "src/controls/while_do_else_node.cpp",
        "src/loggers/bt_cout_logger.cpp",
        "src/loggers/bt_file_logger.cpp",
        "src/loggers/bt_minitrace_logger.cpp",
        "src/loggers/bt_observer.cpp",
        "3rdparty/tinyxml2/tinyxml2.cpp",
        "3rdparty/minitrace/minitrace.cpp",
        "src/shared_library_UNIX.cpp",
    ]
    defines = [
        "LEXY_HAS_UNICODE_DATABASE=1",
        "behaviortree_cpp_EXPORTS",
    ]
    configs = [ 
         ":behaviortreecpp_config", 
         ":public_config",
    ] 
    deps = [
         "http://third_party/behaviortree:lexy_file",
    ]
    
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# libdummy_nodes_dyn.so
config("dummy_nodes_dyn_config"){
    cflags_cc = [
        # 為了編譯libbehaviortree_cpp.so原生庫中添加的編譯器標志
        "-O3", 
        "-DNDEBUG",  
        "-fPIC",    
        "-Wpedantic",   
        "-std=gnu++17",
        # 為了消除shared_library.cpp編譯報錯添加-fexceptions
        "-fexceptions",
        "-frtti",
        "-Wno-deprecated-volatile",
        "-Wno-unused-lambda-capture",
    ]
    include_dirs = [
         "include",
         "sample_nodes"
    ]
}
ohos_shared_library("dummy_nodes_dyn") {
    
    output_name = "dummy_nodes_dyn" # 可選,模塊輸出名
    sources = [
        "sample_nodes/dummy_nodes.cpp",
    ]
    defines = [
        "BT_PLUGIN_EXPORT",
        "dummy_nodes_dyn_EXPORTS",
    ]
    configs = [ 
         ":dummy_nodes_dyn_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
    ]
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# libcrossdoor_nodes_dyn.so
config("crossdoor_nodes_dyn_config"){
    cflags_cc = [
        # 為了編譯libbehaviortree_cpp.so原生庫中添加的編譯器標志
        "-O3", 
        "-DNDEBUG",  
        "-fPIC",    
        "-Wpedantic",   
        "-std=gnu++17",
        # 為了消除shared_library.cpp編譯報錯添加-fexceptions
        "-fexceptions",
        "-frtti",
        "-Wno-deprecated-volatile",
        "-Wno-unused-lambda-capture",
    ]
    include_dirs = [
         "include",
         "sample_nodes"
    ]
}
ohos_shared_library("crossdoor_nodes_dyn") {
    
    output_name = "crossdoor_nodes_dyn" # 可選,模塊輸出名
    sources = [
        "sample_nodes/crossdoor_nodes.cpp",
    ]
    defines = [
        "BT_PLUGIN_EXPORT",
        "crossdoor_nodes_dyn_EXPORTS",
    ]
    configs = [ 
         ":crossdoor_nodes_dyn_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
    ]
    
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# libmovebase_node_dyn.so
config("movebase_node_dyn_config"){
    cflags_cc = [
        # 為了編譯libbehaviortree_cpp.so原生庫中添加的編譯器標志
        "-O3", 
        "-DNDEBUG",  
        "-fPIC",    
        "-Wpedantic",   
        "-std=gnu++17",
        # 為了消除shared_library.cpp編譯報錯添加-fexceptions
        "-fexceptions",
        "-frtti",
        "-Wno-deprecated-volatile",
        "-Wno-unused-lambda-capture",
    ]
    include_dirs = [
         "include",
         "sample_nodes"
    ]
}
ohos_shared_library("movebase_node_dyn") {
    
    output_name = "movebase_node_dyn" # 可選,模塊輸出名
    sources = [
        "sample_nodes/movebase_node.cpp",
    ]
    defines = [
        "BT_PLUGIN_EXPORT",
        "movebase_node_dyn_EXPORTS",
    ]
    configs = [ 
         ":movebase_node_dyn_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
    ]
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# t01_build_your_first_tree
config("executable_public_config"){
    cflags_cc = [
        # 為了編譯libbehaviortree_cpp.so原生庫中添加的編譯器標志
        "-O3", 
        "-DNDEBUG",   
        "-Wpedantic",   
        "-std=gnu++17",
        # 為了消除shared_library.cpp編譯報錯添加-fexceptions
        "-fexceptions",
        "-frtti",
        "-Wno-deprecated-volatile",
        "-Wno-unused-lambda-capture",
    ]
    include_dirs = [
         "include",
         "sample_nodes"
    ]
}
ohos_executable("t01_build_your_first_tree") {
    
    output_name = "t01_build_your_first_tree" # 可選,模塊輸出名
    sources = [
        "examples/t01_build_your_first_tree.cpp",
    ]
    configs = [ 
         ":executable_public_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
        "http://third_party/behaviortree:bt_sample_nodes",
    ]
    
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# t02_basic_ports
ohos_executable("t02_basic_ports") {
    
    output_name = "t02_basic_ports" # 可選,模塊輸出名
    sources = [
        "examples/t02_basic_ports.cpp",
    ]
    configs = [ 
         ":executable_public_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
        "http://third_party/behaviortree:bt_sample_nodes",
    ]
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# t03_generic_ports
ohos_executable("t03_generic_ports") {
    
    output_name = "t03_generic_ports" # 可選,模塊輸出名
    sources = [
        "examples/t03_generic_ports.cpp",
    ]
    configs = [ 
         ":executable_public_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
        "http://third_party/behaviortree:bt_sample_nodes",
    ]
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# t04_reactive_sequence
ohos_executable("t04_reactive_sequence") {
    
    output_name = "t04_reactive_sequence" # 可選,模塊輸出名
    sources = [
        "examples/t04_reactive_sequence.cpp",
    ]
    configs = [ 
         ":executable_public_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
        "http://third_party/behaviortree:bt_sample_nodes",
    ]
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# t05_crossdoor
ohos_executable("t05_crossdoor") {
    
    output_name = "t05_crossdoor" # 可選,模塊輸出名
    sources = [
        "examples/t05_crossdoor.cpp",
    ]
    configs = [ 
         ":executable_public_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
        "http://third_party/behaviortree:bt_sample_nodes",
    ]
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# t06_subtree_port_remapping
ohos_executable("t06_subtree_port_remapping") {
    
    output_name = "t06_subtree_port_remapping" # 可選,模塊輸出名
    sources = [
        "examples/t06_subtree_port_remapping.cpp",
    ]
    configs = [ 
         ":executable_public_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
        "http://third_party/behaviortree:bt_sample_nodes",
    ]
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# t07_load_multiple_xml
ohos_executable("t07_load_multiple_xml") {
    
    output_name = "t07_load_multiple_xml" # 可選,模塊輸出名
    sources = [
        "examples/t07_load_multiple_xml.cpp",
    ]
    configs = [ 
         ":executable_public_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
        "http://third_party/behaviortree:bt_sample_nodes",
    ]
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# t08_additional_node_args
ohos_executable("t08_additional_node_args") {
    
    output_name = "t08_additional_node_args" # 可選,模塊輸出名
    sources = [
        "examples/t08_additional_node_args.cpp",
    ]
    configs = [ 
         ":executable_public_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
        "http://third_party/behaviortree:bt_sample_nodes",
    ]
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# t09_scripting
ohos_executable("t09_scripting") {
    
    output_name = "t09_scripting" # 可選,模塊輸出名
    sources = [
        "examples/t09_scripting.cpp",
    ]
    configs = [ 
         ":executable_public_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
        "http://third_party/behaviortree:bt_sample_nodes",
    ]
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# t10_observer
config("t10_observer_config"){
    cflags_cc = [
        # 為了編譯libbehaviortree_cpp.so原生庫中添加的編譯器標志
        "-O3", 
        "-DNDEBUG",   
        "-Wpedantic",   
        "-std=gnu++17",
        # 為了消除shared_library.cpp編譯報錯添加-fexceptions
        "-fexceptions",
        "-frtti",
        "-Wno-deprecated-volatile",
        "-Wno-unused-lambda-capture",
        "-Wno-unused-variable",
    ]
    include_dirs = [
         "include",
         "sample_nodes"
    ]
}
ohos_executable("t10_observer") {
    
    output_name = "t10_observer" # 可選,模塊輸出名
    sources = [
        "examples/t10_observer.cpp",
    ]
    configs = [ 
         ":t10_observer_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
        "http://third_party/behaviortree:bt_sample_nodes",
    ]
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# t11_replace_rules
ohos_executable("t11_replace_rules") {
    
    output_name = "t11_replace_rules" # 可選,模塊輸出名
    sources = [
        "examples/t11_replace_rules.cpp",
    ]
    configs = [ 
         ":executable_public_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
        "http://third_party/behaviortree:bt_sample_nodes",
    ]
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# ex01_wrap_legacy
ohos_executable("ex01_wrap_legacy") {
    
    output_name = "ex01_wrap_legacy" # 可選,模塊輸出名
    sources = [
        "examples/ex01_wrap_legacy.cpp",
    ]
    configs = [ 
         ":executable_public_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
        "http://third_party/behaviortree:bt_sample_nodes",
    ]
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# ex02_runtime_ports
ohos_executable("ex02_runtime_ports") {
    
    output_name = "ex02_runtime_ports" # 可選,模塊輸出名
    sources = [
        "examples/ex02_runtime_ports.cpp",
    ]
    configs = [ 
         ":executable_public_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
        "http://third_party/behaviortree:bt_sample_nodes",
    ]
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# ex03_ncurses_manual_selector
ohos_executable("ex03_ncurses_manual_selector") {
    
    output_name = "ex03_ncurses_manual_selector" # 可選,模塊輸出名
    sources = [
        "examples/ex03_ncurses_manual_selector.cpp",
    ]
    configs = [ 
         ":executable_public_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
        "http://third_party/behaviortree:bt_sample_nodes",
    ]
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################
# ex04_waypoints
ohos_executable("ex04_waypoints") {
    
    output_name = "ex04_waypoints" # 可選,模塊輸出名
    sources = [
        "examples/ex04_waypoints.cpp",
    ]
    configs = [ 
         ":executable_public_config", 
         ":public_config",
    ] 
    deps = [
        "http://third_party/behaviortree:behaviortree_cpp",
        "http://third_party/behaviortree:bt_sample_nodes",
    ]
    install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]
    
    part_name = "behaviortree"
    subsystem_name = "behaviortree"
}
##############################################################################7、對源碼進行增量編譯,推送編譯生成BehaviorTree.CPP的so以及可執(zhí)行文件到開發(fā)板上,驗證編譯結果
(1)對源碼進行增量編譯
- 推薦使用如下命令對對源碼進行增量編譯,編譯生成BehaviorTree.CPP的so以及可執(zhí)行文件
 
./build.sh --product-name rk3568 --ccache --build-target=behaviortree --disable-post-build --disable-package-image --gn-args enable_notice_collection=false --gn-args load_test_config=false- 默認編譯的是32位,添加–target-cpu arm64參數編譯64位
 
--product-name rk3568 :表示編譯的產品是rk3568 (潤和大禹200)
--build-target=behaviortree :編譯子系統(tǒng)behaviortree
以下這些都是加快編譯速度的選項
--ccache --build-target=behaviortree --disable-post-build --disable-package-image --gn-args enable_notice_collection=false --gn-args load_test_config=false(2)推送編譯生成BehaviorTree.CPP的so以及可執(zhí)行文件到開發(fā)板上,驗證編譯結果
so和可執(zhí)行文件在out\rk3568\behaviortree目錄下:

liblexy_file.a、libbt_sample_nodes.a等靜態(tài)庫文件在out\rk3568\obj\third_party\behaviortree目錄下。

1、通過與ohos版本匹配的hdc_std工具,將編譯生成的庫以及測試用的可執(zhí)行文件推送到開發(fā)板system/lib (lib64)
- 推送到開發(fā)板system/lib (lib64),是因為運行需要鏈接該目錄下的libc++.so
 - 注意,不再是用hdc_std,改成了hdc
 
hdc shell               
mount -o remount,rw /	    ## 重新加載系統(tǒng)為可讀寫
chmod 777 t02_basic_ports
./t02_basic_ports
8、對源碼進行增量編譯全量編譯,燒錄固件驗證編譯結果。
- 如果有將編譯生成BehaviorTree.CPP的so以及可執(zhí)行文件打包到固件,隨固件燒錄到開發(fā)板的需求。推薦進行全量編譯,執(zhí)行 ./build.sh --product-name rk3568 --ccache ,然后編譯燒錄固件到開發(fā)板上即可。
 - 編譯燒錄好固件到開發(fā)板后,so文件會在開發(fā)板system/lib(64位系統(tǒng)的話在system/lib64),可執(zhí)行文件會在system/bin。
 - hdc shell進入開發(fā)板后,在任意目錄層級下執(zhí)行可執(zhí)行文件都可以。
 

- 將編譯生成BehaviorTree.CPP的so以及可執(zhí)行文件打包到固件,在上文third_party/behaviortree/BUILD.gn中已經添加相關代碼。
 
install_enable = true
    
    install_images = [
         "system",
         "ramdisk",
         "updater",
    ]責任編輯:jianghua 
                    來源:
                    51CTO 開源基礎軟件社區(qū)
 














 
 
 














 
 
 
 