mirror of
https://github.com/lopsided98/nix-ros-overlay.git
synced 2025-07-14 14:10:37 +03:00
Reduce ROS2 closure sizes and make example work out of the box
This commit is contained in:
parent
6a181ca24b
commit
0260ffc9ff
3 changed files with 16 additions and 8 deletions
31
distros/ament-cmake-core-setup-hook.sh
Normal file
31
distros/ament-cmake-core-setup-hook.sh
Normal file
|
@ -0,0 +1,31 @@
|
|||
isAmentPackage() {
|
||||
[ -d "$1/share/ament_index" ]
|
||||
}
|
||||
|
||||
declare -gA _amentPackagesSeen
|
||||
|
||||
_findAmentPackages() {
|
||||
local pkg="$1"
|
||||
# Deduplicate the packages
|
||||
if [ -z "${_amentPackagesSeen["$pkg"]:-}" ] \
|
||||
&& isAmentPackage "$pkg" \
|
||||
&& [ -n "$(shopt -s nullglob; echo $pkg/share/*/local_setup.sh)" ]
|
||||
then
|
||||
# ROS scripts use unbound variables
|
||||
set +u
|
||||
for setup in "$pkg"/share/*/local_setup.sh; do
|
||||
source "$setup"
|
||||
done
|
||||
set -u
|
||||
fi
|
||||
_amentPackagesSeen["$pkg"]=1
|
||||
}
|
||||
addEnvHooks "$hostOffset" _findAmentPackages
|
||||
|
||||
_amentCmakeCorePreConfigureHook() {
|
||||
# Don't create share/ament_index/resource_index/parent_prefix_path resource
|
||||
# that contains references to all dependencies. This file isn't used with Nix
|
||||
# and just bloats the closure.
|
||||
cmakeFlags+=" -DAMENT_CMAKE_ENVIRONMENT_PARENT_PREFIX_PATH_GENERATION=OFF"
|
||||
}
|
||||
preConfigureHooks+=(_amentCmakeCorePreConfigureHook)
|
Loading…
Add table
Add a link
Reference in a new issue