1
0
Fork 0
mirror of https://github.com/lopsided98/nix-ros-overlay.git synced 2025-07-14 14:10:37 +03:00

ament-cmake-core: use build platform Python

This commit is contained in:
Ben Wolsieffer 2022-09-20 15:26:10 -04:00
parent 032fe0bbc8
commit b6ad7f87f1
3 changed files with 21 additions and 4 deletions

View file

@ -0,0 +1,9 @@
{ makeSetupHook, python }:
makeSetupHook {
name = "ament-cmake-core-setup-hook";
substitutions = {
python_major = python.sourceVersion.major;
python_executable = python.pythonForBuild.interpreter;
};
} ./setup-hook.sh

View file

@ -0,0 +1,33 @@
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 "$targetOffset" _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:BOOL=OFF"
# Point CMake at build platform Python so it can run it at build time
cmakeFlags+=" -DPython@python_major@_EXECUTABLE:FILEPATH=@python_executable@"
}
preConfigureHooks+=(_amentCmakeCorePreConfigureHook)