Skip to content

Commit

Permalink
Configurable CC/CXX compiler toolchain in Dockerfiles. (#1402)
Browse files Browse the repository at this point in the history
Allows to build Docker images with Clang.
  • Loading branch information
MichaelGrupp authored and wally-the-cartographer committed Oct 31, 2018
1 parent 01af348 commit aaa8a9a
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ cache:
- /home/travis/docker/

env:
- LSB_RELEASE=trusty DOCKER_CACHE_FILE=/home/travis/docker/trusty-cache.tar.gz
- LSB_RELEASE=xenial DOCKER_CACHE_FILE=/home/travis/docker/xenial-cache.tar.gz
- LSB_RELEASE=jessie DOCKER_CACHE_FILE=/home/travis/docker/jessie-cache.tar.gz
- LSB_RELEASE=stretch DOCKER_CACHE_FILE=/home/travis/docker/stretch-cache.tar.gz
- LSB_RELEASE=trusty DOCKER_CACHE_FILE=/home/travis/docker/trusty-cache.tar.gz CC=gcc CXX=g++
- LSB_RELEASE=xenial DOCKER_CACHE_FILE=/home/travis/docker/xenial-cache.tar.gz CC=gcc CXX=g++
- LSB_RELEASE=jessie DOCKER_CACHE_FILE=/home/travis/docker/jessie-cache.tar.gz CC=gcc CXX=g++
- LSB_RELEASE=stretch DOCKER_CACHE_FILE=/home/travis/docker/stretch-cache.tar.gz CC=gcc CXX=g++

before_install: scripts/load_docker_cache.sh

install: true
script:
- docker build ${TRAVIS_BUILD_DIR} -t cartographer:${LSB_RELEASE} -f Dockerfile.${LSB_RELEASE}
--build-arg cc=$CC --build-arg cxx=$CXX
- scripts/save_docker_cache.sh
7 changes: 7 additions & 0 deletions Dockerfile.jessie
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@

FROM debian:jessie

ARG cc
ARG cxx

# Set the preferred C/C++ compiler toolchain, if given (otherwise default).
ENV CC=$cc
ENV CXX=$cxx

# This base image doesn't ship with sudo.
RUN apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/*

Expand Down
7 changes: 7 additions & 0 deletions Dockerfile.stretch
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@

FROM debian:stretch

ARG cc
ARG cxx

# Set the preferred C/C++ compiler toolchain, if given (otherwise default).
ENV CC=$cc
ENV CXX=$cxx

# This base image doesn't ship with sudo.
RUN apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/*

Expand Down
8 changes: 8 additions & 0 deletions Dockerfile.trusty
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
# limitations under the License.

FROM ubuntu:trusty

ARG cc
ARG cxx

# Set the preferred C/C++ compiler toolchain, if given (otherwise default).
ENV CC=$cc
ENV CXX=$cxx

COPY scripts/install_debs_cmake.sh cartographer/scripts/
RUN cartographer/scripts/install_debs_cmake.sh && rm -rf /var/lib/apt/lists/*
COPY scripts/install_ceres.sh cartographer/scripts/
Expand Down
8 changes: 8 additions & 0 deletions Dockerfile.trusty.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
# limitations under the License.

FROM ubuntu:trusty

ARG cc
ARG cxx

# Set the preferred C/C++ compiler toolchain, if given (otherwise default).
ENV CC=$cc
ENV CXX=$cxx

COPY scripts/install_debs_bazel.sh cartographer/scripts/
RUN cartographer/scripts/install_debs_bazel.sh && rm -rf /var/lib/apt/lists/*
COPY . cartographer
Expand Down
8 changes: 8 additions & 0 deletions Dockerfile.xenial
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.


FROM ubuntu:xenial

ARG cc
ARG cxx

# Set the preferred C/C++ compiler toolchain, if given (otherwise default).
ENV CC=$cc
ENV CXX=$cxx

# This base image doesn't ship with sudo.
RUN apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/*

Expand Down
1 change: 1 addition & 0 deletions scripts/install_debs_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ else
fi

sudo apt-get install -y \
clang \
g++ \
git \
google-mock \
Expand Down

0 comments on commit aaa8a9a

Please sign in to comment.