想了解更多关于开源的准系内容,请访问:
51CTO 开源基础软件社区
https://ost.51cto.com
在源码/build/subsystem_config.json中增加子系统behaviortree。准系
"behaviortree": { "path": "third_party/behaviortree",移植 "name": "behaviortree" }
{ "subsystem": "behaviortree",准系 "components": [ { "component": "behaviortree", "features": [] } ] }
{ "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": [ "//third_party/behaviortree:lexy_file", "//third_party/behaviortree:bt_sample_nodes", "//third_party/behaviortree:behaviortree_cpp", "//third_party/behaviortree:dummy_nodes_dyn", "//third_party/behaviortree:crossdoor_nodes_dyn", "//third_party/behaviortree:movebase_node_dyn", "//third_party/behaviortree:t01_build_your_first_tree", "//third_party/behaviortree:t02_basic_ports", "//third_party/behaviortree:t03_generic_ports", "//third_party/behaviortree:t05_crossdoor", "//third_party/behaviortree:t04_reactive_sequence", "//third_party/behaviortree:t06_subtree_port_remapping", "//third_party/behaviortree:t07_load_multiple_xml", "//third_party/behaviortree:t08_additional_node_args", "//third_party/behaviortree:t09_scripting", "//third_party/behaviortree:t10_observer", "//third_party/behaviortree:t11_replace_rules", "//third_party/behaviortree:ex01_wrap_legacy", "//third_party/behaviortree:ex02_runtime_ports", "//third_party/behaviortree:ex03_ncurses_manual_selector", "//third_party/behaviortree:ex04_waypoints" ], "inner_kits": [], "test": [] } }}
import("//build/ohos.gni") ############################################################################### 公共配置config("public_config"){ ldflags = [ #"-lstdc++", #用-lc++替代-lstdc++ "-lc++", "-Wl", "-lm", "-lc", "-lpthread", ]}############################################################################### liblexy_file.aconfig("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 = [ "//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.aconfig("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.soconfig("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 = [ "//third_party/behaviortree:lexy_file", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### libdummy_nodes_dyn.soconfig("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 = [ "//third_party/behaviortree:behaviortree_cpp", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### libcrossdoor_nodes_dyn.soconfig("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 = [ "//third_party/behaviortree:behaviortree_cpp", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### libmovebase_node_dyn.soconfig("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 = [ "//third_party/behaviortree:behaviortree_cpp", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### t01_build_your_first_treeconfig("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 = [ "//third_party/behaviortree:behaviortree_cpp", "//third_party/behaviortree:bt_sample_nodes", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### t02_basic_portsohos_executable("t02_basic_ports") { output_name = "t02_basic_ports" # 可选,模块输出名 sources = [ "examples/t02_basic_ports.cpp", ] configs = [ ":executable_public_config", ":public_config", ] deps = [ "//third_party/behaviortree:behaviortree_cpp", "//third_party/behaviortree:bt_sample_nodes", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### t03_generic_portsohos_executable("t03_generic_ports") { output_name = "t03_generic_ports" # 可选,模块输出名 sources = [ "examples/t03_generic_ports.cpp", ] configs = [ ":executable_public_config", ":public_config", ] deps = [ "//third_party/behaviortree:behaviortree_cpp", "//third_party/behaviortree:bt_sample_nodes", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### t04_reactive_sequenceohos_executable("t04_reactive_sequence") { output_name = "t04_reactive_sequence" # 可选,模块输出名 sources = [ "examples/t04_reactive_sequence.cpp", ] configs = [ ":executable_public_config", ":public_config", ] deps = [ "//third_party/behaviortree:behaviortree_cpp", "//third_party/behaviortree:bt_sample_nodes", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### t05_crossdoorohos_executable("t05_crossdoor") { output_name = "t05_crossdoor" # 可选,模块输出名 sources = [ "examples/t05_crossdoor.cpp", ] configs = [ ":executable_public_config", ":public_config", ] deps = [ "//third_party/behaviortree:behaviortree_cpp", "//third_party/behaviortree:bt_sample_nodes", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### t06_subtree_port_remappingohos_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 = [ "//third_party/behaviortree:behaviortree_cpp", "//third_party/behaviortree:bt_sample_nodes", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### t07_load_multiple_xmlohos_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 = [ "//third_party/behaviortree:behaviortree_cpp", "//third_party/behaviortree:bt_sample_nodes", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### t08_additional_node_argsohos_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 = [ "//third_party/behaviortree:behaviortree_cpp", "//third_party/behaviortree:bt_sample_nodes", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### t09_scriptingohos_executable("t09_scripting") { output_name = "t09_scripting" # 可选,模块输出名 sources = [ "examples/t09_scripting.cpp", ] configs = [ ":executable_public_config", ":public_config", ] deps = [ "//third_party/behaviortree:behaviortree_cpp", "//third_party/behaviortree:bt_sample_nodes", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### t10_observerconfig("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 = [ "//third_party/behaviortree:behaviortree_cpp", "//third_party/behaviortree:bt_sample_nodes", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### t11_replace_rulesohos_executable("t11_replace_rules") { output_name = "t11_replace_rules" # 可选,模块输出名 sources = [ "examples/t11_replace_rules.cpp", ] configs = [ ":executable_public_config", ":public_config", ] deps = [ "//third_party/behaviortree:behaviortree_cpp", "//third_party/behaviortree:bt_sample_nodes", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### ex01_wrap_legacyohos_executable("ex01_wrap_legacy") { output_name = "ex01_wrap_legacy" # 可选,模块输出名 sources = [ "examples/ex01_wrap_legacy.cpp", ] configs = [ ":executable_public_config", ":public_config", ] deps = [ "//third_party/behaviortree:behaviortree_cpp", "//third_party/behaviortree:bt_sample_nodes", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### ex02_runtime_portsohos_executable("ex02_runtime_ports") { output_name = "ex02_runtime_ports" # 可选,模块输出名 sources = [ "examples/ex02_runtime_ports.cpp", ] configs = [ ":executable_public_config", ":public_config", ] deps = [ "//third_party/behaviortree:behaviortree_cpp", "//third_party/behaviortree:bt_sample_nodes", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### ex03_ncurses_manual_selectorohos_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 = [ "//third_party/behaviortree:behaviortree_cpp", "//third_party/behaviortree:bt_sample_nodes", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}############################################################################### ex04_waypointsohos_executable("ex04_waypoints") { output_name = "ex04_waypoints" # 可选,模块输出名 sources = [ "examples/ex04_waypoints.cpp", ] configs = [ ":executable_public_config", ":public_config", ] deps = [ "//third_party/behaviortree:behaviortree_cpp", "//third_party/behaviortree:bt_sample_nodes", ] install_enable = true install_images = [ "system", "ramdisk", "updater", ] part_name = "behaviortree" subsystem_name = "behaviortree"}##############################################################################
./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
--product-name rk3568 :表示编译的产品是rk3568 (润和大禹200)--build-target=behaviortree :编译子系统behaviortree以下这些都是加快编译速度的选项--ccache --build-target=behaviortree --disable-post-build --disable-package-image --gn-args enable_notice_collection=false --gn-args load_test_config=false
so和可执行文件在out\rk3568\behaviortree目录下:
liblexy_file.a、libbt_sample_nodes.a等静态库文件在out\rk3568\obj\third_party\behaviortree目录下。
1、通过与ohos版本匹配的hdc_std工具,将编译生成的库以及测试用的可执行文件推送到开发板system/lib (lib64)
hdc shell mount -o remount,rw / ## 重新加载系统为可读写chmod 777 t02_basic_ports./t02_basic_ports
install_enable = true install_images = [ "system", "ramdisk", "updater", ]
想了解更多关于开源的内容,请访问:
51CTO 开源基础软件社区
https://ost.51cto.com
责任编辑:jianghua 来源: 51CTO 开源基础软件社区 C++三方库移植(责任编辑:时尚)
微软CEO纳德拉:必应与苹果Siri分道扬镳后,将专注搜索市场
6月iOS设备性能榜:M2稳居榜首 A系列只能等一手3nm来救
HTC 部分“卖身” Google,11 亿美元的交易意味着什么?
海关总署:前10个月民营企业进出口15.31万亿元 占外贸总值的48.3%