-
Notifications
You must be signed in to change notification settings - Fork 146
ament_cmake_vendor: also generate powershell hooks #626
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
base: rolling
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # generated from ament_cmake_vendor_package/cmake/templates/local_setup.ps1.in | ||
|
|
||
| # the current prefix is two levels up from the package specific share folder | ||
| $env:AMENT_CURRENT_PREFIX=(Get-Item $PSCommandPath).Directory.Parent.Parent.FullName | ||
|
|
||
| # source all environment hooks of this package | ||
| if (Test-Path "$env:AMENT_CURRENT_PREFIX/share/@PROJECT_NAME@/environment/vendor_package.ps1") { | ||
| . "$env:AMENT_CURRENT_PREFIX/share/@PROJECT_NAME@/environment/vendor_package.ps1" | ||
| } | ||
| if (Test-Path "$env:AMENT_CURRENT_PREFIX/share/@PROJECT_NAME@/environment/vendor_package_cmake_prefix.ps1") { | ||
| . "$env:AMENT_CURRENT_PREFIX/share/@PROJECT_NAME@/environment/vendor_package_cmake_prefix.ps1" | ||
| } | ||
|
|
||
| Remove-Item Env:\AMENT_CURRENT_PREFIX |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # generated from ament_cmake_vendor_package/cmake/templates/vendor_package.ps1.in | ||
|
|
||
| function ament_vendor_prepend_unique_value { | ||
| param ( | ||
| $_listname, | ||
| $_value | ||
| ) | ||
| if (Test-Path Env:$_listname) { | ||
| $_values=(Get-Item env:$_listname).Value | ||
| } else { | ||
| $_values="" | ||
| } | ||
| $_all_values="$_value" | ||
| if ($_values) { | ||
| $_values.Split(";") | ForEach-Object { | ||
| if ($_) { | ||
| if ($_ -ne $_value) { | ||
| $_all_values="${_all_values};$_" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Set-Item env:\$_listname -Value "$_all_values" | ||
| } | ||
|
|
||
| if (Test-Path "$env:AMENT_CURRENT_PREFIX/opt/@PROJECT_NAME@/bin") { | ||
| ament_vendor_prepend_unique_value PATH "$env:AMENT_CURRENT_PREFIX/opt/@PROJECT_NAME@/bin" | ||
| } | ||
|
|
||
| if (Test-Path "$env:AMENT_CURRENT_PREFIX/opt/@PROJECT_NAME@/lib") { | ||
| ament_vendor_prepend_unique_value @_LIBDIR_VAR_NAME@ "$env:AMENT_CURRENT_PREFIX/opt/@PROJECT_NAME@/lib" | ||
| } | ||
|
|
||
| if (Test-Path "$env:AMENT_CURRENT_PREFIX/opt/@PROJECT_NAME@/lib64") { | ||
| ament_vendor_prepend_unique_value @_LIBDIR_VAR_NAME@ "$env:AMENT_CURRENT_PREFIX/opt/@PROJECT_NAME@/lib64" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # generated from ament_cmake_vendor_package/cmake/templates/vendor_package_cmake_prefix.ps1.in | ||
|
|
||
| function ament_vendor_prepend_unique_value { | ||
| param ( | ||
| $_listname, | ||
| $_value | ||
| ) | ||
| if (Test-Path Env:$_listname) { | ||
| $_values=(Get-Item env:$_listname).Value | ||
| } else { | ||
| $_values="" | ||
| } | ||
| $_all_values="$_value" | ||
| if ($_values) { | ||
| $_values.Split(";") | ForEach-Object { | ||
| if ($_) { | ||
| if ($_ -ne $_value) { | ||
| $_all_values="${_all_values};$_" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Set-Item env:\$_listname -Value "$_all_values" | ||
| } | ||
|
|
||
| if (Test-Path "$env:AMENT_CURRENT_PREFIX/opt/@PROJECT_NAME@") { | ||
| ament_vendor_prepend_unique_value CMAKE_PREFIX_PATH "$env:AMENT_CURRENT_PREFIX/opt/@PROJECT_NAME@" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,12 @@ ament_vendor(depender | |
| SKIP_INSTALL | ||
| ) | ||
|
|
||
| ament_vendor(exlib_install | ||
| VCS_URL exlib_good | ||
| VCS_TYPE path | ||
| GLOBAL_HOOK | ||
| ) | ||
|
Comment on lines
+29
to
+33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will result in the call to It also means that a call to |
||
|
|
||
| externalproject_add_stepdependencies(depender configure exlib_bad exlib_good) | ||
|
|
||
| if(WIN32) | ||
|
|
@@ -50,3 +56,19 @@ ament_add_test(layering_bad | |
| COMMAND "${depender_BINDIR}/depender" "should-fail" | ||
| GENERATE_RESULT_FOR_RETURN_CODE_ZERO | ||
| APPEND_LIBRARY_DIRS "${exlib_bad_LIBDIR}" "${exlib_good_LIBDIR}") | ||
|
|
||
| if(WIN32) | ||
| configure_file( | ||
| test_powershell_setup.ps1 | ||
| ${CMAKE_CURRENT_BINARY_DIR}/test_powershell_setup.ps1 | ||
| COPYONLY | ||
| ) | ||
|
|
||
| ament_add_test(test_powershell_setup | ||
| COMMAND powershell.exe -NonInteractive -ExecutionPolicy Bypass -File | ||
| "${CMAKE_CURRENT_BINARY_DIR}/test_powershell_setup.ps1" | ||
| "${CMAKE_INSTALL_PREFIX}" | ||
| GENERATE_RESULT_FOR_RETURN_CODE_ZERO | ||
| ) | ||
|
Comment on lines
+67
to
+72
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assumes that |
||
| endif() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| param ( | ||
| [string]$InstallPrefix | ||
| ) | ||
|
|
||
| $env:PATH = "" | ||
| $env:CMAKE_PREFIX_PATH = "" | ||
|
|
||
| $setup_file = "$InstallPrefix/share/ament_cmake_vendor_package_test/local_setup.ps1" | ||
| if (-not (Test-Path $setup_file)) { | ||
| Write-Error "Could not find local_setup.ps1 at $setup_file" | ||
| exit 1 | ||
| } | ||
|
|
||
| # Source the setup file | ||
| . $setup_file | ||
|
|
||
| Write-Host "PATH: $env:PATH" | ||
| Write-Host "CMAKE_PREFIX_PATH: $env:CMAKE_PREFIX_PATH" | ||
|
|
||
| if (-not "$env:PATH".Contains("ament_cmake_vendor_package_test")) { | ||
| Write-Error "PATH was not updated by local_setup.ps1" | ||
| exit 1 | ||
| } | ||
|
|
||
| if (-not "$env:CMAKE_PREFIX_PATH".Contains("ament_cmake_vendor_package_test")) { | ||
| Write-Error "CMAKE_PREFIX_PATH was not updated by local_setup.ps1" | ||
| exit 1 | ||
| } | ||
|
|
||
| Write-Host "PowerShell local_setup.ps1 verified successfully!" | ||
| exit 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only section I'm hung up on.
As I understand it, for colcon builds, the
colcon-powershellshell extension generates package-level setup scripts today. Supporting Powershell in plain ament builds (like we use for deb and RPM packages) means thatament_cmakeshould be generating the hooks, either directly as a supported shell or by exposing an extension point for a newament_cmake_powershellpackage to implement.Adding it here, while it makes the test being added pass, doesn't make the other custom hooks in ROS start working as well without a similar change, and I don't think we want to be implicitly creating package-level Powershell setup scripts all over the place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In short, I'm worried that this is a "whack-a-mole" approach to making powershell work better.