-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add soemJavaNativeLibrary and support cross compilation for aarch64 #18
Changes from all commits
09c7709
ad2a54d
e4f03c5
2ce4bef
b1749d0
db43415
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
cmake_minimum_required(VERSION 2.8) | ||
cmake_minimum_required(VERSION 3.5.1) | ||
project(ihmcsoemwrapper) | ||
|
||
add_subdirectory(swig) |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Do not publish to dockerhub | ||
FROM ubuntu:20.04 | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get --yes update \ | ||
&& apt-get --yes install \ | ||
nano \ | ||
git \ | ||
wget \ | ||
curl \ | ||
unzip \ | ||
locales \ | ||
apt-transport-https \ | ||
ca-certificates \ | ||
curl \ | ||
software-properties-common \ | ||
sudo \ | ||
build-essential \ | ||
swig \ | ||
cmake \ | ||
openjdk-17-jdk \ | ||
gcc-aarch64-linux-gnu \ | ||
binutils-aarch64-linux-gnu \ | ||
g++-aarch64-linux-gnu \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN locale-gen en_US.UTF-8 | ||
ENV LANG=en_US.UTF-8 | ||
ENV LANGUAGE=en_US:en | ||
ENV LC_ALL=en_US.UTF-8 | ||
|
||
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 | ||
ENV PATH=$PATH:$JAVA_HOME/bin | ||
|
||
# Installing SOEM | ||
WORKDIR /opt | ||
RUN git clone https://github.com/OpenEtherCATsociety/SOEM.git | ||
WORKDIR /opt/SOEM | ||
RUN mkdir build && cd build | ||
WORKDIR /opt/SOEM/build | ||
RUN cmake -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \ | ||
-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \ | ||
-DCMAKE_FIND_ROOT_PATH=/usr/aarch64-linux-gnu \ | ||
-DCMAKE_PROGRAM_PATH=/usr/aarch64-linux-gnu/bin \ | ||
-DHOST_INSTALL="" -DCMAKE_INSTALL_PREFIX=/usr \ | ||
-DCMAKE_POSITION_INDEPENDENT_CODE=true \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
.. | ||
RUN make | ||
RUN make install | ||
|
||
# Setup a robotlab user as the development user, to avoid using root. | ||
# Allows using sudo with robotlab user without a password. | ||
RUN addgroup robotlab \ | ||
&& adduser --uid 1000 --gid 1000 --home /home/robotlab --disabled-password robotlab \ | ||
&& chown -R robotlab /home/robotlab \ | ||
&& adduser robotlab sudo \ | ||
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers | ||
USER robotlab | ||
WORKDIR /home/robotlab | ||
|
||
RUN mkdir -p /home/robotlab/dev/ihmc-ethercat-master/build | ||
RUN mkdir -p /home/robotlab/dev/ihmc-ethercat-master/src | ||
RUN mkdir -p /home/robotlab/dev/ihmc-ethercat-master/swig | ||
VOLUME /home/robotlab/dev/ihmc-ethercat-master/build | ||
VOLUME /home/robotlab/dev/ihmc-ethercat-master/src | ||
VOLUME /home/robotlab/dev/ihmc-ethercat-master/swig | ||
WORKDIR /home/robotlab/dev/ihmc-ethercat-master | ||
|
||
ENTRYPOINT ["/bin/bash"] | ||
CMD ["build-arm64_cross.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Do not publish to dockerhub | ||
FROM ubuntu:20.04 | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get --yes update \ | ||
&& apt-get --yes install \ | ||
nano \ | ||
git \ | ||
wget \ | ||
curl \ | ||
unzip \ | ||
locales \ | ||
apt-transport-https \ | ||
ca-certificates \ | ||
curl \ | ||
software-properties-common \ | ||
sudo \ | ||
build-essential \ | ||
swig \ | ||
cmake \ | ||
openjdk-17-jdk \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN locale-gen en_US.UTF-8 | ||
ENV LANG=en_US.UTF-8 | ||
ENV LANGUAGE=en_US:en | ||
ENV LC_ALL=en_US.UTF-8 | ||
|
||
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 | ||
ENV PATH=$PATH:$JAVA_HOME/bin | ||
|
||
# Installing SOEM | ||
WORKDIR /opt | ||
RUN git clone https://github.com/OpenEtherCATsociety/SOEM.git | ||
WORKDIR /opt/SOEM | ||
RUN mkdir build && cd build | ||
WORKDIR /opt/SOEM/build | ||
RUN cmake -DHOST_INSTALL="" -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_POSITION_INDEPENDENT_CODE=true -DCMAKE_BUILD_TYPE=Release .. | ||
RUN make | ||
RUN make install | ||
|
||
# Setup a robotlab user as the development user, to avoid using root. | ||
# Allows using sudo with robotlab user without a password. | ||
RUN addgroup robotlab \ | ||
&& adduser --uid 1000 --gid 1000 --home /home/robotlab --disabled-password robotlab \ | ||
&& chown -R robotlab /home/robotlab \ | ||
&& adduser robotlab sudo \ | ||
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers | ||
USER robotlab | ||
WORKDIR /home/robotlab | ||
|
||
RUN mkdir -p /home/robotlab/dev/ihmc-ethercat-master/build | ||
RUN mkdir -p /home/robotlab/dev/ihmc-ethercat-master/src | ||
RUN mkdir -p /home/robotlab/dev/ihmc-ethercat-master/swig | ||
VOLUME /home/robotlab/dev/ihmc-ethercat-master/build | ||
VOLUME /home/robotlab/dev/ihmc-ethercat-master/src | ||
VOLUME /home/robotlab/dev/ihmc-ethercat-master/swig | ||
WORKDIR /home/robotlab/dev/ihmc-ethercat-master | ||
|
||
ENTRYPOINT ["/bin/bash"] | ||
CMD ["build-x86_64.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
export AARCH64_CROSS=1 | ||
|
||
# Build for arm64 | ||
mkdir -p build | ||
cd build | ||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../linux-aarch64-toolchain.cmake .. | ||
make | ||
../gradlew publishToMavenLocal -Ptarget=JAVA | ||
../gradlew publishToMavenLocal -Ptarget=PLATFORM | ||
cd .. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
#!/bin/bash | ||
# Uncomment for debugging this script | ||
set -o xtrace | ||
|
||
#!/bin/sh | ||
# Build for native platform (probably x86_64) | ||
mkdir -p build | ||
cd build | ||
|
||
cmake -DCMAKE_BUILD_TYPE=Release .. | ||
make | ||
|
||
pwd | ||
ls .. | ||
../gradlew publishToMavenLocal -Ptarget=JAVA | ||
../gradlew publishToMavenLocal -Ptarget=PLATFORM | ||
cd .. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
docker build -f Dockerfile-x86_64 -t ihmcrobotics/soem-compile-x86_64:0.1 . | ||
docker build -f Dockerfile-arm64_cross -t ihmcrobotics/soem-compile-arm64_cross:0.1 . |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,49 @@ | ||
#!/bin/bash | ||
# Uncomment for debugging this script | ||
set -o xtrace | ||
#!/bin/sh | ||
rm -rf buildDocker | ||
mkdir -p buildDocker | ||
|
||
# Make sure it works one way or the other to reduce possible errors | ||
if (( EUID == 0 )); then | ||
echo "Run without sudo." 1>&2 | ||
exit 1 | ||
fi | ||
echo "Building soemJava x86_64" | ||
sudo docker run \ | ||
--rm \ | ||
--tty \ | ||
--interactive \ | ||
--network host \ | ||
--dns=1.1.1.1 \ | ||
--volume "$(pwd)/buildDocker":/home/robotlab/dev/ihmc-ethercat-master/build \ | ||
--volume "$(pwd)/src":/home/robotlab/dev/ihmc-ethercat-master/src \ | ||
--volume "$(pwd)/swig":/home/robotlab/dev/ihmc-ethercat-master/swig \ | ||
--volume "$(pwd)/build.gradle.kts":/home/robotlab/dev/ihmc-ethercat-master/build.gradle.kts \ | ||
--volume "$(pwd)/gradle.properties":/home/robotlab/dev/ihmc-ethercat-master/gradle.properties \ | ||
--volume "$(pwd)/settings.gradle.kts":/home/robotlab/dev/ihmc-ethercat-master/settings.gradle.kts \ | ||
--volume "$(pwd)/CMakeLists.txt":/home/robotlab/dev/ihmc-ethercat-master/CMakeLists.txt \ | ||
--volume "$(pwd)/build-x86_64.sh":/home/robotlab/dev/ihmc-ethercat-master/build-x86_64.sh \ | ||
--volume "$(pwd)/gradlew":/home/robotlab/dev/ihmc-ethercat-master/gradlew \ | ||
--volume "$(pwd)/gradle/wrapper":/home/robotlab/dev/ihmc-ethercat-master/gradle/wrapper \ | ||
--volume "$HOME/.m2":/home/robotlab/.m2 \ | ||
ihmcrobotics/soem-compile-x86_64:0.1 | ||
|
||
sleep 1 | ||
rm -rf buildDocker | ||
mkdir -p buildDocker | ||
sleep 1 | ||
|
||
if [ ! "$(sudo -u root docker ps -a | grep ethercat-master)" ]; then | ||
echo "ethercat-master not found. Running new container." | ||
sudo -u root docker run \ | ||
--tty \ | ||
--interactive \ | ||
--name ethercat-master \ | ||
--network host \ | ||
--dns=1.1.1.1 \ | ||
--volume "$(pwd)/buildDocker":/home/robotlab/dev/ihmc-ethercat-master/build \ | ||
--volume "$(pwd)/src":/home/robotlab/dev/ihmc-ethercat-master/src \ | ||
--volume "$(pwd)/swig":/home/robotlab/dev/ihmc-ethercat-master/swig \ | ||
--volume "$(pwd)/build.gradle.kts":/home/robotlab/dev/ihmc-ethercat-master/build.gradle.kts \ | ||
--volume "$(pwd)/gradle.properties":/home/robotlab/dev/ihmc-ethercat-master/gradle.properties \ | ||
--volume "$(pwd)/settings.gradle.kts":/home/robotlab/dev/ihmc-ethercat-master/settings.gradle.kts \ | ||
--volume "$(pwd)/CMakeLists.txt":/home/robotlab/dev/ihmc-ethercat-master/CMakeLists.txt \ | ||
--volume "$(pwd)/build.sh":/home/robotlab/dev/ihmc-ethercat-master/build.sh \ | ||
--volume "$(pwd)/gradlew":/home/robotlab/dev/ihmc-ethercat-master/gradlew \ | ||
--volume "$(pwd)/gradle/wrapper":/home/robotlab/dev/ihmc-ethercat-master/gradle/wrapper \ | ||
ihmcrobotics/ethercat-master:0.2 | ||
else | ||
sudo -u root docker start --attach ethercat-master | ||
fi | ||
echo "Building soemJava arm64 (cross compiling)" | ||
sudo docker run \ | ||
--rm \ | ||
--tty \ | ||
--interactive \ | ||
--network host \ | ||
--dns=1.1.1.1 \ | ||
--volume "$(pwd)/buildDocker":/home/robotlab/dev/ihmc-ethercat-master/build \ | ||
--volume "$(pwd)/src":/home/robotlab/dev/ihmc-ethercat-master/src \ | ||
--volume "$(pwd)/swig":/home/robotlab/dev/ihmc-ethercat-master/swig \ | ||
--volume "$(pwd)/build.gradle.kts":/home/robotlab/dev/ihmc-ethercat-master/build.gradle.kts \ | ||
--volume "$(pwd)/gradle.properties":/home/robotlab/dev/ihmc-ethercat-master/gradle.properties \ | ||
--volume "$(pwd)/settings.gradle.kts":/home/robotlab/dev/ihmc-ethercat-master/settings.gradle.kts \ | ||
--volume "$(pwd)/CMakeLists.txt":/home/robotlab/dev/ihmc-ethercat-master/CMakeLists.txt \ | ||
--volume "$(pwd)/linux-aarch64-toolchain.cmake":/home/robotlab/dev/ihmc-ethercat-master/linux-aarch64-toolchain.cmake \ | ||
--volume "$(pwd)/build-arm64_cross.sh":/home/robotlab/dev/ihmc-ethercat-master/build-arm64_cross.sh \ | ||
--volume "$(pwd)/gradlew":/home/robotlab/dev/ihmc-ethercat-master/gradlew \ | ||
--volume "$(pwd)/gradle/wrapper":/home/robotlab/dev/ihmc-ethercat-master/gradle/wrapper \ | ||
--volume "$HOME/.m2":/home/robotlab/.m2 \ | ||
ihmcrobotics/soem-compile-arm64_cross:0.1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.5.1) | ||
|
||
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) | ||
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) | ||
set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu) | ||
set(CMAKE_PROGRAM_PATH /usr/aarch64-linux-gnu/bin) | ||
|
||
set(ENV{AARCH64_CROSS} "1") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,14 +131,17 @@ The gradle build files for the SOEM wrapper and native libraries are created by | |
|
||
To build and publish run the following commands. Note that the gradle commands are ran from within the build directory. | ||
|
||
|
||
- cd ihmc-ethercat-master | ||
- mkdir build | ||
- cd build | ||
- cmake -DCMAKE_BUILD_TYPE=Release .. | ||
- make | ||
- ../gradlew publishToMavenLocal -Ptarget=JAVA | ||
- ../gradlew publishToMavenLocal -Ptarget=PLATFORM | ||
``` | ||
cd ihmc-ethercat-master | ||
mkdir build | ||
cd build | ||
cmake -DCMAKE_BUILD_TYPE=Release .. | ||
# Cross compile for arm64 using the toolchain | ||
# cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../linux-aarch64-toolchain.cmake .. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this means we need to run this on any arm64 machine? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When running on a native arm platform you don't need to use the cross compilation toolchain |
||
make | ||
../gradlew publishToMavenLocal -Ptarget=JAVA | ||
../gradlew publishToMavenLocal -Ptarget=PLATFORM | ||
``` | ||
|
||
Note that if you want to publish multiple platform libraries you only have to run target=JAVA on a single platform | ||
|
||
|
@@ -149,16 +152,6 @@ Note that if you want to publish multiple platform libraries you only have to ru | |
|
||
### Compiling with Docker | ||
|
||
Run `./buildWithDocker.sh` | ||
|
||
The Docker image is hosted at [https://hub.docker.com/r/ihmcrobotics/ethercat-master](). | ||
|
||
If changes to the Dockerfile are needed, build it with the following command, incrementing the version. | ||
Then, increment the version in the buildWithDocker.sh file before running. | ||
|
||
``` | ||
# docker build --tag ihmcrobotics/ethercat-master:0.X . | ||
# docker rm ethercat-master | ||
``` | ||
Build the docker images first with: `./buildDockerImages.sh` | ||
|
||
For more about IHMC Robotics's usage of Docker, see [https://github.com/ihmcrobotics/ihmc-open-robotics-software/tree/develop/docker](). | ||
Then run: `./buildWithDocker.sh` to build the artifacts, they will be copied to the host's local maven repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will have to publish these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Looks like that's why the checks are failing. Maybe you should go ahead and publish so the tests in the PR pass?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, note that there is 1 failing test on develop already