[EGD-3037] Container build based

This commit is contained in:
Radoslaw Wicik
2020-04-07 10:11:56 +02:00
committed by Radosław Wicik
parent 74aec1aa5a
commit edaaa61baa
13 changed files with 302 additions and 31 deletions

3
.gitignore vendored
View File

@@ -30,4 +30,7 @@ source/version.hpp
**/*.pyc
./doc/docs-gui/
docker/cmake-3.17.0-Linux-x86_64.tar.gz
docker/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
LAST_STEP

View File

@@ -3,9 +3,9 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
include(env.cmake)
project(PurePhone)
include(config/CCacheConfig.cmake)
include(config/ProjectConfig.cmake)
include(config/Version.cmake)
include(config/ModuleConfig.cmake)
@@ -26,6 +26,9 @@ set(CMAKE_CXX_FLAGS_DEBUG "-ggdb3 -O2 -DDEBUG" CACHE STRING "")
set(CMAKE_CXX_FLAGS_RELEASE "-O2" CACHE STRING "")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -ggdb3 -DDEBUG" CACHE STRING "")
set(SERIAL_PORT_PATH "SERIAL_PORT=\"/dev/ttyUSB0\"" CACHE STRING "defines where serial port is")
set(TOOLCHAIN_PATH "" CACHE STRING "Path to coolchain directory")
target_link_directories(${PROJECT_NAME} PUBLIC ${PROJECT_LIB_DIRECTORY})
message("Setting PROJECT_LIB_DIRECTORY to ${PROJECT_LIB_DIRECTORY}")

View File

@@ -1,6 +1,22 @@
PurePhone repository
====================
# Quickstart in docker
You can build project in docker container, to that
### Get docker
`./config/bootstrap.sh 8`
### configure for linux Debug
`./in_docker.sh config linux Debug`
### build linux Debug
`./in_docker.sh make build-linux-Debug`
### build rt1051 Release
`./in_docker.sh config rt1051 Release`
`./in_docker.sh make build-rt1051-Release`
# Quickstart
Prior to any build setup environment, need to be run once. (See: `## Run provisioning`)
@@ -17,7 +33,7 @@ If this is new checkout you need to update your git config (step 0 and 1).
* `./config/bootstrap.sh 5` - list of commands for required for switching default gcc/g++ to version 9
* `./config/bootstrap.sh 6` - adds Paths for arm toolchain to your PATH environment variable - this is also used by ./env.cmake
* `./config/bootstrap.sh 7` - adds Paths for cmake to your PATH environment variable
* `./config/bootstrap.sh 8` - setup cmake.env
* `./config/bootstrap.sh 8` - install docker
*6 add_to_path gcc_arm... is required because new ./env.cmake uses environment variables set by this target.*

View File

@@ -7,15 +7,19 @@ set(TOOLCHAIN_PREFIX "arm-none-eabi")
# specify the cross compiler
if(WIN32)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-gcc.exe CACHE INTERNAL "")
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-g++.exe CACHE INTERNAL "")
set(CMAKE_STRIP ${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-strip.exe CACHE INTERNAL "")
set(CMAKE_OBJCOPY ${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-objcopy.exe CACHE INTERNAL "")
set(CMAKE_C_COMPILER ${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-gcc.exe CACHE INTERNAL "")
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-g++.exe CACHE INTERNAL "")
set(CMAKE_STRIP ${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-strip.exe CACHE INTERNAL "")
set(CMAKE_OBJCOPY ${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-objcopy.exe CACHE INTERNAL "")
else()
set(CMAKE_C_COMPILER ${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-gcc CACHE INTERNAL "")
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-g++ CACHE INTERNAL "")
set(CMAKE_STRIP ${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-strip CACHE INTERNAL "")
set(CMAKE_OBJCOPY ${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-objcopy CACHE INTERNAL "")
#make shure that if TOOLCHAIN_PATH exists finishes with /
if (${TOOLCHAIN_PATH})
string(APPEND ${TOOLCHAIN_PATH} "/")
endif()
set(CMAKE_C_COMPILER ${TOOLCHAIN_PATH}${TOOLCHAIN_PREFIX}-gcc CACHE INTERNAL "")
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PATH}${TOOLCHAIN_PREFIX}-g++ CACHE INTERNAL "")
set(CMAKE_STRIP ${TOOLCHAIN_PATH}${TOOLCHAIN_PREFIX}-strip CACHE INTERNAL "")
set(CMAKE_OBJCOPY ${TOOLCHAIN_PATH}${TOOLCHAIN_PREFIX}-objcopy CACHE INTERNAL "")
endif()
set(LDSCRIPTSDIR "${CMAKE_CURRENT_LIST_DIR}/board/rt1051/ldscripts" CACHE INTERNAL "")

View File

@@ -0,0 +1,5 @@
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif(CCACHE_FOUND)

View File

@@ -9,17 +9,10 @@
# it's support is added to default ccache
# packages settings
ARM_GCC="gcc-arm-none-eabi-9-2019-q4-major"
ARM_GCC_PACKAGE_FILE="${ARM_GCC}-x86_64-linux.tar.bz2"
ARM_GCC_SOURCE_LINK="https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2?revision=108bd959-44bd-4619-9c19-26187abf5225&la=en&hash=E788CE92E5DFD64B2A8C246BBA91A249CB8E2D2D"
ARM_GCC_PATH_VAR="${ARM_GCC//-/_}"
CMAKE_DIR="cmake-3.17.0-Linux-x86_64"
CMAKE_SOURCE_LINK="https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0-Linux-x86_64.tar.gz"
CMAKE_PKG="${CMAKE_DIR}.tar.gz"
CMAKE_PATH_VAR=${CMAKE_DIR//[-.]/_}
SCRIPT=$(readlink -f $0)
SCRIPT_DIR="$(dirname ${SCRIPT})"
. ${SCRIPT_DIR}/bootstrap_config
function printVar(){
echo "$1: '${!1}'"
@@ -131,9 +124,20 @@ function setup_cmake() {
echo "CMAKEV installed to ${HOME}/${CMAKE_DIR} and set in PATH"
}
function setup_env_cmake() {
echo -e "\e[32m${FUNCNAME[0]}\e[0m"
cat env.cmake.sample | sed "s:<ARM_GCC_HOME>:${HOME}/${ARM_GCC}/bin:" > env.cmake
function install_docker() {
if [[ -n $(command -v docker) ]]; then
TESTED_VERSION="19.03.8"
DOCKER_VERSION=$(docker version -f '{{.Server.Version}}')
if [[ ${TESTED_VERSION} != ${DOCKER_VERSION} ]]; then
echo -e "Tested with docker ${DOCKER_VERSION} your is ${DOCKER_VERSION} consider updating"
else
echo "Docker already installed"
fi
else
curl -fsSL https://get.docker.com -o /tmp/get-docker.sh
sudo sh /tmp/get-docker.sh
fi
}
@@ -146,7 +150,7 @@ BUILD_STEPS=(
setup_gcc_alternatives
"add_to_path ${ARM_GCC_PATH_VAR} ${HOME}/${ARM_GCC}/bin"
"add_to_path ${CMAKE_PATH_VAR} ${HOME}/${CMAKE_DIR}/bin"
"setup_env_cmake"
install_docker
)

13
config/bootstrap_config Normal file
View File

@@ -0,0 +1,13 @@
# configuration variables used by bootstrap and dockerbuilder
ARM_GCC="gcc-arm-none-eabi-9-2019-q4-major"
ARM_GCC_PACKAGE_FILE="${ARM_GCC}-x86_64-linux.tar.bz2"
ARM_GCC_SOURCE_LINK="https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2?revision=108bd959-44bd-4619-9c19-26187abf5225&la=en&hash=E788CE92E5DFD64B2A8C246BBA91A249CB8E2D2D"
ARM_GCC_PATH_VAR="${ARM_GCC//-/_}"
CMAKE_DIR="cmake-3.17.0-Linux-x86_64"
CMAKE_SOURCE_LINK="https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0-Linux-x86_64.tar.gz"
CMAKE_PKG="${CMAKE_DIR}.tar.gz"
CMAKE_PATH_VAR=${CMAKE_DIR//[-.]/_}

38
config/download_assets Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
# packages settings
function printVar(){
echo "$1: '${!1}'"
}
SCRIPT=$(readlink -f $0)
SCRIPT_DIR="$(dirname ${SCRIPT})"
. ${SCRIPT_DIR}/bootstrap_config
SRC_ROOT=$(readlink -f ${SCRIPT_DIR}/..)
DEST_DIR="${SRC_ROOT}/docker"
printVar SCRIPT
printVar SCRIPT_DIR
printVar SRC_ROOT
printVar DEST_DIR
function get_arm_toolchain() {
echo -e "\e[32m${FUNCNAME[0]}\e[0m"
echo "Download armgcc"
[[ ! -f $ARM_GCC ]] &&
wget --no-verbose --show-progress -O ${ARM_GCC_PACKAGE_FILE} ${ARM_GCC_SOURCE_LINK}
}
function get_cmake() {
echo -e "\e[32m${FUNCNAME[0]}\e[0m"
[[ ! -f ${CMAKE_DIR}.tgz ]] &&
wget --no-verbose -O ${CMAKE_PKG} ${CMAKE_SOURCE_LINK}
}
pushd ${DEST_DIR}
get_arm_toolchain
get_cmake
popd

View File

@@ -72,7 +72,7 @@ function check_systemview() {
*)
echo "wrong systemview option \"${SYSTEMVIEW}\" using default OFF"
SYSTEMVIEW="OFF"
return 0;;
return 1;;
esac
}
@@ -80,14 +80,18 @@ if [[ $# > 3 || $# < 2 ]]; then
help
exit 1
fi
test_env.cmake
#test_env.cmake
TARGET=$1
BUILD_TYPE=$2
SYSTEMVIEW=$3
if check_target && check_build_type ; then
check_systemview
shift 2
SYSTEMVIEW=$1
if check_systemview ; then
shift
fi
BUILD_DIR="build-${TARGET,,}-${CMAKE_BUILD_TYPE}"
echo -e "build dir:\e[34m\n\t${BUILD_DIR}\e[0m"
SRC_DIR=`pwd`
@@ -104,7 +108,7 @@ if check_target && check_build_type ; then
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DCMAKE_TOOLCHAIN_FILE=${SRC_DIR}/${CMAKE_TOOLCHAIN_FILE} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 ${SRC_DIR} \
-DSYSTEMVIEW=${SYSTEMVIEW} "
-DSYSTEMVIEW=${SYSTEMVIEW} $@"
echo -e "\e[32m${CMAKE_CMD}\e[0m" | tr -s " "
if $CMAKE_CMD; then
echo -e "\e[32mcd ${BUILD_DIR} && make -j\e[0m"

95
docker/.bashrc Normal file
View File

@@ -0,0 +1,95 @@
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
RED='\e[38;2;255;13;0m'
YELLOW="\e[38;2;255;232;0m"
BLUE="\e[38;2;20;5;210m"
GREEN="\e[38;2;0;222;27m"
ORANGE="\e[38;2;255;100;0m"
function host_color(){
echo -en "${YELLOW}"
}
function dir_color(){
echo -en "${GREEN}"
}
function git_color(){
echo -en "${ORANGE}"
}
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWDIRTYSTATE=1
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
export gcc_arm_none_eabi_9_2019_q4_major_PATH="/usr/local/gcc-arm-none-eabi-9-2019-q4-major/bin"
PATH="${gcc_arm_none_eabi_9_2019_q4_major_PATH:+${gcc_arm_none_eabi_9_2019_q4_major_PATH}:}${PATH}"
export cmake_3_17_0_Linux_x86_64_PATH="/usr/local/cmake-3.17.0-Linux-x86_64/bin"
PATH="${cmake_3_17_0_Linux_x86_64_PATH:+${cmake_3_17_0_Linux_x86_64_PATH}:}${PATH}"
export PATH
PS1='\[\e[0m\]\n\[$(host_color)\]@pure_phone_builder \[$(dir_color)\]: \w \[\e[0m\]\[\e[33m\]$(__git_ps1 "${ORANGE}: %s")\[\e[0m\]\n\$'
export PS1

28
docker/Dockerfile Normal file
View File

@@ -0,0 +1,28 @@
FROM ubuntu:eoan
MAINTAINER radoslaw.wicik@mudiata.com
# basic build system for PurePhoneOs
ADD gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 /usr/local/
ADD cmake-3.17.0-Linux-x86_64.tar.gz /usr/local/
RUN apt-get update && \
apt-get full-upgrade -y && \
apt-get install -y \
binutils \
wget \
git \
make \
pkg-config \
gtkmm-3.0 \
gcc-9 \
g++-9 \
portaudio19-dev \
build-essential \
vim \
bash-completion
ADD .bashrc /home/docker/
ENV PATH="/usr/local/cmake-3.17.0-Linux-x86_64/bin:/usr/local/gcc-arm-none-eabi-9-2019-q4-major/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
ENV TERM="xterm-256color"

59
in_docker.sh Executable file
View File

@@ -0,0 +1,59 @@
#!/bin/bash
CONTAINER_NAME=rwicik/pure_phone_build
CONTAINER_TAG=latest
CONTAINER=${CONTAINER_NAME}:${CONTAINER_TAG}
PURE_HOME="/home/PurePhone"
STANDARD_OPTIONS="-v `pwd`:${PURE_HOME} --user \"$(id -u):$(id -g)\" -t"
RCFILE="/home/docker/.bashrc"
if [[ $BASH_VERSINFO -lt 4 ]]; then
echo "Please update your bash to at last version 4"
echo "your is: ${BASH_VERSINFO}"
exit 4
fi
function help() {
cat <<- MSGEND
This scripts runs configuration and build in docker container.
You don't have to setup entire build environment, just use container.
Ussage:
${0} login|config|make [addiotional options]
login - login to build container - usually not needed
config <target> <build_type> [OPTIONS] - run ./configure.sh in container
<target> and <build_type> are required
OPTIONS are passed to cmake as is
run '${0} config' without params to see details
make <build_directory> [OPTIONS] - run 'make' in container. You have to pass directory
creted by '${0} config' command.
you can pass additional arguments for make linke '-j' or 'VERBOSE=1'
MSGEND
exit 0
}
TARGET=$1
shift
case ${TARGET} in
"login")
CMD="docker run ${STANDARD_OPTIONS} -w ${PURE_HOME} -it ${CONTAINER} /bin/bash --rcfile ${RCFILE}"
;;
"config")
CMD="docker run ${STANDARD_OPTIONS} -w ${PURE_HOME} ${CONTAINER} ./configure.sh $@"
;;
"make")
BUILD_DIR=$1
shift
CMD="docker run ${STANDARD_OPTIONS} -w ${PURE_HOME}/${BUILD_DIR} ${CONTAINER} make -j $@"
;;
*)
help
;;
esac
echo ${CMD}
eval ${CMD}

3
run.sh
View File

@@ -1,4 +1,3 @@
#!/bin/bash -e
[[ -e $1 ]] || ( echo "ERROR: Provide proper folder with PurePhone.elf to load"; exit 1)
make -C $1 -j 4 && \
~/gcc-arm-none-eabi-8-2019-q3-update/bin/arm-none-eabi-gdb-py $1/PurePhone.elf -x .gdbinit-1051
arm-none-eabi-gdb-py $1/PurePhone.elf -x .gdbinit-1051