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

Applying all patches inside patches directory #79

Merged
merged 4 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions apply_patches.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Abort script on any failures
set -e

my_loc="$(cd "$(dirname $0)" && pwd)"
source $my_loc/config.sh
source $my_loc/utils.sh

if [ $# != 2 ] || [ $1 == '-h' ] || [ $1 == '--help' ]; then
echo "Usage: $0 patch_prefix output_prefix"
echo " example: $0 /home/user/ros_android/patches /home/user/my_workspace/output"
exit 1
fi

patch_prefix=$1
output_prefix=$2

echo
echo -e '\e[34mApplying patches.\e[39m'
echo

for patch_file in $patch_prefix/*.patch; do
apply_patch $patch_file -d $output_prefix
done
170 changes: 1 addition & 169 deletions do_everything.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,6 @@ mkdir -p $prefix/libs
export TARGET_DIR=$prefix/target
[ -d $TARGET_DIR ] || mkdir -p $TARGET_DIR

# Get the android ndk build helper script
# If file doesn't exist, then download and patch it
#if ! [ -e $prefix/android.toolchain.cmake ]; then
# cd $prefix
# download 'https://raw.githubusercontent.com/taka-no-me/android-cmake/556cc14296c226f753a3778d99d8b60778b7df4f/android.toolchain.cmake'
# patch -p0 -N -d $prefix < $my_loc/patches/android.toolchain.cmake.patch
# cat $my_loc/files/android.toolchain.cmake.addendum >> $prefix/android.toolchain.cmake
#fi

export RBA_TOOLCHAIN=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake
apply_patch $my_loc/patches/android.toolchain.cmake.patch -d $ANDROID_NDK_HOME/build/cmake

Expand All @@ -123,166 +114,7 @@ echo
if [[ $skip -ne 1 ]] ; then
run_cmd get_catkin_packages $prefix

echo
echo -e '\e[34mApplying patches.\e[39m'
echo

# patch CMakeLists.txt for lz4 library - Build as a library
apply_patch $my_loc/patches/lz4.patch

# patch rosbag_storage - Fix static linking due to missing BZIP2 dependency
apply_patch $my_loc/patches/rosbag_storage.patch

# Patch collada - Build as static lib
apply_patch $my_loc/patches/collada_dom.patch

# Patch assimp - Build as static lib
apply_patch $my_loc/patches/assimp.patch

# Patch console_bridge - Disable unit tests (unsatisfied dependencies)
apply_patch $my_loc/patches/console_bridge.patch

# Patch urdfdom - Build as static lib
apply_patch $my_loc/patches/urdfdom.patch

# Patch qhull - Don't install shared libraries
# TODO: Remove shared libraries to avoid hack in parse_libs.py
# apply_patch /opt/roscpp_android/patches/qhull.patch

# Patch bfl - Build as static lib
apply_patch $my_loc/patches/bfl.patch

# Patch orocos_kdl - Build as static lib
apply_patch $my_loc/patches/orocos_kdl.patch

# Patch PCL - Disable optionals.
apply_patch $my_loc/patches/pcl-1.8.1.patch

# Patch uuid - Avoiding stdlib.h include
apply_patch $my_loc/patches/uuid.patch

# Patch yaml - Avoid building tests
apply_patch $my_loc/patches/yaml-cpp.patch

# Patch bullet - Avoid building examples
apply_patch $my_loc/patches/bullet.patch

## ROS patches

# Patch rosconsole - Add android backend
apply_patch $my_loc/patches/rosconsole.patch

# Patch catkin - Fix transitive linking of interface libraries for static builds
apply_patch $my_loc/patches/catkin.patch

# Patch map_server - Fix find yaml
apply_patch $my_loc/patches/map_server.patch

# Patch bondcpp - Fix transitive linking problems
apply_patch $my_loc/patches/bondcpp.patch

# Patch image_publisher - Fix linking problems, transitive linking,
# and changed shared to static library building.
apply_patch $my_loc/patches/image_publisher.patch

# Patch image_rotate - Fix find opencv and transitive linking problem
apply_patch $my_loc/patches/image_rotate.patch

# Patch opencv - Fix installation path
apply_patch $my_loc/patches/opencv.patch

# Patch actionlib - problems with Boost changes.
apply_patch $my_loc/patches/actionlib.patch

# Patch rospack - problems with Boost changes
# Also emptied some unnecessary functions to avoid problems related to including Python.
apply_patch $my_loc/patches/rospack.patch

# Patch xmlrpcpp - problems with Boost changes.
apply_patch $my_loc/patches/xmlrpcpp.patch

# Patch roslib - weird issue with rospack.
# TODO: Need to look further (only on catkin_make_isolated)
# apply_patch /opt/roscpp_android/patches/roslib.patch

# Patch collada_parser - cmake detects mkstemps even though Android does not support it
# TODO: investigate how to prevent cmake to detect system mkstemps
# apply_patch $my_loc/patches/collada_parser.patch

# Patch laser_assembler - Remove testing for Android
# TODO: It seems like there may be a better way to handle the test issues
# http://stackoverflow.com/questions/22055741/googletest-for-android-ndk
# apply_patch $my_loc/patches/laser_assembler.patch

# Patch laser_filters - Remove testing for Android
# TODO: It seems like there may be a better way to handle the test issues
# http://stackoverflow.com/questions/22055741/googletest-for-android-ndk
# https://source.android.com/reference/com/android/tradefed/testtype/GTest.html
# apply_patch $my_loc/patches/laser_filters.patch

# Patch camera_info_manager - remove testing for Android
# TODO: It seems like there may be a better way to handle the test issues
# http://stackoverflow.com/questions/22055741/googletest-for-android-ndk
# https://source.android.com/reference/com/android/tradefed/testtype/GTest.html
apply_patch $my_loc/patches/camera_info_manager.patch

# Patch camera_calibration_parsers - deleted python things and solved problem finding Boost.
apply_patch $my_loc/patches/camera_calibration_parsers.patch

# Patch cv_bridge - fix transitive linking in cv_bridge-extras.cmake
apply_patch $my_loc/patches/cv_bridge.patch

# Patch theora_image_transport - fix transitive linking
apply_patch $my_loc/patches/theora_image_transport.patch

# Patch robot_pose_ekf - Add bfl library cmake variables, also, remove tests
# TODO: The correct way to handle this would be to create .cmake files for bfl and do a findpackage(orocos-bfl)
# apply_patch $my_loc/patches/robot_pose_ekf.patch

# Patch robot_state_publisher - Add ARCHIVE DESTINATION
# TODO: Create PR to add ARCHIVE DESTINATION
apply_patch $my_loc/patches/robot_state_publisher.patch

# Patch moveit_core - Add fcl library cmake variables
# TODO: The correct way to handle this would be to create .cmake files for fcl and do a findpackage(fcl)
#apply_patch $my_loc/patches/moveit_core.patch

# Patch moveit_core plugins - Add ARCHIVE DESTINATION
# TODO: PR merged: https://github.com/ros-planning/moveit_core/pull/251
# Wait for next release to remove (current 0.6.15)
#apply_patch $my_loc/patches/moveit_core_plugins.patch

# Patch camera_calibration_parsers - Fix yaml-cpp dependency
# TODO: PR created: https://github.com/ros-perception/image_common/pull/36
# apply_patch $my_loc/patches/camera_calibration_parsers.patch

# Patch image_view - Solved YAML linking problems, and transitive linking.
apply_patch $my_loc/patches/image_view.patch

# Patch depth_image_proc - Solved transitive linking problems
apply_patch $my_loc/patches/depth_image_proc.patch

# Patch urdf - Fixed linking with pluginlib and dependencies in downstream packages
apply_patch $my_loc/patches/urdf.patch

# Patch global_planner - Add angles dependency
# TODO: PR merged: https://github.com/ros-planning/navigation/pull/359
# Wait for next release to remove (current 1.12.4)
# apply_patch $my_loc/patches/global_planner.patch

#Patch Poco lib
apply_patch $my_loc/patches/poco.patch

# Plugin specific patches
if [ $use_pluginlib -ne 0 ]; then
# Patch pluginlib for static loading
apply_patch $my_loc/patches/pluginlib.patch
# apply_patch image_transport # to fix faulty export plugins
apply_patch $my_loc/patches/image_transport.patch
fi
Copy link

Choose a reason for hiding this comment

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

This special case is not handled anymore. In combination with do_everything.sh:120ff if use_pluginlib is disabled in config.sh:12, applying the patches would break pluginlib.

The alternative would be to ignore package pluginlib and all its dependees when building with use_pluginlib=0, because the unpatched version would not work anyway on Android if I am not mistaken.

Copy link
Author

Choose a reason for hiding this comment

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

AFAIU the unpatched version won't work; my rationale is that if you don't want pluginlib, applying a few extra packages doesn't add too much overhead, and you won't be able to use pluginlib anyway.

I agree that for correctness we should ignore pluginlib and deps, but on second thought I'd just drop the flag and build pluginlib support always, as it really doesn't add too much build time to the overall, and the flag just adds some more complexity to the scripts. WDYT?

Copy link

Choose a reason for hiding this comment

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

Always building with pluginlib support enabled would be fine for me.


## Demo Application specific patches

run_cmd apply_patches $my_loc/patches/source_patches $prefix
Copy link

Choose a reason for hiding this comment

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

Why the additional subdirectory source_patches? I would just leave them in patches and only move the unused ones to patches/graveyard/ or delete them directly (they can still be found via the Git history).

Copy link
Author

Choose a reason for hiding this comment

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

There's a single patch that has to be applied in a different directory: android.toolchain.cmake.patch; in principle that one has to be in a separate folder.
Perhaps we can move that one to files directory and move all the patches up one level as you propose?

Copy link

Choose a reason for hiding this comment

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

👍

An alternative approach I took in https://github.com/Intermodalics/ros_android_private/pull/17 is to commit a wrapper android.toolchain.cmake (or a template) and apply changes as CMake code after having included the original file, instead of patching the file in the Android NDK installation folder.

Such a custom and, if necessary, generated toolchain file could also replace most of the cmake options passed in build_catkin_workspace.sh:103ff and utils.sh:21 and be exposed to the user to be used in overlay workspaces (installed to target).

fi

# Before build
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.