Skip to content

Commit

Permalink
Build: restructure build process on Mac to make it more flexible
Browse files Browse the repository at this point in the history
This allows to build BOINC on a Mac CI system as well as on a developers computer. See script headers for documentation.
The short version is:
* run ./3rdParty/buildMacDependencies.sh to compile all dependency libraries into 3rdParty/buildCache/mac (can be configured with --cache_dir)
* run ./mac_build/buildMacBOINC-CI.sh to compile all BOINC components using the build cache (--cache_dir can be used here too)

There are options for building debug versions but they are not very well tested. Currently you can't selectively build single targets using this.
  • Loading branch information
ChristianBeer committed Mar 17, 2017
1 parent aaa0254 commit ab956d8
Show file tree
Hide file tree
Showing 12 changed files with 807 additions and 316 deletions.
140 changes: 140 additions & 0 deletions 3rdParty/buildMacDependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#!/bin/bash

# This file is part of BOINC.
# http://boinc.berkeley.edu
# Copyright (C) 2017 University of California
#
# BOINC is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# BOINC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with BOINC. If not, see <http://www.gnu.org/licenses/>.
#

## support script to build BOINC dependencies on Macintosh
## This script checks if cached versions are available and builts them if not.
## The build is done in 3rdParty/mac and usable files are installed to 3rdParty/buildCache/mac
## in order to keep the cache as small as possible
## The 3rdParty/buildCache directory can be cached by CI systems for all subsequent builds

## This script should do what mac_build/setupForBOINC.sh does but install to 3rdParty/buildCache/mac

## Usage:
## ./3rdParty/buildMacDependencies.sh [--clean] [--cache_dir PATH] [--debug]
##
## --clean will force a full rebuild of the cache.
## --cache_dir must be an absolute path where the libraries are installed to (default: 3rdParty/buildCache/mac)
## ATTENTION: don't set this to /usr or /var this is an internal cache and it should stay in the source path
## --debug will also build the debug versions of wxWidgets and BOINC Manager (Cache will be larger)
##

