Merged PR 1045143: Initial implementation of the build system that uses docker for various Linux distros

Initial implementation of the build system that uses docker for various Linux distros.
More distros can be added by implementing a corresponding docker file under /docker/ dir.
We can reuse this approach for "Windows Core" builds and qemu-arm(32|64) builds as well.
Going forward the same approach can be used for Android builds: no need to setup the tools
locally, container would deploy all the tools needed for a build script to run to completion.

Docker-based build script infra is going to be hosted on MS Azure VSO / OneBranch (CDPx).

Related work items: #1035556
This commit is contained in:
Max Golovanov 2019-05-22 22:57:00 +00:00
Родитель 62a0f80f9e
Коммит 4158c67a74
8 изменённых файлов: 143 добавлений и 4 удалений

Просмотреть файл

@ -45,6 +45,19 @@ else()
set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS} -std=c++11 ${DBG_FLAGS}")
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# using Clang
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# using GCC
# Prefer to generate position-independent code
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
# using Intel C++
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# using Visual Studio C++
endif()
include(tools/Utils.cmake)
if (NOT DEFAULT_PAL_IMPLEMENTATION)

25
build-docker.cmd Normal file
Просмотреть файл

@ -0,0 +1,25 @@
@echo off
if "%~1"=="" goto help
del .buildtools 2>NUL
docker info
docker version
set IMAGE_NAME=%1
echo Running in container %IMAGE_NAME%
sc query com.docker.service
echo Building docker image...
docker build --rm -t %IMAGE_NAME% docker/%IMAGE_NAME%
echo Starting build...
docker run -it -v %CD%:/build %IMAGE_NAME% /build/build.sh
exit
:help
echo.
echo Usage: build-docker.cmd [container_name]
echo.
echo Supported containers:
dir /B docker

Просмотреть файл

@ -1,14 +1,15 @@
#!/bin/bash
#!/usr/bin/env bash
cd "$(dirname "$0")"
cd googletest
set -evx
env | sort
mkdir build || true
mkdir -p build || true
cd build
cmake -Dgtest_build_samples=ON \
-Dgmock_build_samples=ON \
-Dgtest_build_tests=ON \
-Dgmock_build_tests=ON \
-DCMAKE_CXX_FLAGS=$CXX_FLAGS \
-DCMAKE_CXX_FLAGS="-fPIC $CXX_FLAGS" \
..
make
CTEST_OUTPUT_ON_FAILURE=1 make test

32
docker/centos7/Dockerfile Normal file
Просмотреть файл

@ -0,0 +1,32 @@
FROM centos:centos7
# Package installation
RUN yum update -y
## Common packages for linux build environment
RUN yum install -y gcc gcc-c++ automake libtool-bin curl libcurl4-openssl-dev zlib1g-dev build-essential libssl-dev clang python pkg-config git curl bzip2 unzip make wget sudo centos-release-scl devtoolset-7 devtoolset-7-valgrind
## Add docker user
RUN useradd -m docker
RUN passwd -d docker
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN echo 'docker ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN mkdir -p /tmp
## RUN mount -t tmpfs -o size=512M tmpfs /tmp
USER docker
RUN echo "scl enable devtoolset-7 bash" >> ~/.bash_profile
RUN sudo yum update -y
## Install cmake3
RUN sudo bash -c 'wget -O /tmp/cmake-3.6.2.tar.gz https://cmake.org/files/v3.6/cmake-3.6.2.tar.gz && \
cd /tmp && \
tar -zxvf cmake-3.6.2.tar.gz && \
cd cmake-3.6.2 && \
./bootstrap --prefix=/usr/local && \
make && \
make install'
CMD /bin/bash
# ENTRYPOINT bash

Просмотреть файл

@ -0,0 +1,23 @@
FROM ubuntu:14.04
ENV DEBIAN_FRONTEND noninteractive
# Package installation
RUN apt-get update
## Common packages for linux build environment
RUN apt install -y clang python pkg-config git curl bzip2 unzip make wget cmake sudo
RUN adduser --disabled-password --gecos '' docker
RUN adduser docker sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
## RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
USER docker
# this is where I was running into problems with the other approaches
RUN sudo apt-get update
CMD /bin/bash
# ENTRYPOINT bash

Просмотреть файл

@ -0,0 +1,23 @@
FROM ubuntu:16.04
ENV DEBIAN_FRONTEND noninteractive
# Package installation
RUN apt-get update
## Common packages for linux build environment
RUN apt install -y clang python pkg-config git curl bzip2 unzip make wget cmake sudo
RUN adduser --disabled-password --gecos '' docker
RUN adduser docker sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
## RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
USER docker
# this is where I was running into problems with the other approaches
RUN sudo apt-get update
CMD /bin/bash
# ENTRYPOINT bash

Просмотреть файл

@ -0,0 +1,23 @@
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND noninteractive
# Package installation
RUN apt-get update
## Common packages for linux build environment
RUN apt install -y clang python pkg-config git curl bzip2 unzip make wget cmake sudo
RUN adduser --disabled-password --gecos '' docker
RUN adduser docker sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
## RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
USER docker
# this is where I was running into problems with the other approaches
RUN sudo apt-get update
CMD /bin/bash
# ENTRYPOINT bash

Просмотреть файл

@ -51,7 +51,6 @@ apt install -y zlib1g-dev
apt install -y git
apt install -y build-essential
apt install -y libssl-dev
apt install -y zlib1g-dev
apt install -y libsqlite3-dev
# Stock sqlite may be too old
#apt install libsqlite3-dev