Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strip base images and build speed up #46

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 0 additions & 92 deletions .gitlab-ci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ before_script:
fi

script:
- ./cicd/run build -d $DISTRO -p --build-type=${BUILD_TYPE} --tests=$TESTS haya
- ./cicd/run build -d $DISTRO -p --build-type=${BUILD_TYPE} --tests=$TESTS --timeout=2400 haya
- |
if [ $DISTRO == "ubuntu" ]; then
./cicd/run build -d $DISTRO -i mixbytes/haya:$TRAVIS_BRANCH haya
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ else() # Apple AND UNIX
if( APPLE )
# Apple Specific Options Here
message( STATUS "Configuring EOSIO on OS X" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-deprecated-declarations" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-deprecated-declarations" )
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

else() # UNIX
# Linux Specific Options Here
message( STATUS "Configuring EOSIO on Linux" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall" )
if ( FULL_STATIC_BUILD )
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc")
endif ( FULL_STATIC_BUILD )
Expand Down
12 changes: 4 additions & 8 deletions cicd/Dockerfile-centos-tools
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,16 @@ LABEL author="Andrey Levkin <[email protected]>" \
version="0.1.0" \
description="Base image for building Haya on CentOS"

COPY . /var/src/${project_name}
COPY ./scripts /var/src/${project_name}/scripts

WORKDIR /var/src/${project_name}

RUN yum -y update && \
yum -y --enablerepo=extras install centos-release-scl && \
yum install -y epel-release && \
yum update -y --enablerepo=epel && \
yum install -y devtoolset-7 git rpm-build ccache \
autoconf automake libtool make bzip2 doxygen graphviz \
bzip2-devel openssl-devel gmp-devel \
ocaml libicu-devel python python-devel python33 \
gettext-devel file sudo libusbx-devel libcurl-devel && \
git submodule update --init --recursive && \
yum install -y git curl sudo ccache && \
cd scripts && \
bash ${project_name}_build.sh -y -t && \
rm -rf /var/src && rm -rf /var/cache/*
yum clean all && \
rm -rf /var/src && rm -rf /var/cache/* && rm -rf /root/src
11 changes: 4 additions & 7 deletions cicd/Dockerfile-ubuntu-tools
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@ LABEL author="Andrey Levkin <[email protected]>" \
version="0.1.0" \
description="Base image for building Haya on Ubuntu"

COPY . /var/src/${project_name}
COPY ./scripts /var/src/${project_name}/scripts

WORKDIR /var/src/${project_name}

RUN apt-get update && \
apt-get install -y \
sudo git ccache llvm-4.0 clang-4.0 libclang-4.0-dev make automake libbz2-dev libssl-dev doxygen graphviz \
libgmp3-dev autotools-dev build-essential libicu-dev python2.7 python2.7-dev python3 python3-dev \
autoconf libtool curl zlib1g-dev sudo ruby libusb-1.0-0-dev libcurl4-gnutls-dev pkg-config && \
git submodule update --init --recursive && \
apt-get install -y git curl sudo ccache && \
cd scripts && \
bash ${project_name}_build.sh -y -t && \
rm -rf /var/src && rm -rf /var/cache
rm -rf /var/src && rm -rf /var/cache && \
rm -rf /var/lib/apt/lists/* && rm -rf /root/src
8 changes: 7 additions & 1 deletion cicd/build-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ cp -arf ${SRC_DIR}/${PROJECT_NAME} ${BUILD_DIR}/${PROJECT_NAME}
cd "${BUILD_DIR}/${PROJECT_NAME}"
#git submodule update --init --recursive
cd scripts
./${PROJECT_NAME}_build.sh -y -f -o ${BUILD_TYPE}
./${PROJECT_NAME}_build.sh -y -f -n -o ${BUILD_TYPE}

if [ -x $(command -v ccache) ]; then
echo "================CCACHE================="
ccache -s
echo "======================================="
fi

if [ $TESTS ]; then
if [ $DIST == "centos" ]; then
Expand Down
11 changes: 10 additions & 1 deletion cicd/run
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ProgName="./cicd/run"
GIT_TAG=$(git describe --tags --abbrev=1)
BUILD_DIR=build
CACHE_DIR=${CCACHE_DIR:-$HOME/.ccache}
_BUILD_TYPE="Release"
_BUILD_TYPE="RelWithDebInfo"

#SHELL=$3

Expand Down Expand Up @@ -46,6 +46,7 @@ function sub_help(){
echo " -d target platform {ubuntu,centos}"
echo " --build-type build type {Debug,Release,RelWithDebInfo}"
echo " --tests unit tests regex pattern"
echo " --timeout build timeout in seconds"
echo ""
echo "Example:"
echo "# Build toolchain and project package for Ubuntu"
Expand Down Expand Up @@ -112,6 +113,9 @@ function sub_build(){
build-type*)
_BUILD_TYPE=$LONG_OPTARG
;;
timeout*)
_TIMEOUT=$LONG_OPTARG
;;
'')
break
;;
Expand Down Expand Up @@ -144,6 +148,11 @@ function sub_build(){
echo "Building ${_PROJECT_NAME} and create package for ${_DIST}"
local _command="/mnt/src/${_PROJECT_NAME}/cicd/build-in-docker.sh ${_PROJECT_NAME} ${_DIST} ${_BUILD_TYPE} ${_TESTS}"
local docker_image="${_PROJECT_NAME}-build-tools-${_DIST}:latest"

if [[ $_TIMEOUT ]]; then
_command="timeout $_TIMEOUT $_command"
fi

if [[ login_to_container -eq 1 ]]; then
_command=${_SHELL}
docker_image="ubuntu:18.04"
Expand Down
47 changes: 31 additions & 16 deletions scripts/haya_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,16 @@ export BOOST_VERSION_MAJOR=1
export BOOST_VERSION_MINOR=67
export BOOST_VERSION_PATCH=0
export BOOST_VERSION=${BOOST_VERSION_MAJOR}_${BOOST_VERSION_MINOR}_${BOOST_VERSION_PATCH}
export BOOST_ROOT=${SRC_LOCATION}/boost_${BOOST_VERSION}
export BOOST_SRC=${SRC_LOCATION}/boost_${BOOST_VERSION}
export BOOST_ROOT=${OPT_LOCATION}/boost_${BOOST_VERSION}
export BOOST_LINK_LOCATION=${OPT_LOCATION}/boost
export LLVM_VERSION=release_40
export LLVM_ROOT=${OPT_LOCATION}/llvm
export LLVM_DIR=${LLVM_ROOT}/lib/cmake/llvm
export DOXYGEN_VERSION=1_8_14
export DOXYGEN_ROOT=${SRC_LOCATION}/doxygen-${DOXYGEN_VERSION}
export TINI_VERSION=0.18.0
export CMAKE_CXX_FLAGS=""

# Setup directories
mkdir -p $SRC_LOCATION
Expand Down Expand Up @@ -107,9 +109,10 @@ function usage()

NONINTERACTIVE=0
BUILDTOOLSONLY=0
NOWARNING=0

if [ $# -ne 0 ]; then
while getopts ":cdo:s:ahytf" opt; do
while getopts ":cdo:s:ahytfn" opt; do
case "${opt}" in
o )
options=( "Debug" "Release" "RelWithDebInfo" "MinSizeRel" )
Expand Down Expand Up @@ -152,6 +155,9 @@ if [ $# -ne 0 ]; then
f)
SKIP_DEPS_CHECK=1
;;
n)
NOWARNING=1
;;
\? )
printf "\\nInvalid Option: %s\\n" "-${OPTARG}" 1>&2
usage
Expand All @@ -170,33 +176,42 @@ if [ $# -ne 0 ]; then
done
fi

if [ ! -d "${REPO_ROOT}/.git" ]; then
printf "\\nThis build script only works with sources cloned from git\\n"
printf "Please clone a new haya directory with 'git clone https://github.com/mixbytes/haya --recursive'\\n"
exit 1
fi

cd $REPO_ROOT

STALE_SUBMODS=$(( $(git submodule status --recursive | grep -c "^[+\-]") ))
if [ $STALE_SUBMODS -gt 0 ]; then
printf "\\ngit submodules are not up to date.\\n"
printf "Please run the command 'git submodule update --init --recursive'.\\n"
exit 1
if [ $BUILDTOOLSONLY == 0 ]; then
if [ ! -d "${REPO_ROOT}/.git" ]; then
printf "\\nThis build script only works with sources cloned from git\\n"
printf "Please clone a new haya directory with 'git clone https://github.com/mixbytes/haya --recursive'\\n"
exit 1
fi

STALE_SUBMODS=$(( $(git submodule status --recursive | grep -c "^[+\-]") ))
if [ $STALE_SUBMODS -gt 0 ]; then
printf "\\ngit submodules are not up to date.\\n"
printf "Please run the command 'git submodule update --init --recursive'.\\n"
exit 1
fi
fi

printf "\\nBeginning build version: %s\\n" "${VERSION}"
printf "%s\\n" "$( date -u )"
printf "User: %s\\n" "$( whoami )"
# printf "git head id: %s\\n" "$( cat .git/refs/heads/master )"
printf "Current branch: %s\\n" "$( git rev-parse --abbrev-ref HEAD )"

if [ $BUILDTOOLSONLY == 0 ]; then
printf "Current branch: %s\\n" "$( git rev-parse --abbrev-ref HEAD )"
fi

ARCH=$( uname )
printf "\\nARCHITECTURE: %s\\n" "${ARCH}"

# Find and use existing CMAKE
export CMAKE=$(command -v cmake 2>/dev/null)

if [ "$NOWARNING" == 1 ]; then
CMAKE_CXX_FLAGS="-w"
fi

if [ "$ARCH" == "Linux" ]; then
# Check if cmake is already installed or not and use source install location
if [ -z $CMAKE ]; then export CMAKE=$HOME/bin/cmake; fi
Expand All @@ -223,7 +238,6 @@ if [ "$ARCH" == "Linux" ]; then
FILE="${REPO_ROOT}/scripts/haya_build_centos.sh"
CXX_COMPILER=g++
C_COMPILER=gcc
export PATH=$PATH:/opt/rh/devtoolset-7/root/usr/bin
;;
"elementary OS")
FILE="${REPO_ROOT}/scripts/haya_build_ubuntu.sh"
Expand Down Expand Up @@ -293,7 +307,8 @@ $CMAKE -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" -DCMAKE_CXX_COMPILER="${CXX_COMP
-DCMAKE_C_COMPILER="${C_COMPILER}" -DCORE_SYMBOL_NAME="${CORE_SYMBOL_NAME}" \
-DOPENSSL_ROOT_DIR="${OPENSSL_ROOT_DIR}" -DBUILD_MONGO_DB_PLUGIN=true \
-DENABLE_COVERAGE_TESTING="${ENABLE_COVERAGE_TESTING}" -DBUILD_DOXYGEN="${DOXYGEN}" \
-DCMAKE_INSTALL_PREFIX=$OPT_LOCATION/haya -DENABLE_TX_SPONSORSHIP=1 $LOCAL_CMAKE_FLAGS "${REPO_ROOT}"
-DCMAKE_INSTALL_PREFIX=$OPT_LOCATION/haya -DENABLE_TX_SPONSORSHIP=1 $LOCAL_CMAKE_FLAGS "${REPO_ROOT}" \
-DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better ${CMAKE_CXX_FLAGS}

set +x
if [ $? -ne 0 ]; then exit -1; fi
make -j"${JOBS}"
Expand Down
Loading