Add macOS travis config, fix issue in CMakeLists.txt causing macOS build to break

pull/747/head
Koen Schmeets 2020-10-17 17:05:10 +02:00 committed by phkahler
parent 0288c0a98b
commit 91684fe6f4
5 changed files with 102 additions and 12 deletions

View File

@ -6,6 +6,36 @@ jobs:
- stage: deploy
name: Snap arm64
include:
- stage: test
name: macOS
os: osx
osx_image: xcode11.2
install: "./.travis/install-macos.sh"
script: "./.travis/build-macos.sh"
deploy:
provider: releases
api_key:
secure: 3PAqaWQTsHKKuItoZnIm7KJkCE/IHjrGtQMvdjabmVr9F/X3nuRYCdhvlSwU6z1N/UIiUso5jDc/qYOxbBnDfXiu2HihW9USaPLLrQoMQHxqAr62Hks1ESMo/rCrYPdqzFBdEbkuP6GqwxXyUDhnvDwXzmqSzhcotEUwiuRnvcTnlf29WT4D0Gz8gEwIkkiMN9msH8mabvd5SkmaBFd+Z7elXn6DpTxZSHRhX8QCW7681pdq424H4qbArIB+I9ccHbS+Cbh8kKBcd/hNX1tFK4SdaUYyywonrWhgPHZzZ8oj0dRGvY19+ZnTJisQmUjiJQDglUeJ+p5RIcUHOnUjM/Io/jWdA78W9Vn0gpjX5F2iBfm0UcSyXwf9dXDFnm9pOCnFjJ1Cv4wxWlRvUXcQxv9hb00cyHYEhzPJRmNUu/DF45caOHYvLADwd0d3UPrfblXpjTPxpDxHHl3QuXQLeERiGsZOg5N6kg0coUO0p60JDdDHrxjiLXDsD8Oe9FMxIfZd6y+hfsQWLFSDyWqod+F4rmROsRdsJaAC8EliRCxBp/jLY8/ntFLAKCwRP57z46wXWe65yOENOErSDZvbrPZbNOm7whX4GsTozfE1dy+3lcsOq+jth3LbyQHuDRNW2/oKtWfOeQ1H+8W+WP1GRpyIOHzClSgMe/k3n7E60Ls=
skip_cleanup: true
file: build/bin/SolveSpace.dmg
on:
repo: vespakoen/solvespace
tags: true
- stage: deploy
name: macOS
os: osx
osx_image: xcode11.2
install: "./.travis/install-macos.sh"
script: "./.travis/build-macos.sh && ./.travis/sign-macos.sh"
deploy:
provider: releases
api_key:
secure: 3PAqaWQTsHKKuItoZnIm7KJkCE/IHjrGtQMvdjabmVr9F/X3nuRYCdhvlSwU6z1N/UIiUso5jDc/qYOxbBnDfXiu2HihW9USaPLLrQoMQHxqAr62Hks1ESMo/rCrYPdqzFBdEbkuP6GqwxXyUDhnvDwXzmqSzhcotEUwiuRnvcTnlf29WT4D0Gz8gEwIkkiMN9msH8mabvd5SkmaBFd+Z7elXn6DpTxZSHRhX8QCW7681pdq424H4qbArIB+I9ccHbS+Cbh8kKBcd/hNX1tFK4SdaUYyywonrWhgPHZzZ8oj0dRGvY19+ZnTJisQmUjiJQDglUeJ+p5RIcUHOnUjM/Io/jWdA78W9Vn0gpjX5F2iBfm0UcSyXwf9dXDFnm9pOCnFjJ1Cv4wxWlRvUXcQxv9hb00cyHYEhzPJRmNUu/DF45caOHYvLADwd0d3UPrfblXpjTPxpDxHHl3QuXQLeERiGsZOg5N6kg0coUO0p60JDdDHrxjiLXDsD8Oe9FMxIfZd6y+hfsQWLFSDyWqod+F4rmROsRdsJaAC8EliRCxBp/jLY8/ntFLAKCwRP57z46wXWe65yOENOErSDZvbrPZbNOm7whX4GsTozfE1dy+3lcsOq+jth3LbyQHuDRNW2/oKtWfOeQ1H+8W+WP1GRpyIOHzClSgMe/k3n7E60Ls=
skip_cleanup: true
file: build/bin/SolveSpace.dmg
on:
repo: vespakoen/solvespace
tags: true
- stage: test
name: "Debian"
os: linux