# checks if a given path is canonical (absolute and does not contain relative links)
# from http://unix.stackexchange.com/a/256437
isPathCanonical() {
case "x$1" in
(x*/..|x*/../*|x../*|x*/.|x*/./*|x./*)
rc=1
;;
(x/*)
rc=0
;;
(*)
rc=1
;;
esac
return $rc
}

# check working directory because the script needs to be called like: ./3rdParty/buildMacDependencies.sh
if [ ! -d "3rdParty" ]; then
echo "start this script in the source root directory"
exit 1
fi

ROOTDIR=$(pwd)
cache_dir=""
doclean=""
wxoption="--nodebug"
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--cache_dir)
cache_dir="$2"
shift
;;
--clean)
doclean="yes"
;;
--debug)
wxoption=""
;;
*)
echo "unrecognized option $key"
;;
esac
shift # past argument or value
done

if [ "x$cache_dir" != "x" ]; then
if isPathCanonical "$cache_dir" && [ "$cache_dir" != "/" ]; then
PREFIX="$cache_dir"
else
echo "cache_dir must be an absolute path without ./ or ../ in it"
exit 1
fi
else
PREFIX="$(pwd)/3rdParty/buildCache/mac"
fi

download_and_build() {
cd "${ROOTDIR}/3rdParty/mac" || exit 1
DIRNAME="${1}"
FILENAME="${2}"
DLURL="${3}"
BUILDSCRIPT="${4}"
FLAGFILE="${PREFIX}/${DIRNAME}_done"
if [ -e "${FLAGFILE}" ]; then
echo "${DIRNAME} seems already to be present in ${PREFIX}"
return 0
fi
if [ ! -d ${DIRNAME} ]; then
if [ ! -e ${FILENAME} ]; then
wget ${DLURL}
fi
tar -xf ${FILENAME}
fi
cd ${DIRNAME} || exit 1
source ${BUILDSCRIPT} --prefix ${PREFIX}
if [ $? -ne 0 ]; then exit 1; fi
cd ../.. || exit 1
touch ${FLAGFILE}
}

mkdir -p 3rdParty/mac
mkdir -p ${PREFIX}
cd "${ROOTDIR}/3rdParty/mac" || exit 1

if [ "${doclean}" = "yes" ]; then
echo "cleaning cache"
rm -rf ${PREFIX}
mkdir -p ${PREFIX}
fi

#download_and_build $DIRNAME $FILENAME $DOWNLOADURL $BUILDSCRIPT
download_and_build "openssl-1.1.0" "openssl-1.1.0.tar.gz" "https://www.openssl.org/source/openssl-1.1.0.tar.gz" "${ROOTDIR}/mac_build/buildopenssl.sh"
download_and_build "c-ares-1.11.0" "c-ares-1.11.0.tar.gz" "http://c-ares.haxx.se/download/c-ares-1.11.0.tar.gz" "${ROOTDIR}/mac_build/buildc-ares.sh"
download_and_build "curl-7.50.2" "curl-7.50.2.tar.gz" "http://curl.haxx.se/download/curl-7.50.2.tar.gz" "${ROOTDIR}/mac_build/buildcurl.sh"
download_and_build "wxWidgets-3.0.0" "wxWidgets-3.0.0.tar.bz2" "http://sourceforge.net/projects/wxwindows/files/3.0.0/wxWidgets-3.0.0.tar.bz2" "${ROOTDIR}/mac_build/buildWxMac.sh ${wxoption}"
download_and_build "sqlite-autoconf-3110000" "sqlite-autoconf-3110000.tar.gz" "http://www.sqlite.org/2016/sqlite-autoconf-3110000.tar.gz" "${ROOTDIR}/mac_build/buildsqlite3.sh"
download_and_build "freetype-2.6.2" "freetype-2.6.2.tar.bz2" "http://sourceforge.net/projects/freetype/files/freetype2/2.6.2/freetype-2.6.2.tar.bz2" "${ROOTDIR}/mac_build/buildfreetype.sh"
download_and_build "ftgl-2.1.3~rc5" "ftgl-2.1.3-rc5.tar.gz" "http://sourceforge.net/projects/ftgl/files/FTGL%20Source/2.1.3%7Erc5/ftgl-2.1.3-rc5.tar.gz" "${ROOTDIR}/mac_build/buildFTGL.sh"

# change back to root directory
cd ${ROOTDIR} || exit 1
74 changes: 0 additions & 74 deletions mac3rdParty/buildMacTravis.sh

This file was deleted.

54 changes: 35 additions & 19 deletions mac_build/BuildMacBOINC.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/sh
#!/bin/bash

# This file is part of BOINC.
# http://boinc.berkeley.edu
# Copyright (C) 2015 University of California
# Copyright (C) 2017 University of California
#
# BOINC is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License
Expand All @@ -29,11 +29,12 @@
# Updated 11/28/15 to build ScreenSaver with ARC under Xcode 6 or later
# Updated 2/15/16 to allow optional use of libc++ and C++11 dialect
# Updated 3/11/16 to remove obsolete targets MakeAppIcon_h & WaitPermissions
# Updated 3/13/16 to add -target and -setting optional arguments
#
## This script requires OS 10.8 or later
#
## If you drag-install Xcode 4.3 or later, you must have opened Xcode
## and clicked the Install button on the dialog which appears to
## If you drag-install Xcode 4.3 or later, you must have opened Xcode
## and clicked the Install button on the dialog which appears to
## complete the Xcode installation before running this script.
##

Expand All @@ -42,13 +43,13 @@
## cd [path]/boinc/mac_build
##
## then invoke this script as follows:
## source BuildMacBOINC.sh [-dev] [-noclean] [-libc++] [-c++11] [-all] [-lib] [-client] [-help]
## source BuildMacBOINC.sh [-dev] [-noclean] [-libc++] [-c++11] [-all] [-lib] [-client] [-target targetName] [-setting name value] [-help]
## or
## chmod +x BuildMacBOINC.sh
## ./BuildMacBOINC.sh [-dev] [-noclean] [-libc++] [-c++11] [-all] [-lib] [-client] [-help]
## ./BuildMacBOINC.sh [-dev] [-noclean] [-libc++] [-c++11] [-all] [-lib] [-client] [-target targetName] [-setting name value] [-help]
##
## optional arguments
## -dev build the development (debug) version.
## -dev build the development (debug) version.
## default is deployment (release) version.
##
## -noclean don't do a "clean" of each target before building.
Expand All @@ -63,13 +64,20 @@
## -all build all targets (i.e. target "Build_All" -- this is the default)
##
## -lib build the six libraries: libboinc_api.a, libboinc_graphics2.a,
## libboinc.a, libboinc_opencl.a, libboinc_zip.a, jpeglib.a
## libboinc.a, libboinc_opencl.a, libboinc_zip.a, jpeglib.a.
##
## -client build two targets: boinc client and command-line utility boinc_cmd
## (also builds libboinc.a if needed, since boinc_cmd requires it.)
##
## Both -lib and -client may be specified to build seven targets (no BOINC Manager)
##
## The following are used mainly for building the daily test builds:
##
## -target targetName build ONLY the one target specified by targetName
##
## -setting name value override setting 'name' to have the value 'value'
## Usually used along with -target, You can pass multipe -setting arguments.
##

targets=""
doclean="clean"
Expand All @@ -78,8 +86,10 @@ uselibcplusplus=""
buildall=0
buildlibs=0
buildclient=0
buildzip=1
style="Deployment"
isXcode6orLater=0
unset settings

xcodeversion=`xcodebuild -version`
xcodeMajorVersion=`echo $xcodeversion | cut -d ' ' -f 2 | cut -d '.' -f 1`
Expand All @@ -89,15 +99,20 @@ isXcode6orLater=1
fi

while [ $# -gt 0 ]; do
case "$1" in
case "$1" in
-noclean ) doclean="" ; shift 1 ;;
-dev ) style="Development" ; shift 1 ;;
-libc++ ) uselibcplusplus="CLANG_CXX_LIBRARY=libc++ MACOSX_DEPLOYMENT_TARGET=10.7" ; shift 1 ;;
-c++11 ) cplusplus11dialect="CLANG_CXX_LANGUAGE_STANDARD=c++11" ; shift 1 ;;
-all ) buildall=1 ; shift 1 ;;
-lib ) buildlibs=1 ; shift 1 ;;
-client ) buildclient=1 ; shift 1 ;;
* ) echo "usage:" ; echo "cd {path}/mac_build/" ; echo "source BuildMacBOINC.sh [-dev] [-noclean] [-all] [-lib] [-client] [-help]" ; return 1 ;;
-target ) shift 1 ; targets="-target $1" ; buildzip=0 ; shift 1 ;;
-setting ) shift 1 ; name="$1" ;
shift 1 ; unset value ; value=("$1");
settings+=("$name=""${value[@]}") ;
shift 1 ;;
* ) echo "usage:" ; echo "cd {path}/mac_build/" ; echo "source BuildMacBOINC.sh [-dev] [-noclean] [-all] [-lib] [-client] [-target targetName] [-setting name value] [-help]" ; return 1 ;;
esac
done

Expand Down Expand Up @@ -156,34 +171,35 @@ fi
echo ""

SDKPATH=`xcodebuild -version -sdk macosx Path`
result=0

if [ $isXcode6orLater = 0 ]; then
## echo "Xcode version < 6"
## Build the screensaver using our standard settings (with Garbage Collection)
xcodebuild -project boinc.xcodeproj ${targets} -configuration ${style} -sdk "${SDKPATH}" ${doclean} build ${uselibcplusplus} ${cplusplus11dialect}
xcodebuild -project boinc.xcodeproj ${targets} -configuration ${style} -sdk "${SDKPATH}" ${doclean} build ${uselibcplusplus} ${cplusplus11dialect} "${settings[@]}"
result=$?
else
## echo "Xcode version > 5"
## We must modify the build settings for the screensaver only, to build it with ARC
xcodebuild -project boinc.xcodeproj ${targets} -configuration ${style} -sdk "${SDKPATH}" ${doclean} build ${uselibcplusplus} ${cplusplus11dialect}

xcodebuild -project boinc.xcodeproj ${targets} -configuration ${style} -sdk "${SDKPATH}" ${doclean} build ${uselibcplusplus} ${cplusplus11dialect} "${settings[@]}"
result=$?

if [ "${buildall}" = "1" ] || [ "${targets}" = "" ]; then
if [ $result -eq 0 ]; then
xcodebuild -project boinc.xcodeproj -target ScreenSaver -configuration ${style} -sdk "${SDKPATH}" ${doclean} build ARCHS=x86_64 GCC_ENABLE_OBJC_GC=unsupported ${uselibcplusplus} ${cplusplus11dialect}
xcodebuild -project boinc.xcodeproj -target ScreenSaver -configuration ${style} -sdk "${SDKPATH}" ${doclean} build ARCHS=x86_64 GCC_ENABLE_OBJC_GC=unsupported ${uselibcplusplus} ${cplusplus11dialect} "${settings[@]}"
result=$?
fi
fi
fi

result=$?

if [ $result -eq 0 ]; then
# build ibboinc_zip.a for -all or -lib or default, where
# default is none of { -all, -lib, -client }
if [ "${buildall}" = "1" ] || [ "${buildlibs}" = "1" ] || [ "${buildclient}" = "0" ]; then
xcodebuild -project ../zip/boinc_zip.xcodeproj -target boinc_zip -configuration ${style} -sdk "${SDKPATH}" ${doclean} build ${uselibcplusplus} ${cplusplus11dialect}

result=$?
if [ "${buildzip}" = "1" ]; then
xcodebuild -project ../zip/boinc_zip.xcodeproj -target boinc_zip -configuration ${style} -sdk "${SDKPATH}" ${doclean} build ${uselibcplusplus} ${cplusplus11dialect}
result=$?
fi
fi
fi

Expand Down
Loading

0 comments on commit ab956d8

Please sign in to comment.