Skip to content

Commit 40ae07a

Browse files
jacobperronivanpauno
authored andcommitted
Update build instructions in README and CI
* Cherry-pick upstream ros2-java#119 - Updates build instructions in README - Update CI for desktop - Add CI for Android - Minor patches to code for Android * Switch to latest release of ros-tooling GitHub actions.
1 parent 6b63f95 commit 40ae07a

File tree

3 files changed

+99
-1
lines changed

3 files changed

+99
-1
lines changed

.github/workflows/build_and_test.yml

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,77 @@ jobs:
1111
sudo apt update -qq
1212
sudo apt install -y default-jdk
1313
- uses: actions/checkout@v2
14-
- uses: ros-tooling/setup-ros@master # using master, until a released version supports rolling
14+
- uses: ros-tooling/setup-ros@0.1.0
1515
with:
1616
required-ros-distributions: rolling
1717
- uses: ros-tooling/action-ros-ci@master
1818
with:
1919
package-name: rosidl_generator_java rcljava_common rcljava
2020
target-ros2-distro: rolling
2121
vcs-repo-file-url: ${{ github.workspace }}/ros2_java_desktop.repos
22+
23+
build_android:
24+
runs-on: ubuntu-18.04
25+
steps:
26+
- name: Install Java
27+
run: |
28+
sudo apt-get update -qq
29+
sudo apt-get install -y default-jdk gradle
30+
- uses: actions/checkout@v2
31+
- name: Setup locale for ROS 2
32+
run: |
33+
sudo locale-gen en_US en_US.UTF-8
34+
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
35+
export LANG=en_US.UTF-8
36+
- name: Setup sources for ROS 2
37+
run: |
38+
sudo apt-get update && sudo apt-get install -y curl gnupg2 lsb-release
39+
curl -sL https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
40+
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-latest.list'
41+
- name: Install ROS 2 dependencies
42+
run: |
43+
sudo apt-get update && sudo apt-get install -y python3-colcon-common-extensions python3-vcstool python3-lark-parser python3-dev
44+
- name: Install colcon extensions for Gradle
45+
run: |
46+
sudo pip3 install git+git://github.com/colcon/colcon-gradle.git
47+
sudo pip3 install git+git://github.com/colcon/colcon-ros-gradle.git
48+
- name: Install Android NDK
49+
run: |
50+
curl -LO https://dl.google.com/android/repository/android-ndk-r21d-linux-x86_64.zip
51+
unzip android-ndk-r21d-linux-x86_64.zip
52+
- name: Setup workspace with VCS repo file
53+
run: |
54+
mkdir -p ros2_java_ws/src
55+
cd ros2_java_ws
56+
curl -sL file://${{ github.workspace }}/ros2_java_android.repos | vcs import src
57+
# Use checked out version of ros2_java
58+
rm -rf src/ros2_java/ros2_java
59+
ln --symbolic ${{ github.workspace }} src/ros2_java
60+
- name: Build ros2_java for Android
61+
run: |
62+
export PYTHON3_EXEC="$( which python3 )"
63+
export PYTHON3_LIBRARY="$( ${PYTHON3_EXEC} -c 'import os.path; from distutils import sysconfig; print(os.path.realpath(os.path.join(sysconfig.get_config_var("LIBPL"), sysconfig.get_config_var("LDLIBRARY"))))' )"
64+
export PYTHON3_INCLUDE_DIR="$( ${PYTHON3_EXEC} -c 'from distutils import sysconfig; print(sysconfig.get_config_var("INCLUDEPY"))' )"
65+
export ANDROID_ABI=armeabi-v7a
66+
export ANDROID_NATIVE_API_LEVEL=android-21
67+
export ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-clang
68+
export ANDROID_NDK=${PWD}/android-ndk-r21d
69+
70+
cd ros2_java_ws
71+
colcon build \
72+
--packages-ignore cyclonedds rcl_logging_log4cxx rosidl_generator_py \
73+
--packages-up-to rcljava \
74+
--cmake-args \
75+
-DPYTHON_EXECUTABLE=${PYTHON3_EXEC} \
76+
-DPYTHON_LIBRARY=${PYTHON3_LIBRARY} \
77+
-DPYTHON_INCLUDE_DIR=${PYTHON3_INCLUDE_DIR} \
78+
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
79+
-DANDROID_FUNCTION_LEVEL_LINKING=OFF \
80+
-DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL} \
81+
-DANDROID_TOOLCHAIN_NAME=${ANDROID_TOOLCHAIN_NAME} \
82+
-DANDROID_STL=c++_shared \
83+
-DANDROID_ABI=${ANDROID_ABI} \
84+
-DANDROID_NDK=${ANDROID_NDK} \
85+
-DTHIRDPARTY=ON \
86+
-DCOMPILE_EXAMPLES=OFF \
87+
-DCMAKE_FIND_ROOT_PATH="${PWD}/install"

rcljava/src/test/java/org/ros2/rcljava/node/NodeTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ public static void setupOnce() throws Exception {
108108
org.apache.log4j.BasicConfigurator.configure();
109109

110110
RCLJava.rclJavaInit();
111+
try
112+
{
113+
// Configure log4j. Doing this dynamically so that Android does not complain about missing
114+
// the log4j JARs, SLF4J uses Android's native logging mechanism instead.
115+
Class c = Class.forName("org.apache.log4j.BasicConfigurator");
116+
Method m = c.getDeclaredMethod("configure", (Class<?>[]) null);
117+
Object o = m.invoke(null, (Object[]) null);
118+
}
119+
catch (Exception e)
120+
{
121+
e.printStackTrace();
122+
}
111123
}
112124

113125
public class TestConsumer<T> implements Consumer<T> {

ros2_java_android.repos

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ repositories:
8787
type: git
8888
url: https://github.com/ros2/rmw.git
8989
version: dashing
90+
ros2/rmw_connext:
91+
type: git
92+
url: https://github.com/ros2/rmw_connext.git
93+
version: dashing
94+
ros2/rmw_cyclonedds:
95+
type: git
96+
url: https://github.com/ros2/rmw_cyclonedds.git
97+
version: dashing-eloquent
9098
ros2/rmw_fastrtps:
9199
type: git
92100
url: https://github.com/ros2/rmw_fastrtps.git
@@ -95,6 +103,10 @@ repositories:
95103
type: git
96104
url: https://github.com/ros2/rmw_implementation.git
97105
version: dashing
106+
ros2/rmw_opensplice:
107+
type: git
108+
url: https://github.com/ros2/rmw_opensplice.git
109+
version: dashing
98110
ros2/rosidl:
99111
type: git
100112
url: https://github.com/ros2/rosidl.git
@@ -115,10 +127,18 @@ repositories:
115127
type: git
116128
url: https://github.com/ros2/rosidl_typesupport.git
117129
version: dashing
130+
ros2/rosidl_typesupport_connext:
131+
type: git
132+
url: https://github.com/ros2/rosidl_typesupport_connext.git
133+
version: dashing
118134
ros2/rosidl_typesupport_fastrtps:
119135
type: git
120136
url: https://github.com/ros2/rosidl_typesupport_fastrtps.git
121137
version: dashing
138+
ros2/rosidl_typesupport_opensplice:
139+
type: git
140+
url: https://github.com/ros2/rosidl_typesupport_opensplice.git
141+
version: dashing
122142
ros2/test_interface_files:
123143
type: git
124144
url: https://github.com/ros2/test_interface_files.git

0 commit comments

Comments
 (0)