View File

@ -5,5 +5,5 @@ if echo $TRAVIS_TAG | grep ^v; then BUILD_TYPE=RelWithDebInfo; else BUILD_TYPE=D
mkdir build
cd build
cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 -DCMAKE_BUILD_TYPE=$BUILD_TYPE ..
make VERBOSE=1
make
make test_solvespace

View File

@ -1,5 +1,3 @@
#!/bin/sh -xe
brew update
brew install freetype cairo
git submodule update --init

63
.travis/sign-macos.sh Normal file
View File

@ -0,0 +1,63 @@
#!/bin/sh -xe
cd build
app="bin/SolveSpace.app"
dmg="bin/SolveSpace.dmg"
bundle_id="com.solvespace.solvespace"
# get the signing certificate (this is the Developer ID:Application: Your Name, exported to a p12 file, then converted to base64, e.g.: cat ~/Desktop/certificate.p12 | base64 | pbcopy)
echo $MACOS_CERTIFICATE_P12 | base64 --decode > certificate.p12
# create a keychain
security create-keychain -p secret build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p secret build.keychain
# import the key
security import certificate.p12 -k build.keychain -P $MACOS_CERTIFICATE_PASSWORD -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple: -s -k secret build.keychain
#security set-keychain-settings -t 3600 -u build.keychain
# check if all is good
security find-identity -v
# sign the .app
codesign -s "${MACOS_DEVELOPER_ID}" --timestamp --options runtime -f --deep "${app}"
# create the .dmg from the signed .app
hdiutil create -srcfolder "${app}" "${dmg}"
# sign the .dmg
codesign -s "${MACOS_DEVELOPER_ID}" --timestamp --options runtime -f "${dmg}"
# notarize and store request uuid in variable
notarize_uuid=$(xcrun altool --notarize-app --primary-bundle-id "${bundle_id}" --username "${MACOS_APPSTORE_USERNAME}" --password "${MACOS_APPSTORE_APP_PASSWORD}" --file "${dmg}" 2>&1 | grep RequestUUID | awk '{print $3'})
# wait a bit so we don't get errors during checking
sleep 5
success=0
for (( ; ; ))
do
echo "Checking progress..."
progress=$(xcrun altool --notarization-info "${notarize_uuid}" -u "${MACOS_APPSTORE_USERNAME}" -p "${MACOS_APPSTORE_APP_PASSWORD}" 2>&1)
echo "${progress}"
if [ $? -ne 0 ] || [[ "${progress}" =~ "Invalid" ]] ; then
echo "Error with notarization. Exiting"
break
fi
if [[ "${progress}" =~ "success" ]]; then
success=1
break
else
echo "Not completed yet. Sleeping for 10 seconds"
fi
sleep 10
done
# staple
xcrun stapler staple $app

View File

@ -22,6 +22,10 @@ set(CMAKE_USER_MAKE_RULES_OVERRIDE
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX
"${CMAKE_SOURCE_DIR}/cmake/cxx_flag_overrides.cmake")
if(APPLE OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
# project
# NOTE TO PACKAGERS: The embedded git commit hash is critical for rapid bug triage when the builds
@ -69,7 +73,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
endif()
# common compiler flags
include(CheckCXXCompilerFlag)
set(FILE_PREFIX_MAP "-ffile-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=.")
@ -109,10 +112,6 @@ if(ENABLE_OPENMP)
endif()
endif()
if(APPLE OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed ${CMAKE_EXE_LINKER_FLAGS}")
endif()