forked from iNavFlight/inav
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
69 additions
and
27 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
.git/ | ||
.vagrant/ | ||
obj/ | ||
.vscode/ | ||
/build/ | ||
/obj/ | ||
/tools/ | ||
/downloads/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,14 @@ | ||
FROM ubuntu:bionic | ||
FROM ubuntu:focal | ||
|
||
# Configuration | ||
VOLUME /home/src/ | ||
WORKDIR /home/src/ | ||
ARG TOOLCHAIN_VERSION_SHORT | ||
ENV TOOLCHAIN_VERSION_SHORT ${TOOLCHAIN_VERSION_SHORT:-"9-2019q4"} | ||
ARG TOOLCHAIN_VERSION_LONG | ||
ENV TOOLCHAIN_VERSION_LONG ${TOOLCHAIN_VERSION_LONG:-"9-2019-q4-major"} | ||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
# Essentials | ||
RUN mkdir -p /home/src && \ | ||
apt-get update && \ | ||
apt-get install -y software-properties-common ruby make git gcc wget curl bzip2 | ||
|
||
# Toolchain | ||
RUN wget -P /tmp "https://developer.arm.com/-/media/Files/downloads/gnu-rm/$TOOLCHAIN_VERSION_SHORT/gcc-arm-none-eabi-$TOOLCHAIN_VERSION_LONG-x86_64-linux.tar.bz2" | ||
RUN mkdir -p /opt && \ | ||
cd /opt && \ | ||
tar xvjf "/tmp/gcc-arm-none-eabi-$TOOLCHAIN_VERSION_LONG-x86_64-linux.tar.bz2" -C /opt && \ | ||
chmod -R -w "/opt/gcc-arm-none-eabi-$TOOLCHAIN_VERSION_LONG" | ||
|
||
ENV PATH="/opt/gcc-arm-none-eabi-$TOOLCHAIN_VERSION_LONG/bin:$PATH" | ||
RUN apt-get update && apt-get install -y git cmake make ruby gcc | ||
|
||
RUN useradd inav | ||
|
||
USER inav | ||
|
||
VOLUME /src | ||
|
||
WORKDIR /src/build | ||
ENTRYPOINT ["/src/cmake/docker.sh"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,32 @@ | ||
if [ -z "$1" ]; then | ||
echo "Usage syntax: ./build.sh <TARGET>" | ||
set -e | ||
|
||
if [[ $# == 0 ]]; then | ||
echo -e "\ | ||
Usage syntax: ./build.sh <TARGET> | ||
Notes: | ||
* You can specify multiple targets. | ||
* If no targets are specified, *all* of them will be built. | ||
* To clean a target prefix it with \"clean_\". | ||
* To clean all targets just use \"clean\"." | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$(docker images -q inav-build)" ]; then | ||
echo -e "*** Building image\n" | ||
docker build -t inav-build . | ||
echo -ne "\n" | ||
fi | ||
|
||
if [ ! -d ./build ]; then | ||
echo -e "*** Creating build directory\n" | ||
mkdir ./build | ||
fi | ||
|
||
echo -e "*** Building target $1\n" | ||
docker run --rm -v "$(pwd)":/home/src/ inav-build make TARGET="$1" | ||
echo -e "*** Building targets [$@]\n" | ||
docker run --rm -it -v "$(pwd)":/src inav-build $@ | ||
|
||
if ls ./build/*.hex &> /dev/null; then | ||
echo -e "\n*** Built targets in ./build:" | ||
stat -c "%n (%.19y)" ./build/*.hex | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
LAST_CMAKE_AT_REV_FILE="docker_cmake.rev" | ||
CURR_REV="$(git rev-parse HEAD)" | ||
|
||
initialize_cmake() { | ||
echo -e "*** CMake was not initialized yet, doing it now.\n" | ||
cmake .. | ||
echo "$CURR_REV" > "$LAST_CMAKE_AT_REV_FILE" | ||
} | ||
|
||
# Check if CMake has never been initialized | ||
if [ ! -f Makefile ]; then | ||
initialize_cmake | ||
fi | ||
|
||
# Check if CMake was initialized for a different Git revision (new targets may have been added) | ||
if [ -f "$LAST_CMAKE_AT_REV_FILE" ]; then | ||
LAST_CMAKE_AT_REV="$(cat $LAST_CMAKE_AT_REV_FILE)" | ||
if [[ "$LAST_CMAKE_AT_REV" != "SKIP" ]] && [[ "$LAST_CMAKE_AT_REV" != "$CURR_REV" ]]; then | ||
initialize_cmake | ||
fi | ||
else | ||
initialize_cmake | ||
fi | ||
|
||
# Let Make handle the arguments coming from the build script | ||
make "$@" |
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