diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54d4e3ab..9b705f0c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: name: Ubuntu Focal CI steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Compile and test id: ci uses: gazebo-tooling/action-gz-ci@focal @@ -22,7 +22,7 @@ jobs: name: Ubuntu Jammy CI steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Compile and test id: ci uses: gazebo-tooling/action-gz-ci@jammy diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml index 6f93ccd5..2c94852d 100644 --- a/.github/workflows/triage.yml +++ b/.github/workflows/triage.yml @@ -10,9 +10,8 @@ jobs: runs-on: ubuntu-latest steps: - name: Add ticket to inbox - uses: technote-space/create-project-card-action@v1 + uses: actions/add-to-project@v0.5.0 with: - PROJECT: Core development - COLUMN: Inbox - GITHUB_TOKEN: ${{ secrets.TRIAGE_TOKEN }} - CHECK_ORG_PROJECT: true + project-url: https://github.com/orgs/gazebosim/projects/7 + github-token: ${{ secrets.TRIAGE_TOKEN }} + diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 00000000..f1d9f490 --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,139 @@ +load( + "@gz//bazel/skylark:build_defs.bzl", + "GZ_FEATURES", + "GZ_ROOT", + "GZ_VISIBILITY", + "gz_configure_header", + "gz_export_header", + "gz_include_header", +) + +package( + default_visibility = GZ_VISIBILITY, + features = GZ_FEATURES, +) + +licenses(["notice"]) # Apache-2.0 + +gz_configure_header( + name = "config", + src = "core/include/gz/plugin/config.hh.in", + cmakelists = ["CMakeLists.txt"], + package = "plugin", +) + +gz_export_header( + name = "core/include/gz/plugin/Export.hh", + export_base = "GZ_PLUGIN", + lib_name = "gz-plugin", + visibility = ["//visibility:private"], +) + +public_headers_no_gen = glob([ + "core/include/gz/plugin/*.hh", + "core/include/gz/plugin/detail/*.hh", +]) + +sources = glob( + ["core/src/*.cc"], + exclude = ["core/src/*_TEST.cc"], +) + +gz_include_header( + name = "pluginhh_genrule", + out = "core/include/gz/plugin.hh", + hdrs = public_headers_no_gen + [ + "core/include/gz/plugin/config.hh", + "core/include/gz/plugin/Export.hh", + ], +) + +public_headers = public_headers_no_gen + [ + "core/include/gz/plugin/config.hh", + "core/include/gz/plugin/Export.hh", + "core/include/gz/plugin.hh", +] + +cc_library( + name = "core", + srcs = sources, + hdrs = public_headers, + includes = ["core/include"], + deps = [ + GZ_ROOT + "utils", + ], +) + +[cc_test( + name = src.replace("/", "_").replace(".cc", "").replace("src_", ""), + srcs = [src], + deps = [ + ":core", + "@gtest", + "@gtest//:gtest_main", + ], +) for src in glob( + [ + "core/src/*_TEST.cc", + ], +)] + +cc_library( + name = "register", + hdrs = [ + "register/include/gz/plugin/Register.hh", + "register/include/gz/plugin/RegisterMore.hh", + "register/include/gz/plugin/RegisterStatic.hh", + "register/include/gz/plugin/detail/Common.hh", + "register/include/gz/plugin/detail/Register.hh", + "register/include/gz/plugin/detail/RegisterStatic.hh", + ], + includes = [ + "register/include", + ], + deps = [ + ":core", + ], +) + +gz_export_header( + name = "loader/include/gz/plugin/loader/Export.hh", + export_base = "GZ_PLUGIN_LOADER", + lib_name = "gz-plugin-loader", + visibility = ["//visibility:private"], +) + +cc_library( + name = "loader", + srcs = [ + "loader/src/Loader.cc", + "loader/src/detail/Registry.cc", + "loader/src/detail/StaticRegistry.cc", + ], + hdrs = [ + "loader/include/gz/plugin/Loader.hh", + "loader/include/gz/plugin/detail/Loader.hh", + "loader/include/gz/plugin/detail/Registry.hh", + "loader/include/gz/plugin/detail/StaticRegistry.hh", + "loader/include/gz/plugin/loader/Export.hh", + ], + includes = ["loader/include"], + deps = [ + ":core", + GZ_ROOT + "utils", + ], +) + +cc_test( + name = "Loader_TEST", + srcs = ["loader/src/Loader_TEST.cc"], + defines = [ + 'GzDummyPlugins_LIB=\\"./plugin/test/libGzDummyPlugins.so\\"', + ], + deps = [ + ":loader", + GZ_ROOT + "plugin/test:test_plugins", + "@gtest", + "@gtest//:gtest_main", + ], +) diff --git a/COPYING b/COPYING deleted file mode 100644 index 4909afd0..00000000 --- a/COPYING +++ /dev/null @@ -1,178 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - diff --git a/Changelog.md b/Changelog.md index 178a8dfe..f2de16d9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,38 @@ ## Gazebo Plugin 2.x +### Gazebo Plugin 2.0.2 (2023-09-26) + +1. Add explicit dependency on plugin library + * [Pull request #124](https://github.com/gazebosim/gz-plugin/pull/124) + +1. Documentation fixes + * [Pull request #122](https://github.com/gazebosim/gz-plugin/pull/122) + * [Pull request #112](https://github.com/gazebosim/gz-plugin/pull/112) + +1. Infrastructure + * [Pull request #121](https://github.com/gazebosim/gz-plugin/pull/121) + * [Pull request #120](https://github.com/gazebosim/gz-plugin/pull/120) + * [Pull request #115](https://github.com/gazebosim/gz-plugin/pull/115) + +1. Update parameter name in DemangleSymbol to match declaration + * [Pull request #117](https://github.com/gazebosim/gz-plugin/pull/117) + +1. Inline functions in plugin_unload.hh + * [Pull request #118](https://github.com/gazebosim/gz-plugin/pull/118) + +1. Rename COPYING to LICENSE + * [Pull request #114](https://github.com/gazebosim/gz-plugin/pull/114) + +1. Bazel build rules for garden + * [Pull request #113](https://github.com/gazebosim/gz-plugin/pull/113) + + +### Gazebo Plugin 2.0.1 + +1. Forward port 1.4.0. + * [Pull request #109](https://github.com/gazebosim/gz-plugin/pull/109) + ### Gazebo Plugin 2.0.0 1. Add option to use `RTLD_NODELETE` when loading a library. @@ -48,26 +80,7 @@ ## Gazebo Plugin 1.x -### Gazebo Plugin 1.2.1 (2021-09-24) - -1. Add Doxygen documentation checks to CI - * [Pull request #59](https://github.com/gazebosim/gz-plugin/pull/59) - -1. Infrastructure - * [Pull request #58](https://github.com/gazebosim/gz-plugin/pull/58) - * [Pull request #52](https://github.com/gazebosim/gz-plugin/pull/52) - * [Pull request #51](https://github.com/gazebosim/gz-plugin/pull/51) - -1. Find gz program instead of gz-tools - * [Pull request #57](https://github.com/gazebosim/gz-plugin/pull/57) - -1. Remove gz-tools from CMakeLists.txt. Not used - * [Pull request #56](https://github.com/gazebosim/gz-plugin/pull/56) - - -## Gazebo Plugin 1.x - -### Gazebo Plugin 1.3.0 (2022-11-11) +### Gazebo Plugin 1.4.0 (2022-11-11) 1. ign -> gz Migrate Ignition Headers : gz-plugin * [Pull request #101](https://github.com/gazebosim/gz-plugin/pull/101) @@ -95,6 +108,22 @@ 1. Install ruby commands on Windows * [Pull request #63](https://github.com/gazebosim/gz-plugin/pull/63) +### Gazebo Plugin 1.2.1 (2021-09-24) + +1. Add Doxygen documentation checks to CI + * [Pull request #59](https://github.com/gazebosim/gz-plugin/pull/59) + +1. Infrastructure + * [Pull request #58](https://github.com/gazebosim/gz-plugin/pull/58) + * [Pull request #52](https://github.com/gazebosim/gz-plugin/pull/52) + * [Pull request #51](https://github.com/gazebosim/gz-plugin/pull/51) + +1. Find gz program instead of gz-tools + * [Pull request #57](https://github.com/gazebosim/gz-plugin/pull/57) + +1. Remove gz-tools from CMakeLists.txt. Not used + * [Pull request #56](https://github.com/gazebosim/gz-plugin/pull/56) + ### Gazebo Plugin 1.2.0 (2021-03-30) 1. Infrastructure diff --git a/LICENSE b/LICENSE index 5f63c882..4909afd0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,15 +1,178 @@ -Software License Agreement (Apache License) + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ -Copyright 2014 Open Source Robotics Foundation + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/README.md b/README.md index fec12ebe..ba01ee97 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,11 @@ Build | Status Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-plugin/branch/main/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-plugin/branch/main) Ubuntu Focal | [![Build Status](https://build.osrfoundation.org/job/ignition_plugin-ci-main-focal-amd64/badge/icon)](https://build.osrfoundation.org/job/ignition_plugin-ci-main-focal-amd64/) Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_plugin-ci-main-homebrew-amd64)](https://build.osrfoundation.org/job/ignition_plugin-ci-main-homebrew-amd64) -Windows 7 | [![Build Status](https://build.osrfoundation.org/job/ignition_plugin-ci-main-windows7-amd64/badge/icon)](https://build.osrfoundation.org/job/ignition_plugin-ci-main-windows7-amd64/) - -**Library for registering plugin libraries and dynamically loading them at runtime.** +Windows | [![Build Status](https://build.osrfoundation.org/view/ign-garden/job/ign_plugin-gz-2-win/badge/icon)](https://build.osrfoundation.org/view/ign-garden/job/ign_plugin-gz-2-win/) Gazebo Plugin is a component in the [Gazebo](http://gazebosim.org) framework, a set -of libraries designed to rapidly develop robot applications. +of libraries designed to rapidly develop robot applications. +It is used to register plugin libraries and load them dynamically at runtime. [http://gazebosim.org](http://gazebosim.org) @@ -31,8 +30,8 @@ of libraries designed to rapidly develop robot applications. ## Installation -See the [installation tutorial](https://gazebosim.org/api/plugin/1.2/installation.html). +See the [installation tutorial](https://gazebosim.org/api/plugin/2/installation.html). # Documentation -API documentation and tutorials can be accessed at [https://gazebosim.org/libs/plugin](https://gazebosim.org/libs/plugin) +Visit the [documentation page](https://gazebosim.org/api/plugin/2/index.html). diff --git a/core/src/utility.cc b/core/src/utility.cc index 970d2f1a..5ed920a2 100644 --- a/core/src/utility.cc +++ b/core/src/utility.cc @@ -32,20 +32,20 @@ namespace gz namespace plugin { ///////////////////////////////////////////////// - std::string DemangleSymbol(const std::string &_name) + std::string DemangleSymbol(const std::string &_symbol) { #if defined(__GNUC__) || defined(__clang__) int status; char *demangled_cstr = abi::__cxa_demangle( - _name.c_str(), nullptr, nullptr, &status); + _symbol.c_str(), nullptr, nullptr, &status); if (0 != status) { // LCOV_EXCL_START - std::cerr << "[Demangle] Failed to demangle the symbol name [" << _name - << "]. Error code: " << status << "\n"; + std::cerr << "[Demangle] Failed to demangle the symbol name [" + << _symbol << "]. Error code: " << status << "\n"; assert(false); - return _name; + return _symbol; // LCOV_EXCL_STOP } @@ -55,20 +55,20 @@ namespace gz return demangled; #elif _MSC_VER - assert(_name.substr(0, 6) == "class "); + assert(_symbol.substr(0, 6) == "class "); // Visual Studio's typeid(~).name() does not mangle the name, except that // it prefixes the normal name of the class with the character sequence // "class ". So to get the "demangled" name, all we have to do is remove // "class " from each place where it appears. const std::regex classRegex("class "); - return std::regex_replace(_name, classRegex, ""); + return std::regex_replace(_symbol, classRegex, ""); #else // If we don't know the compiler, then we can't perform name demangling. // The tests will probably fail in this situation, and the class names // will probably look gross to users. Plugin name aliasing can be used // to make plugins robust to this situation. - return _name; + return _symbol; #endif } } diff --git a/loader/src/Loader.cc b/loader/src/Loader.cc index 9296d454..7d36c028 100644 --- a/loader/src/Loader.cc +++ b/loader/src/Loader.cc @@ -155,7 +155,9 @@ namespace gz // Quit early and return an empty set of plugin names if we did not // actually get a valid dlHandle. if (nullptr == dlHandle) + { return newPlugins; + } // Found a shared library, does it have the symbols we're looking for? std::vector loadedPlugins = this->dataPtr->LoadPlugins( diff --git a/loader/src/Loader_TEST.cc b/loader/src/Loader_TEST.cc index cfe44cca..19c775bc 100644 --- a/loader/src/Loader_TEST.cc +++ b/loader/src/Loader_TEST.cc @@ -43,7 +43,7 @@ TEST(Loader, LoadNonexistantLibrary) TEST(Loader, LoadNonLibrary) { gz::plugin::Loader loader; - EXPECT_TRUE(loader.LoadLib(std::string(GZ_PLUGIN_SOURCE_DIR) + EXPECT_TRUE(loader.LoadLib(std::string("") + "/core/src/Plugin.cc").empty()); } @@ -51,7 +51,7 @@ TEST(Loader, LoadNonLibrary) TEST(Loader, LoadNonPluginLibrary) { gz::plugin::Loader loader; - EXPECT_TRUE(loader.LoadLib(GZ_PLUGIN_LIB).empty()); + EXPECT_TRUE(loader.LoadLib("").empty()); } ///////////////////////////////////////////////// diff --git a/test/BUILD.bazel b/test/BUILD.bazel new file mode 100644 index 00000000..cb67b7e9 --- /dev/null +++ b/test/BUILD.bazel @@ -0,0 +1,227 @@ +load( + "@gz//bazel/skylark:build_defs.bzl", + "GZ_ROOT", + "GZ_VISIBILITY", +) + +cc_library( + name = "test_plugins_core", + testonly = 1, + hdrs = [ + "plugins/DummyMultiPlugin.hh", + "plugins/DummyPlugins.hh", + "plugins/FactoryPlugins.hh", + "plugins/GenericExport.hh", + "plugins/TemplatedPlugins.hh", + ], + includes = ["plugins"], +) + +cc_binary( + name = "libGzBadPluginAlign.so", + testonly = 1, + srcs = [ + "plugins/BadPluginAlign.cc", + ], + linkshared = 1, + deps = [ + ":test_plugins_core", + GZ_ROOT + "plugin:register", + ], +) + +cc_binary( + name = "libGzBadPluginAPIVersionNew.so", + testonly = 1, + srcs = [ + "plugins/BadPluginAPIVersionNew.cc", + ], + linkshared = 1, + deps = [ + ":test_plugins_core", + GZ_ROOT + "plugin:register", + ], +) + +cc_binary( + name = "libGzBadPluginAPIVersionOld.so", + testonly = 1, + srcs = [ + "plugins/BadPluginAPIVersionOld.cc", + ], + linkshared = 1, + deps = [ + ":test_plugins_core", + GZ_ROOT + "plugin:register", + ], +) + +cc_binary( + name = "libGzBadPluginNoInfo.so", + testonly = 1, + srcs = [ + "plugins/BadPluginNoInfo.cc", + ], + linkshared = 1, + deps = [ + ":test_plugins_core", + GZ_ROOT + "plugin:register", + ], +) + +cc_binary( + name = "libGzBadPluginSize.so", + testonly = 1, + srcs = [ + "plugins/BadPluginSize.cc", + ], + linkshared = 1, + deps = [ + ":test_plugins_core", + GZ_ROOT + "plugin:register", + ], +) + +cc_binary( + name = "libGzFactoryPlugins.so", + testonly = 1, + srcs = [ + "plugins/FactoryPlugins.cc", + ], + linkshared = 1, + deps = [ + ":test_plugins_core", + GZ_ROOT + "plugin:register", + ], +) + +cc_binary( + name = "libGzTemplatedPlugins.so", + testonly = 1, + srcs = [ + "plugins/TemplatedPlugins.cc", + ], + linkshared = 1, + deps = [ + ":test_plugins_core", + GZ_ROOT + "plugin:register", + ], +) + +cc_binary( + name = "libGzDummyPlugins.so", + testonly = 1, + srcs = [ + "plugins/DummyPlugins.cc", + "plugins/DummyPluginsOtherTranslationUnit.cc", + ], + linkshared = 1, + deps = [ + ":test_plugins_core", + GZ_ROOT + "plugin:register", + ], +) + +cc_library( + name = "test_plugins", + testonly = 1, + data = [ + ":libGzBadPluginAPIVersionNew.so", + ":libGzBadPluginAPIVersionOld.so", + ":libGzBadPluginAlign.so", + ":libGzBadPluginNoInfo.so", + ":libGzBadPluginSize.so", + ":libGzDummyPlugins.so", + ":libGzFactoryPlugins.so", + ":libGzTemplatedPlugins.so", + ], + defines = [ + 'GzDummyPlugins_LIB=\\"./plugin/test/libGzDummyPlugins.so\\"', + 'GzFactoryPlugins_LIB=\\"./plugin/test/libGzFactoryPlugins.so\\"', + 'GzTemplatedPlugins_LIB=\\"./plugin/test/libGzTemplatedPlugins.so\\"', + 'GzBadPluginAlign_LIB=\\"./plugin/test/lbGzBadPluginAlign.so\\"', + 'GzBadPluginNoInfo_LIB=\\"./plugin/test/lbGzBadPluginNoInfo.so\\"', + 'GzBadPluginSize_LIB=\\"./plugin/test/lbGzBadPluginSize.so\\"', + 'GzBadPluginAPIVersionOld_LIB=\\"./plugin/test/lbGzBadPluginAPIVersionOld.so\\"', + 'GzBadPluginAPIVersionNew_LIB=\\"./plugin/test/lbGzBadPluginAPIVersionNew.so\\"', + ], + visibility = GZ_VISIBILITY, + deps = [ + ":test_plugins_core", + ], +) + +cc_test( + name = "INTEGRATION_aliases", + srcs = ["integration/aliases.cc"], + deps = [ + ":test_plugins", + GZ_ROOT + "plugin:loader", + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "INTEGRATION_EnablePluginFromThis", + srcs = [ + "integration/EnablePluginFromThis_TEST.cc", + "integration/utils.hh", + ], + deps = [ + ":test_plugins", + GZ_ROOT + "plugin:loader", + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "INTEGRATION_factory", + srcs = [ + "integration/factory.cc", + "integration/utils.hh", + ], + deps = [ + ":test_plugins", + GZ_ROOT + "plugin:loader", + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "INTEGRATION_plugin", + srcs = [ + "integration/plugin.cc", + "integration/utils.hh", + ], + deps = [ + ":test_plugins", + GZ_ROOT + "plugin:loader", + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "INTEGRATION_templated_plugins", + srcs = [ + "integration/templated_plugins.cc", + "integration/utils.hh", + ], + deps = [ + ":test_plugins", + GZ_ROOT + "plugin:loader", + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "INTEGRATION_WeakPluginPtr", + srcs = [ + "integration/WeakPluginPtr.cc", + "integration/utils.hh", + ], + deps = [ + ":test_plugins", + GZ_ROOT + "plugin:loader", + "@gtest//:gtest_main", + ], +) diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt index 881d2f13..e63b7c7e 100644 --- a/test/integration/CMakeLists.txt +++ b/test/integration/CMakeLists.txt @@ -55,6 +55,9 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # linking generator expressions as described here: # https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#genex:LINK_LIBRARY target_link_libraries(INTEGRATION_static_plugins -WHOLEARCHIVE:$) + # The whole-archive invocation doesn't correctly compute dependencies, + # so explicitly require the plugin before the test can build. + add_dependencies(INTEGRATION_static_plugins GzDummyStaticPlugin) else() target_link_libraries(INTEGRATION_static_plugins $<$:-Wl,--whole-archive> diff --git a/test/integration/plugin_unload.hh b/test/integration/plugin_unload.hh index 4c198c6c..2191f8c8 100644 --- a/test/integration/plugin_unload.hh +++ b/test/integration/plugin_unload.hh @@ -33,7 +33,7 @@ /// \brief Load the InstanceCounter plugin /// \param[in] _nodelete True if RTLD_NODELETE should be used when loading the /// \return Pointer to the plugin -gz::plugin::PluginPtr LoadInstanceCounter(bool _nodelete) +inline gz::plugin::PluginPtr LoadInstanceCounter(bool _nodelete) { gz::plugin::Loader pl; @@ -50,7 +50,8 @@ gz::plugin::PluginPtr LoadInstanceCounter(bool _nodelete) /// \param[in] _nodelete True if RTLD_NODELETE should be used when loading the /// library. /// \param[in] _numExpectedInstances Expected number of instances of the plugin. -void LoadAndTestInstanceCounter(bool _nodelete, int _numExpectedInstances) +inline void LoadAndTestInstanceCounter(bool _nodelete, + int _numExpectedInstances) { gz::plugin::PluginPtr instanceCounterPlugin = LoadInstanceCounter(_nodelete); test::util::InstanceCounterBase *instanceCounter =