Last active
June 10, 2021 00:15
-
-
Save stonier/0a7ae007a9bd1ada3bb1c7604a11a573 to your computer and use it in GitHub Desktop.
Snorriheim Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################ | |
# Environment | |
################################################################################ | |
SHELL:=/bin/bash | |
PWD:=$(shell pwd) | |
################################################################################ | |
# Variables | |
################################################################################ | |
# use with e.g. 'make one PACKAGE=py_trees_ros' | |
PACKAGE?=py_trees_ros | |
# Inferencing what workspace this might be...otherwise preset VCI_INDEX | |
VCS_FAMILY:=$(shell basename $(shell dirname ${PWD})) | |
VCS_SUITE:=$(shell basename ${PWD}) | |
VCI_INDEX?=${VCS_FAMILY}/${VCS_SUITE} | |
################################################################################ | |
# Build Arguments | |
################################################################################ | |
COLCON_ARGS=--symlink-install --event-handlers console_direct+ | |
COLCON_QUIET_ARGS=--symlink-install --event-handlers | |
# OR make a single tarball or binary | |
# COLCON_ARGS=--merge-install --event-handlers console_direct+ | |
# COLCON_QUIET_ARGS=--merge-install --event-handlers | |
CMAKE_ARGS:=--cmake-args | |
ifneq ("$(wildcard initial_cache.cmake)","") | |
CMAKE_ARGS:=${CMAKE_ARGS} -C ${PWD}/initial_cache.cmake | |
endif | |
# CMAKE_ARGS:=${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_VERBOSE_MAKEFILE:=ON | |
# CMAKE_ARGS:=${CMAKE_ARGS} -C ${PWD}/config.cache | |
# CMAKE_ARGS:=${CMAKE_ARGS} --cmake-force-configure | |
# CMAKE_ARGS:=${CMAKE_ARGS} --cmake-force-configure | |
# CMAKE_ARGS:=${CMAKE_ARGS} -DCMAKE_PREFIX_PATH=/opt/ueye | |
################################################################################ | |
# Distro & Underlay Setup | |
################################################################################ | |
UBUNTU_DISTRO=$(shell lsb_release -cs) | |
ifeq ($(UBUNTU_DISTRO),bionic) | |
DISTRO:=dashing | |
else ifeq ($(UBUNTU_DISTRO),focal) | |
DISTRO:=foxy | |
endif | |
SETUP_ENV:=. /opt/ros/${DISTRO}/setup.bash | |
distro: | |
@echo "**************************************************************************************" | |
@echo " Distro Variables" | |
@echo "**************************************************************************************" | |
@echo "UBUNTU DISTRO: ${UBUNTU_DISTRO}" | |
@echo "ROS DISTRO : ${DISTRO}" | |
################################################################################ | |
# Dependencies | |
################################################################################ | |
SYSTEM_DEPS=build-essential curl git lsb-release wget python3-dev xdot | |
BUILD_DEPS=python3-colcon-core python3-colcon-common-extensions python3-rosdep python3-vci python3-vcstool | |
help: | |
@echo "" | |
@echo "Valid Targets:" | |
@echo "" | |
@echo " workspace : bootstrap/update the workspace" | |
@echo " - installs/updates sources in ./src" | |
@echo " - installs build and package dependencies" | |
@echo "" | |
@echo " update_myself : update this Makefile from gist" | |
@echo " update_sources : import / pull sources only" | |
@echo " update_build_dependencies : system build dependencies" | |
@echo " update_package_dependencies : ros dependencies from the ros apt repo" | |
@echo "" | |
@echo " list : print the topologically ordered build list" | |
@echo " info : detailed information on each package" | |
@echo "" | |
@echo " all : build and install everything" | |
@echo " quiet : build quietly" | |
@echo " one : build only one package, e.g. 'make one PACKAGE=ecl_time'" | |
@echo "" | |
@echo " tests : run tests with verbosity on failure" | |
@echo " clean : clean all cmake project build and install directories" | |
@echo "" | |
ros_apt_source_file = /etc/apt/sources.list.d/ros2.list | |
$(ros_apt_source_file): | |
@echo "**************************************************************************************" | |
@echo " ROS2 Apt Repository" | |
@echo "**************************************************************************************" | |
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - | |
sudo sh -c 'echo "deb [arch=`dpkg --print-architecture`] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2.list' | |
sudo apt update | |
snorriheim_apt_source_file = /etc/apt/sources.list.d/d-stonier-ubuntu-snorriheim-${UBUNTU_DISTRO}.list | |
$(snorriheim_apt_source_file): | |
@echo "**************************************************************************************" | |
@echo " Snorriheim Apt Repository" | |
@echo "**************************************************************************************" | |
sudo add-apt-repository ppa:d-stonier/snorriheim | |
sudo apt-get update | |
update_system_dependencies: | |
@echo "**************************************************************************************" | |
@echo " Update System Dependencies" | |
@echo "**************************************************************************************" | |
@dpkg -s ${SYSTEM_DEPS} > /dev/null || sudo apt install ${SYSTEM_DEPS} | |
update_build_dependencies: update_system_dependencies $(ros_apt_source_file) $(snorriheim_apt_source_file) | |
@echo "**************************************************************************************" | |
@echo " Update Build Dependencies" | |
@echo "**************************************************************************************" | |
@dpkg -s ${BUILD_DEPS} > /dev/null || sudo apt install ${BUILD_DEPS} | |
update_sources: | |
@echo "**************************************************************************************" | |
@echo " Updating Sources" | |
@echo "**************************************************************************************" | |
@mkdir -p src | |
@cd src && vci find ${VCI_INDEX} | vcs import || exit 1 | |
@cd src && vcs pull || exit 1 | |
update_package_dependencies: $(ros_apt_source_file) | |
@echo "**************************************************************************************" | |
@echo " Update ROS Dependencies" | |
@echo "**************************************************************************************" | |
test -f /etc/ros/rosdep/sources.list.d/20-default.list || { sudo rosdep init; rosdep update; } | |
rosdep install --from-paths src --rosdistro ${DISTRO} --ignore-src -r -y | |
workspace: update_build_dependencies update_sources update_package_dependencies | |
update_myself: | |
@echo "**************************************************************************************" | |
@echo " Fetching Latest Makefile"; | |
@echo "**************************************************************************************" | |
@mkdir -p gist | |
@if [ -d "gist/makefile" ]; then \ | |
cd gist/makefile && git pull; \ | |
else \ | |
git clone git@gist.github.com:0a7ae007a9bd1ada3bb1c7604a11a573.git gist/makefile; \ | |
rm -f ./Makefile; \ | |
ln -s gist/makefile/snorriheim-Makefile ./Makefile; \ | |
fi | |
@if [ -d "gist/setup" ]; then \ | |
cd gist/setup && git pull; \ | |
else \ | |
git clone git@gist.github.com:57901cd58fae9a235401f5bd2858e4e3.git gist/setup; \ | |
rm -f ./setup.bash; \ | |
ln -s gist/setup/setup.bash ./setup.bash; \ | |
fi | |
@if [ -d "gist/eclipse" ]; then \ | |
cd gist/eclipse && git pull; \ | |
else \ | |
git clone git@gist.github.com:11737562d0053d85950c9fb67927b97c.git gist/eclipse; \ | |
rm -f ./eclipse; \ | |
ln -s gist/eclipse/eclipse ./eclipse; \ | |
fi | |
clean: | |
rm -rf build install log | |
all: | |
@echo "**************************************************************************************" | |
@echo " Build All"; | |
@echo "**************************************************************************************" | |
${SETUP_ENV} && VERBOSE=1 colcon build ${COLCON_ARGS} ${CMAKE_ARGS} | |
build: all | |
quiet: | |
@echo "**************************************************************************************" | |
@echo " Build Quietly"; | |
@echo "**************************************************************************************" | |
${SETUP_ENV} && VERBOSE=1 colcon build ${COLCON_QUIET_ARGS} ${CMAKE_ARGS} | |
one: | |
@echo "**************************************************************************************" | |
@echo " Build One"; | |
@echo "**************************************************************************************" | |
${SETUP_ENV} && VERBOSE=1 colcon build ${COLCON_ARGS} --packages-select ${PACKAGE} ${CMAKE_ARGS} | |
testone: | |
@echo "**************************************************************************************" | |
@echo " Tests"; | |
@echo "**************************************************************************************" | |
# for python packages, this is just running python3 setup.py test | |
${SETUP_ENV} && colcon test --packages-select ${PACKAGE} --abort-on-error | |
${SETUP_ENV} && colcon test-result --test-result-base build/${PACKAGE} --all | |
tests: | |
@echo "**************************************************************************************" | |
@echo " Tests"; | |
@echo "**************************************************************************************" | |
# for python packages, this is just running python3 setup.py test | |
${SETUP_ENV} && colcon test | |
${SETUP_ENV} && colcon test-result --all | |
info: | |
@echo "**************************************************************************************" | |
@echo " Package Information"; | |
@echo "**************************************************************************************" | |
colcon info | |
list: | |
@echo "**************************************************************************************" | |
@echo " Package Build Order"; | |
@echo "**************************************************************************************" | |
colcon list -t -n # text list | |
graph: | |
@echo "**************************************************************************************" | |
@echo " Package Build Graph"; | |
@echo "**************************************************************************************" | |
colcon graph --dot > /tmp/graph.dot && xdot /tmp/graph.dot | |
.PHONY: tests clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment