Skip to content

Commit

Permalink
switched macos to build arm64 and x86_64 closes #161
Browse files Browse the repository at this point in the history
  • Loading branch information
ofTheo committed Dec 5, 2020
1 parent 966abe0 commit 128943a
Show file tree
Hide file tree
Showing 24 changed files with 128 additions and 79 deletions.
14 changes: 9 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,38 +105,42 @@ matrix:
- TOOLCHAIN_ROOT="$HOME/rpi2_toolchain"
- TOOLCHAIN_PREFIX=arm-linux-gnueabihf

# osx xcode7
# osx xcode12
- os: osx
cache: ccache
osx_image: xcode7.3
osx_image: xcode12.2
compiler: clang
env:
- TARGET="osx"
- BUNDLE="1"
- DEVELOPER_DIR="/Applications/Xcode-12.2.app/Contents/Developer"

- os: osx
cache: ccache
osx_image: xcode7.3
osx_image: xcode12.2
compiler: clang
env:
- TARGET="osx"
- BUNDLE="2"
- DEVELOPER_DIR="/Applications/Xcode-12.2.app/Contents/Developer"

- os: osx
cache: ccache
osx_image: xcode7.3
osx_image: xcode12.2
compiler: clang
env:
- TARGET="osx"
- BUNDLE="3"
- DEVELOPER_DIR="/Applications/Xcode-12.2.app/Contents/Developer"

- os: osx
cache: ccache
osx_image: xcode7.3
osx_image: xcode12.2
compiler: clang
env:
- TARGET="osx"
- BUNDLE="4"
- DEVELOPER_DIR="/Applications/Xcode-12.2.app/Contents/Developer"

# ios
- os: osx
Expand Down
14 changes: 7 additions & 7 deletions apothecary/formulas/FreeImage/Makefile.osx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include Makefile.srcs

# Update this based on your installed SDKs
MACOSX_SDK=$(shell xcrun -sdk macosx --show-sdk-version)
MACOSX_MIN_SDK = 10.7
MACOSX_MIN_SDK = 10.9

# Find SDK path via xcode-select, backwards compatible with Xcode vers < 4.5
MACOSX_SYSROOT = $(shell xcode-select -print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOSX_SDK).sdk
Expand All @@ -15,7 +15,7 @@ MACOSX_SYSROOT = $(shell xcode-select -print-path)/Platforms/MacOSX.platform/Dev
CC_X86_64 = $(shell xcrun -find clang)
CPP_X86_64 = $(shell xcrun -find clang++)

COMPILERFLAGS = -arch x86_64 -arch i386 -Wno-ctor-dtor-privacy -stdlib=libc++ -Wc++11-narrowing -Os -fexceptions -fvisibility=hidden -DNO_LCMS -fPIC -DNDEBUG -D__ANSI__ -DDISABLE_PERF_MEASUREMENT -mmacosx-version-min=$(MACOSX_MIN_SDK)
COMPILERFLAGS = -arch x86_64 -arch arm64 -Wno-implicit-function-declaration -Wno-ctor-dtor-privacy -stdlib=libc++ -Wc++11-narrowing -Os -fexceptions -fvisibility=hidden -DNO_LCMS -fPIC -DPNG_ARM_NEON_OPT=0 -DNDEBUG -D__ANSI__ -DDISABLE_PERF_MEASUREMENT -mmacosx-version-min=$(MACOSX_MIN_SDK)

INCLUDE_X86_64 = -isysroot $(MACOSX_SYSROOT)
CFLAGS_X86_64 = $(COMPILERFLAGS) $(INCLUDE) $(INCLUDE_X86_64)
Expand All @@ -31,9 +31,9 @@ STATICLIB = lib$(TARGET).a

HEADER = Source/FreeImage.h

.SUFFIXES: .o-x86_64
MODULES_X86_64 = $(SRCS:.c=.o-x86_64)
MODULES_X86_64 := $(MODULES_X86_64:.cpp=.o-x86_64)
.SUFFIXES: .o
MODULES_X86_64 = $(SRCS:.c=.o)
MODULES_X86_64 := $(MODULES_X86_64:.cpp=.o)

PREFIX = /usr/local
INSTALLDIR = $(PREFIX)/lib
Expand All @@ -53,10 +53,10 @@ FreeImage: $(STATICLIB)
$(STATICLIB): $(MODULES_X86_64)
$(LIBTOOL) -o $@ $(MODULES_X86_64)

.c.o-x86_64:
.c.o:
$(CC_X86_64) $(CFLAGS_X86_64) -c $< -o $@

.cpp.o-x86_64:
.cpp.o:
$(CPP_X86_64) $(CPPFLAGS_X86_64) -c $< -o $@

install:
Expand Down
3 changes: 2 additions & 1 deletion apothecary/formulas/_depends/pixman.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ function build() {

# these flags are used to create a fat 32/64 binary with i386->libstdc++, x86_64->libc++
# see https://gist.github.com/tgfrerer/8e2d973ed0cfdd514de6
local FAT_LDFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
local SDK_PATH=$(xcrun --show-sdk-path)
local FAT_LDFLAGS="-arch arm64 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER} -isysroot ${SDK_PATH}"

./configure LDFLAGS="${FAT_LDFLAGS} " \
CFLAGS="-O3 ${FAT_LDFLAGS}" \
Expand Down
4 changes: 2 additions & 2 deletions apothecary/formulas/assimp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ function build() {
# cd build_osx
# 32 bit
cmake -G 'Unix Makefiles' $buildOpts \
-DCMAKE_C_FLAGS="-arch i386 -arch x86_64 -O3 -DNDEBUG -funroll-loops -mmacosx-version-min=${OSX_MIN_SDK_VER}" \
-DCMAKE_CXX_FLAGS="-arch i386 -arch x86_64 -stdlib=libc++ -O3 -DNDEBUG -funroll-loops -std=c++11 -mmacosx-version-min=${OSX_MIN_SDK_VER}" .
-DCMAKE_C_FLAGS="-arch arm64 -arch x86_64 -O3 -DNDEBUG -funroll-loops -mmacosx-version-min=${OSX_MIN_SDK_VER}" \
-DCMAKE_CXX_FLAGS="-arch arm64 -arch x86_64 -stdlib=libc++ -O3 -DNDEBUG -funroll-loops -std=c++11 -mmacosx-version-min=${OSX_MIN_SDK_VER}" .
make assimp -j${PARALLEL_MAKE}

elif [ "$TYPE" == "vs" ] ; then
Expand Down
6 changes: 3 additions & 3 deletions apothecary/formulas/boost/boost.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
FORMULA_TYPES=( "osx" "ios" "tvos" "android" "emscripten" "vs" )

# define the version
VERSION=1.65.0
VERSION=1.66.0
VERSION_UNDERSCORES="$(echo "$VERSION" | sed 's/\./_/g')"
TARBALL="boost_${VERSION_UNDERSCORES}.tar.gz"

Expand Down Expand Up @@ -42,7 +42,7 @@ function download() {

# prepare the build environment, executed inside the lib src dir
function prepare() {
patch -p0 -u < $FORMULA_DIR/visualc.hpp.patch
# patch -p0 -u < $FORMULA_DIR/visualc.hpp.patch

if [ "$TYPE" == "osx" ]; then
./bootstrap.sh --with-toolset=clang --with-libraries=filesystem
Expand Down Expand Up @@ -80,7 +80,7 @@ function build() {


elif [ "$TYPE" == "osx" ]; then
./b2 -j${PARALLEL_MAKE} toolset=clang cxxflags="-std=c++11 -stdlib=libc++ -arch i386 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}" linkflags="-stdlib=libc++" threading=multi variant=release --build-dir=build --stage-dir=stage link=static stage
./b2 -j${PARALLEL_MAKE} toolset=clang cxxflags="-std=c++11 -stdlib=libc++ -arch arm64 -arch x86_64 -Wno-implicit-function-declaration -mmacosx-version-min=${OSX_MIN_SDK_VER}" linkflags="-stdlib=libc++" threading=multi variant=release --build-dir=build --stage-dir=stage link=static stage
cd tools/bcp
../../b2
elif [[ "$TYPE" == "ios" || "${TYPE}" == "tvos" ]]; then
Expand Down
19 changes: 15 additions & 4 deletions apothecary/formulas/cairo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,29 @@ function build() {
# exit 1
with_vs_env "make -f Makefile.win32 \"CFG=release\""
elif [ "$TYPE" == "osx" ] ; then
./configure PKG_CONFIG="$BUILD_ROOT_DIR/bin/pkg-config" \

# needed for travis FREETYPE_LIBS configure var forces cairo to search this location for freetype
ROOT=${PWD}/..
FREETYPE_LIB_PATH="-L$ROOT/freetype/build/osx/lib -lfreetype"

./configure PKG_CONFIG="$BUILD_ROOT_DIR/bin/pkg-config" \
PKG_CONFIG_PATH="$BUILD_ROOT_DIR/lib/pkgconfig" \
LDFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}" \
CFLAGS="-Os -arch i386 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}" \
FREETYPE_LIBS="$FREETYPE_LIB_PATH" \
LDFLAGS="-arch arm64 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}" \
CFLAGS="-Os -arch arm64 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}" \
--prefix=$BUILD_ROOT_DIR \
--disable-gtk-doc \
--disable-gtk-doc-html \
--disable-gtk-doc-pdf \
--disable-full-testing \
--disable-dependency-tracking \
--disable-xlib \
--disable-qt
--disable-qt \
--disable-shared \
--disable-quartz-font \
--disable-quartz \
--disable-quartz-image

make -j${PARALLEL_MAKE}
make install
else
Expand Down
10 changes: 5 additions & 5 deletions apothecary/formulas/curl/curl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ function build() {
#local OPENSSL_DIR=$BUILD_DIR/openssl/build/$TYPE
./buildconf

export CFLAGS="-arch i386 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
export LDFLAGS="-arch i386 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
export CFLAGS="-arch arm64 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
export LDFLAGS="-arch arm64 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
./configure \
--with-darwinssl \
--prefix=$BUILD_DIR/curl/build/osx/x86 \
--prefix=$BUILD_DIR/curl/build/osx/arm64 \
--enable-static \
--disable-shared \
--disable-ldap \
--disable-ldaps \
--host=x86-apple-darwin
--host=arm-apple-darwin
make clean
make -j${PARALLEL_MAKE}
make install
Expand All @@ -118,7 +118,7 @@ function build() {

cp -r build/osx/x64/* build/osx/

lipo -create build/osx/x86/lib/libcurl.a \
lipo -create build/osx/arm64/lib/libcurl.a \
build/osx/x64/lib/libcurl.a \
-output build/osx/lib/libcurl.a
make install
Expand Down
4 changes: 2 additions & 2 deletions apothecary/formulas/freetype/freetype.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ function build() {
if [ "$TYPE" == "osx" ] ; then
local BUILD_TO_DIR=$BUILD_DIR/freetype/build/$TYPE/

# these flags are used to create a fat 32/64 binary with i386->libstdc++, x86_64->libc++
# these flags are used to create a fat arm64/x86_64 binary with libc++
# see https://gist.github.com/tgfrerer/8e2d973ed0cfdd514de6
local FAT_CFLAGS="-arch i386 -arch x86_64 -stdlib=libc++ -mmacosx-version-min=${OSX_MIN_SDK_VER}"
local FAT_CFLAGS="-arch arm64 -arch x86_64 -stdlib=libc++ -mmacosx-version-min=${OSX_MIN_SDK_VER}"

set -e
CURRENTPATH=`pwd`
Expand Down
10 changes: 5 additions & 5 deletions apothecary/formulas/glew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ function build() {

if [ "$TYPE" == "osx" ] ; then

# GLEW will not allow one to simply supply OPT="-arch i386 -arch x86_64"
# GLEW will not allow one to simply supply OPT="-arch arm64 -arch x86_64"
# so we build them separately.

# 32 bit
make clean; make -j${PARALLEL_MAKE} glew.lib OPT="-arch i386 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
mv lib/libGLEW.a libGLEW-i386.a
# arm64
make clean; make -j${PARALLEL_MAKE} glew.lib OPT="-arch arm64 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
mv lib/libGLEW.a libGLEW-arm64.a

# 64 bit
make clean; make -j${PARALLEL_MAKE} glew.lib OPT="-arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
mv lib/libGLEW.a libGLEW-x86_64.a

# link into fat universal lib
lipo -c libGLEW-i386.a libGLEW-x86_64.a -o libGLEW.a
lipo -c libGLEW-arm64.a libGLEW-x86_64.a -o libGLEW.a

elif [ "$TYPE" == "vs" ] ; then
unset TMP
Expand Down
2 changes: 1 addition & 1 deletion apothecary/formulas/glfw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function build() {
-DGLFW_BUILD_EXAMPLES=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}" \
-DCMAKE_C_FLAGS="-arch arm64 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}" \
$EXTRA_CONFIG
else
cmake .. -DGLFW_BUILD_DOCS=OFF \
Expand Down
12 changes: 8 additions & 4 deletions apothecary/formulas/libpng/libpng.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,19 @@ function prepare() {
function build() {

if [ "$TYPE" == "osx" ] ; then

# these flags are used to create a fat 32/64 binary with i386->libstdc++, x86_64->libc++
local SDK_PATH=$(xcrun --show-sdk-path)
echo "SDK PATH IS ${SDK_PATH}"

# these flags are used to create a fat arm/64 binary with libc++
# see https://gist.github.com/tgfrerer/8e2d973ed0cfdd514de6
local FAT_LDFLAGS="-arch i386 -arch x86_64 -stdlib=libstdc++ -Xarch_x86_64 -stdlib=libc++"
local FAT_LDFLAGS="-arch arm64 -arch x86_64 -stdlib=libc++ -isysroot ${SDK_PATH} -mmacosx-version-min=${OSX_MIN_SDK_VER}"

./configure LDFLAGS="${FAT_LDFLAGS} " \
CFLAGS="-O3 ${FAT_LDFLAGS}" \
--prefix=$BUILD_ROOT_DIR \
--disable-dependency-tracking
--disable-dependency-tracking \
--disable-arm-neon \
--disable-shared
make clean
make
elif [ "$TYPE" == "vs" ] ; then
Expand Down
2 changes: 1 addition & 1 deletion apothecary/formulas/libusb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function build() {
fi

if [ "$TYPE" == "osx" ] ; then
CFLAGS="-arch i386 -arch x86_64" ./configure --disable-shared --enable-static
CFLAGS="-arch arm64 -arch x86_64" ./configure --disable-shared --enable-static
make -j${PARALLEL_MAKE}
fi

Expand Down
10 changes: 5 additions & 5 deletions apothecary/formulas/libxml2/libxml2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ function build() {
make -j${PARALLEL_MAKE}
make install
elif [ "$TYPE" == "osx" ]; then
export CFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
export LDFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
export CFLAGS="-arch arm64 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
export LDFLAGS="-arch arm64 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}"

./configure --without-lzma --without-zlib --disable-shared --enable-static --without-ftp --without-html --without-http --without-iconv --without-legacy --without-modules --without-output --without-python
make clean
Expand Down Expand Up @@ -114,8 +114,8 @@ function build() {


elif [ "$TYPE" == "osx" ]; then
export CFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
export LDFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
export CFLAGS="-arch arm64 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
export LDFLAGS="-arch arm64 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}"

./configure --without-lzma --without-zlib --disable-shared --enable-static --without-ftp --without-html --without-http --without-iconv --without-legacy --without-modules --without-output --without-python
make clean
Expand Down Expand Up @@ -197,4 +197,4 @@ function clean() {
else
make clean
fi
}
}
4 changes: 2 additions & 2 deletions apothecary/formulas/opencv/opencv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ function build() {
cmake .. -DCMAKE_INSTALL_PREFIX=$LIB_FOLDER \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 \
-DENABLE_FAST_MATH=OFF \
-DCMAKE_CXX_FLAGS="-fvisibility-inlines-hidden -stdlib=libc++ -std=c++11 -O3 -fPIC -arch i386 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}" \
-DCMAKE_C_FLAGS="-fvisibility-inlines-hidden -stdlib=libc++ -O3 -fPIC -arch i386 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}" \
-DCMAKE_CXX_FLAGS="-fvisibility-inlines-hidden -stdlib=libc++ -std=c++11 -O3 -fPIC -arch arm64 -arch x86_64 -Wno-implicit-function-declaration -mmacosx-version-min=${OSX_MIN_SDK_VER}" \
-DCMAKE_C_FLAGS="-fvisibility-inlines-hidden -stdlib=libc++ -O3 -fPIC -arch arm64 -arch x86_64 -Wno-implicit-function-declaration -mmacosx-version-min=${OSX_MIN_SDK_VER}" \
-DCMAKE_BUILD_TYPE="Release" \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_DOCS=OFF \
Expand Down
15 changes: 15 additions & 0 deletions apothecary/formulas/openssl/13-macos-arm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## -*- mode: perl; -*-
## macos configuration targets

%targets = (
# Based on 10-main.conf
# tip from https://cutecoder.org/programming/compile-open-ssl-apple-silicon/
"darwin64-arm64-cc" => {
inherit_from => [ "darwin-common", asm("aarch64_asm") ],
CFLAGS => add("-Wall"),
cflags => add("-arch arm64"),
lib_cppflags => add("-DL_ENDIAN"),
bn_ops => "SIXTY_FOUR_BIT_LONG",
perlasm_scheme => "macosx",
},
);
Loading

0 comments on commit 128943a

Please sign in to comment.