Add support for building for different architectures on macos

This commit is contained in:
Luis Ángel San Martín Rodríguez 2023-07-17 23:17:17 +02:00
parent 560eff5f7a
commit a355a15c4b
2 changed files with 80 additions and 11 deletions

View File

@ -111,10 +111,10 @@ jobs:
displayName: 'Run tests'
#
# MacOS qt6
# MacOS qt6(intel)
#
- job: MacOS_qt6
- job: MacOS_qt6_Intel
timeoutInMinutes: 90
dependsOn: CodeFormatValidation
variables:
@ -145,7 +145,66 @@ jobs:
VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' )"
echo "Trying to know if we are in a forked repo: $IS_FORK"
SKIP_CODESIGN="$(tr [A-Z] [a-z] <<< "$IS_FORK")"
./compileOSX.sh $VERSION $(Build.BuildNumber) $SKIP_CODESIGN Qt6
./compileOSX.sh $VERSION $(Build.BuildNumber) $SKIP_CODESIGN Qt6 x86_64
displayName: 'Build'
- script: |
cd $(Build.SourcesDirectory)/tests
qmake
make check TESTARGS="-maxwarnings 100000"
displayName: 'Build and run tests'
- script: |
SKIP_CODESIGN="$(tr [A-Z] [a-z] <<< "$IS_FORK")"
if [ "$SKIP_CODESIGN" = false ]; then
xcrun notarytool submit *.dmg --apple-id $(AppleId) --team-id $(TeamId) --password $(AppPassword) --wait
xcrun stapler staple *.dmg
fi
displayName: 'Notarize'
- task: CopyFiles@2
inputs:
contents: '*.dmg'
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishPipelineArtifact@1
inputs:
path: $(Build.ArtifactStagingDirectory)
artifactName: Macos qt6 $(Build.BuildNumber) dmg
#
# MacOS qt6(apple)
#
#TODO create a template
- job: MacOS_qt6_Apple
timeoutInMinutes: 90
dependsOn: CodeFormatValidation
variables:
- ${{ if and(eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/luisangelsm/'), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))) }}:
- group: macos-codesign
pool:
vmImage: 'macOS-latest'
steps:
- script: |
pip3 install aqtinstall
python3 -m aqt install 6.3.1 mac desktop -m qt5compat qtmultimedia qtimageformats
echo '##vso[task.prependpath]$(Build.SourcesDirectory)/6.3.1/macos/bin'
brew install create-dmg
brew install node
brew link --overwrite node
npm install -g appdmg
mkdir $(Build.SourcesDirectory)\compressed_archive
wget "https://github.com/YACReader/yacreader-7z-deps/blob/main/7z2301-src.7z?raw=true" -O $(Build.SourcesDirectory)/compressed_archive/7z2301-src.7z
7z x $(Build.SourcesDirectory)/compressed_archive/7z2301-src.7z -o$(Build.SourcesDirectory)/compressed_archive/lib7zip
displayName: 'Install dependencies'
- ${{ if and(eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/luisangelsm/'), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))) }}:
- task: InstallAppleCertificate@2
inputs:
certSecureFile: 'developerID_application.p12'
certPwd: $(P12Password)
- script: |
cd $(Build.SourcesDirectory)
VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' )"
echo "Trying to know if we are in a forked repo: $IS_FORK"
SKIP_CODESIGN="$(tr [A-Z] [a-z] <<< "$IS_FORK")"
./compileOSX.sh $VERSION $(Build.BuildNumber) $SKIP_CODESIGN Qt6 arm64
displayName: 'Build'
- script: |
cd $(Build.SourcesDirectory)/tests

View File

@ -9,29 +9,39 @@ SKIP_CODESIGN=${3:-false}
QT_VERSION=${4:-""}
ARCH=${5:-"arm64"}
echo "building macos binaries with these params: ${VERSION} ${BUILD_NUMBER} ${SKIP_CODESIGN} ${QT_VERSION}"
if [ "$5" == "clean" ]; then
if [ "$6" == "clean" ]; then
./cleanOSX.sh
fi
if [ "$ARCH" == "arm64"]; then
ARCH_NAME="Apple"
fi
if [ "$ARCH" == "x86_64"]; then
ARCH_NAME="Intel"
fi
hash qmake 2>/dev/null || { echo >&2 "Qmake command not available. Please add the bin subfolder of your Qt installation to the PATH environment variable."; exit 1; }
echo "Compiling YACReader"
cd YACReader
qmake DEFINES+="BUILD_NUMBER=\\\\\\\"${BUILD_NUMBER}\\\\\\\""
qmake DEFINES+="BUILD_NUMBER=\\\\\\\"${BUILD_NUMBER}\\\\\\\"" QMAKE_APPLE_DEVICE_ARCHS="${ARCH}"
make
cd ..
echo "Compiling YACReaderLibrary"
cd YACReaderLibrary
qmake DEFINES+="BUILD_NUMBER=\\\\\\\"${BUILD_NUMBER}\\\\\\\""
qmake DEFINES+="BUILD_NUMBER=\\\\\\\"${BUILD_NUMBER}\\\\\\\"" QMAKE_APPLE_DEVICE_ARCHS="${ARCH}"
make
cd ..
echo "Compiling YACReaderLibraryServer"
cd YACReaderLibraryServer
qmake DEFINES+="BUILD_NUMBER=\\\\\\\"${BUILD_NUMBER}\\\\\\\""
qmake DEFINES+="BUILD_NUMBER=\\\\\\\"${BUILD_NUMBER}\\\\\\\"" QMAKE_APPLE_DEVICE_ARCHS="${ARCH}"
make
cd ..
@ -53,9 +63,9 @@ mkdir -p YACReader.app/Contents/MacOS/utils
mkdir -p YACReaderLibrary.app/Contents/MacOS/utils
mkdir -p YACReaderLibraryServer.app/Contents/MacOS/utils
cp -R dependencies/7zip/macx/* YACReader.app/Contents/MacOS/utils/
cp -R dependencies/7zip/macx/* YACReaderLibrary.app/Contents/MacOS/utils/
cp -R dependencies/7zip/macx/* YACReaderLibraryServer.app/Contents/MacOS/utils/
cp -R dependencies/7zip/macx/${ARCH}/* YACReader.app/Contents/MacOS/utils/
cp -R dependencies/7zip/macx/${ARCH}/* YACReaderLibrary.app/Contents/MacOS/utils/
cp -R dependencies/7zip/macx/${ARCH}/* YACReaderLibraryServer.app/Contents/MacOS/utils/
cp -R release/server YACReaderLibrary.app/Contents/MacOS/
cp -R release/server YACReaderLibraryServer.app/Contents/MacOS/
@ -74,7 +84,7 @@ fi
echo "Preparing apps for release, Done."
dest="YACReader-$VERSION.$BUILD_NUMBER MacOSX-Intel ${QT_VERSION}"
dest="YACReader-$VERSION.$BUILD_NUMBER MacOSX-${ARCH_NAME} ${QT_VERSION}"
echo "Copying to destination folder ${dest}"
mkdir -p "$dest"
cp -R YACReader.app "${dest}/YACReader.app"