diff --git a/README.md b/README.md index 4e747a4..610aced 100644 --- a/README.md +++ b/README.md @@ -22,30 +22,43 @@ Besides dependencies included in trusty, we need vala >= 0.24, which you can get from the [vala-team PPA](https://launchpad.net/~vala-team/+archive/ubuntu/ppa), and libgrx which is part of the ev3dev package repository. -## Compiling -To get something usable on the EV3 brick, you should compile using [brickstrap]. +## Get the code + +This project uses git and git submodules. + + git clone --recursive git://github.com/ev3dev/ev3devKit + + +## Cross-compiling for the EV3 + +This requires that you have [Docker](https://www.docker.com) installed. + + cd ev3devKit + ./docker/setup.sh $BUILD_DIR $ARCH + docker exec --tty ev3devkit_$ARCH make install + +Substitute any directory you like for `$BUILD_DIR` this is where the compiled +files will be stored. The directory will be created if it does not exist. +Substitute `$ARCH` with `armel` for the EV3 or `armhf` for RPi/BeagleBone. +When the build is completed, copy the files from `$BUILD_DIR/dist` to your EV3. + + +## Compiling for desktop # include install build depends $ sudo apt-get install cmake valac libgirepository1.0-dev \ - libgudev-1.0-dev libncurses5-dev libgrx-dev - # if you are building for desktop (see below) you also need - $ sudo apt-get install libgtk-3-dev - # clone the git repo - $ git clone --recursive git://github.com/ev3dev/ev3devKit + libgudev-1.0-dev libncurses5-dev libgrx-dev libgtk-3-dev # create a build directory (not in cloned ev3devKit directory). $ mkdir build $ cd build - $ cmake ../ev3devKit + $ cmake ../ev3devKit -DCMAKE_BUILD_TYPE=string:Debug -DEV3DEVKIT_DESKTOP=bool:Yes $ make You can add additional build option to the `cmake` command. Note: you need to delete *everything* in the build directory when changing `cmake` options to -ensure that they take effect (you can use `nuke.sh` to do this). +ensure that they take effect. -* Enable debugging: `-DCMAKE_BUILD_TYPE=string:Debug` -* Build additional library for running on a desktop: `-DEV3DEVKIT_DESKTOP=bool:Yes` -* Do not build the demo programs: `-EV3DEVKIT_BUILD_DEMO=bool:No` ## Running diff --git a/docker/armel.dockerfile b/docker/armel.dockerfile new file mode 100644 index 0000000..ab3a423 --- /dev/null +++ b/docker/armel.dockerfile @@ -0,0 +1,11 @@ +FROM ev3dev/debian-jessie-armel-cross + +RUN sudo apt-get update && \ + DEBIAN_FRONTEND=noninteractive sudo apt-get install --yes --no-install-recommends \ + cmake \ + libgirepository1.0-dev \ + libgrx-dev \ + libgudev-1.0-dev \ + libgudev-1.0-dev \ + libncurses5-dev \ + valac diff --git a/docker/armhf.dockerfile b/docker/armhf.dockerfile new file mode 100644 index 0000000..519f56d --- /dev/null +++ b/docker/armhf.dockerfile @@ -0,0 +1,11 @@ +FROM ev3dev/debian-jessie-armhf-cross + +RUN sudo apt-get update && \ + DEBIAN_FRONTEND=noninteractive sudo apt-get install --yes --no-install-recommends \ + cmake \ + libgirepository1.0-dev \ + libgrx-dev \ + libgudev-1.0-dev \ + libgudev-1.0-dev \ + libncurses5-dev \ + valac diff --git a/docker/setup.sh b/docker/setup.sh new file mode 100755 index 0000000..efd2466 --- /dev/null +++ b/docker/setup.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +set -e + +script_dir=$(dirname $(readlink -f "$0")) + +build_dir="$1" +if [ ! -n "$build_dir" ]; then + echo "Error: Must specify build directory" + exit 1 +fi + +case $2 in + armel|armhf) + arch=$2 + ;; + *) + echo "Error: Must specify 'armel' or 'armhf'" + exit 1 + ;; +esac + +if ! which docker >/dev/null; then + echo "Error: Docker is not installed" + exit 1 +fi + +image_name="ev3devkit-$arch" +container_name="ev3devkit_$arch" + +docker build \ + --tag $image_name \ + --no-cache \ + --file "$script_dir/$arch.dockerfile" \ + "$script_dir/" +mkdir -p $build_dir + +docker rm --force $container_name >/dev/null 2>&1 || true +docker run \ + --volume "$build_dir:/build" \ + --volume "$(pwd):/src" \ + --workdir /build \ + --name $container_name \ + --env "TERM=$TERM" \ + --env "DESTDIR=/build/dist" \ + --tty \ + --detach \ + $image_name tail + +docker exec --tty $container_name cmake /src -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_TOOLCHAIN_FILE=/opt/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/toolchain.cmake + +echo "Done. You can now compile by running 'docker exec --tty $container_name make'"