Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional binary relocatability #507

Merged
merged 10 commits into from
Aug 29, 2023

Conversation

traversaro
Copy link
Contributor

@traversaro traversaro commented Apr 24, 2023

🦟 Bug fix

Closes part of gazebosim/gz-sim#626

Summary

This PR uses the changes introduced in gz-cmake3 in gazebosim/gz-cmake#334 to support the cmake installation directory to be moved after the make install prefix, and continue to work without the need to set any special environment variable, as long as the library is compiled as shared. To avoid regressions and problems in Ubuntu Focal due to the use of std::filesystem, this new behaviour is only activated if the GZ_ENABLE_RELOCATABLE_INSTALL option is enabled, and its default value is OFF .

In particular, this PR defines a gz::physics::getEngineInstallDir() function that should be used in place of the GZ_PHYSICS_ENGINE_INSTALL_DIR macro to ensure that the library is relocatable.

Furthermore, this PR also deprecates the GZ_PHYSICS_ENGINE_INSTALL_DIR macros, using the strategy described in https://stackoverflow.com/a/29297970 . That strategy works fine on GCC and Clang, while on MSVC it raise a warning:

warning C4068: unknown pragma

However, I think that it does anyhow the job of raising some kind of warning, and then at soon as the developer checks the macro definition the kind of warning is clear.

Test it

The test should work as usual. The used CMake machinery is tested in gazebosim/gz-cmake#334 .

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

Signed-off-by: Silvio Traversaro <[email protected]>
Copy link
Contributor

@mjcarroll mjcarroll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am happy with this implementation, but want to spend a moment to check with bazel interactions.

Copy link
Contributor

@j-rivero j-rivero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a small comment about the change in the dependencies. We also need a small patch for making codecheck happy:

diff --git a/src/InstallationDirectories.cc b/src/InstallationDirectories.cc
index 5f51c076..d9f2711a 100644
--- a/src/InstallationDirectories.cc
+++ b/src/InstallationDirectories.cc
@@ -28,7 +28,8 @@ inline namespace GZ_PHYSICS_VERSION_NAMESPACE {
 
 std::string getEngineInstallDir()
 {
-  return gz::common::joinPaths(getInstallPrefix(), GZ_PHYSICS_ENGINE_RELATIVE_INSTALL_DIR);
+  return gz::common::joinPaths(getInstallPrefix(),
+                               GZ_PHYSICS_ENGINE_RELATIVE_INSTALL_DIR);
 }
 
 }

CMakeLists.txt Outdated Show resolved Hide resolved
Copy link
Contributor

@mjcarroll mjcarroll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes have no impact with bazel rules, I will address the bazel changes in a follow-up PR, though.

Signed-off-by: Silvio Traversaro <[email protected]>
@codecov
Copy link

codecov bot commented May 8, 2023

Codecov Report

Merging #507 (4094858) into gz-physics6 (5343ab9) will decrease coverage by 0.41%.
The diff coverage is 0.00%.

❗ Current head 4094858 differs from pull request most recent head 62f2a32. Consider uploading reports for the commit 62f2a32 to get more accurate results

@@               Coverage Diff               @@
##           gz-physics6     #507      +/-   ##
===============================================
- Coverage        76.19%   75.78%   -0.41%     
===============================================
  Files              142      143       +1     
  Lines             7254     7293      +39     
===============================================
  Hits              5527     5527              
- Misses            1727     1766      +39     
Files Changed Coverage Δ
src/InstallationDirectories.cc 0.00% <0.00%> (ø)

@azeey azeey added the beta Targeting beta release of upcoming collection label Jul 31, 2023
@mjcarroll
Copy link
Contributor

@osrf-jenkins retest this please

@azeey azeey removed their request for review August 22, 2023 17:49
@azeey azeey removed the 🎵 harmonic Gazebo Harmonic label Aug 26, 2023
std::string path1 = sanitizeSlashes(checkWindowsPath(_path1));
std::string path2 = sanitizeSlashes(checkWindowsPath(_path2), true);
std::vector<char> combined(path1.length() + path2.length() + 2);
if (::PathCombineA(combined.data(), path1.c_str(), path2.c_str()) != NULL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in https://build.osrfoundation.org/job/ign_physics-pr-win/2336/console

src\InstallationDirectories.cc(130,9): error C2039: 'PathCombineA': is not a member of '`global namespace'' 

Copy link
Member

@scpeters scpeters Aug 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just getting back to these, I believe that is the case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, this is what I did in conda-forge: conda-forge/gz-physics-feedstock@d548779 . Probably I forgot to report it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2e1a99f .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something may need to be linked as well?

InstallationDirectories.obj : error LNK2001: unresolved external symbol __imp_PathCombineA [C:\J\workspace\ign_physics-pr-win\ws\build\gz-physics6\src\gz-physics6.vcxproj]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously yes, see last commit of https://github.com/conda-forge/gz-physics-feedstock/pull/11/commits , my bad. -_-

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully fixed by 62f2a32 .

Signed-off-by: Silvio Traversaro <[email protected]>
Signed-off-by: Silvio Traversaro <[email protected]>
@mjcarroll
Copy link
Contributor

Alrighty @traversaro maybe just DCO now?

@mjcarroll
Copy link
Contributor

Oh we've had a bunch of merges, I think we are good without any addition DCO work

@traversaro
Copy link
Contributor Author

The only non-merge commit without DCO seems 39b1d44 .

@mjcarroll mjcarroll merged commit 11f8fa4 into gazebosim:gz-physics6 Aug 29, 2023
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Targeting beta release of upcoming collection 🌱 garden Ignition Garden
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants