|
| 1 | +# templates/macos-build.yml |
| 2 | +# Template for building SerialPrograms on MacOS |
| 3 | + |
| 4 | +parameters: |
| 5 | + stageName: '' |
| 6 | + displayName: '' |
| 7 | + targetOS: '' |
| 8 | + poolName: '' |
| 9 | + imageName: '' |
| 10 | + architecture: '' |
| 11 | + compiler: '' |
| 12 | + qt_version: '' |
| 13 | + qt_version_major: '' |
| 14 | + qt_modules: '' |
| 15 | + cmake_preset: '' |
| 16 | + macos_path: '' |
| 17 | + cmake_version_params: '' |
| 18 | + cmake_additional_param: '' |
| 19 | + condition: '' |
| 20 | + |
| 21 | +stages: |
| 22 | +- stage: ${{ parameters.stageName }} |
| 23 | + displayName: ${{ parameters.displayName }} |
| 24 | + dependsOn: [] |
| 25 | + condition: ${{ parameters.condition }} |
| 26 | + |
| 27 | + jobs: |
| 28 | + - job: MacOS |
| 29 | + timeoutInMinutes: 60 |
| 30 | + cancelTimeoutInMinutes: 1 |
| 31 | + displayName: MacOS ${{ parameters.architecture }} |
| 32 | + |
| 33 | + pool: |
| 34 | + name: ${{ parameters.poolName }} |
| 35 | + demands: |
| 36 | + - Agent.OSArchitecture -equals ${{ lower(parameters.architecture) }} |
| 37 | + |
| 38 | + variables: |
| 39 | + architecture: ${{ parameters.architecture }} |
| 40 | + compiler: ${{ parameters.compiler }} |
| 41 | + qt_version: ${{ parameters.qt_version }} |
| 42 | + cmake_preset: ${{ parameters.cmake_preset }} |
| 43 | + macos_path: ${{ parameters.macos_path }} |
| 44 | + cmake_version_params: ${{ parameters.cmake_version_params }} |
| 45 | + cmake_additional_param: ${{ parameters.cmake_additional_param }} |
| 46 | + |
| 47 | + steps: |
| 48 | + - template: checkout.yml |
| 49 | + |
| 50 | + #- script: | |
| 51 | + # set -e |
| 52 | + # PERSISTENT_ONNX="/Users/Shared/onnxruntime" |
| 53 | + # WORK_ONNX="$(Pipeline.Workspace)/onnxruntime" |
| 54 | + # |
| 55 | + # if [ -d "$PERSISTENT_ONNX" ]; then |
| 56 | + # echo "=== Found ONNX Runtime at $PERSISTENT_ONNX ===" |
| 57 | + # if [ ! -L "$WORK_ONNX" ]; then |
| 58 | + # ln -sf "$PERSISTENT_ONNX" "$WORK_ONNX" |
| 59 | + # echo "=== Created symlink to ONNX Runtime ===" |
| 60 | + # fi |
| 61 | + # else |
| 62 | + # echo "=== ERROR: ONNX Runtime not found at $PERSISTENT_ONNX ===" |
| 63 | + # exit 1 |
| 64 | + # fi |
| 65 | + # displayName: 'Link ONNX Runtime' |
| 66 | + # condition: succeeded() |
| 67 | + |
| 68 | + - script: | |
| 69 | + export PATH=$(macos_path) |
| 70 | + cd "$(Pipeline.Workspace)/Arduino-Source-Internal/Repository/Public/SerialPrograms" |
| 71 | + cmake $(cmake_additional_param) $(cmake_version_params) --preset=$(cmake_preset) --fresh |
| 72 | + displayName: 'Configure CMake' |
| 73 | + condition: succeeded() |
| 74 | +
|
| 75 | + - script: | |
| 76 | + export PATH=$(macos_path) |
| 77 | + cd "$(Pipeline.Workspace)/Arduino-Source-Internal/Repository/Public/SerialPrograms" |
| 78 | + cmake --build --preset=$(cmake_preset) |
| 79 | + displayName: 'Build' |
| 80 | + condition: succeeded() |
| 81 | +
|
| 82 | + - script: | |
| 83 | + set -e |
| 84 | + export PATH=$(macos_path) |
| 85 | + BUILD_DIR="$(Pipeline.Workspace)/Arduino-Source-Internal/Repository/Public/build/$(cmake_preset)" |
| 86 | +
|
| 87 | + echo "=== Generating dSYM bundle ===" |
| 88 | + mkdir -p "$(Pipeline.Workspace)/Arduino-Source-Internal/Repository/Public/build/$(cmake_preset)/cache-symbols" |
| 89 | + cd "$BUILD_DIR" |
| 90 | + dsymutil SerialPrograms.app/Contents/MacOS/SerialPrograms -o cache-symbols/SerialPrograms.dSYM |
| 91 | +
|
| 92 | + echo "=== dSYM bundle created ===" |
| 93 | + displayName: 'Generate Debug Symbols' |
| 94 | + condition: succeeded() |
| 95 | +
|
| 96 | + - script: | |
| 97 | + set -e |
| 98 | + export PATH=$(macos_path) |
| 99 | + APP_DIR="$(Pipeline.Workspace)/Arduino-Source-Internal/Repository/Public/build/$(cmake_preset)/SerialPrograms.app" |
| 100 | + MACOS_DIR="$APP_DIR/Contents/MacOS" |
| 101 | + FW_DIR="$APP_DIR/Contents/Frameworks" |
| 102 | + BREW_PREFIX=$(brew --prefix) |
| 103 | +
|
| 104 | + mkdir -p "$FW_DIR" |
| 105 | + if [ "$(architecture)" = "x64" ]; then |
| 106 | + QT_BIN="/usr/local/Qt/$(qt_version)/macos/bin" |
| 107 | + else |
| 108 | + QT_BIN="/opt/Qt/$(qt_version)/macos/bin" |
| 109 | + fi |
| 110 | +
|
| 111 | + echo "=== Copying additional deps ===" |
| 112 | + cp $BREW_PREFIX/opt/gcc/lib/gcc/current/libgcc_s.1.1.dylib $APP_DIR/Contents/Frameworks |
| 113 | + cp $BREW_PREFIX/opt/protobuf/lib/libutf8_validity.dylib $APP_DIR/Contents/Frameworks |
| 114 | + cp $BREW_PREFIX/opt/little-cms2/lib/liblcms2.2.dylib $APP_DIR/Contents/Frameworks |
| 115 | + cp $BREW_PREFIX/opt/webp/lib/libsharpyuv.0.dylib $APP_DIR/Contents/Frameworks |
| 116 | + cp $BREW_PREFIX/opt/jpeg-xl/lib/libjxl_cms.0.11.dylib $APP_DIR/Contents/Frameworks |
| 117 | + cp $BREW_PREFIX/opt/vtk/lib/libvtkCommonComputationalGeometry-*.dylib $APP_DIR/Contents/Frameworks |
| 118 | + cp $BREW_PREFIX/opt/vtk/lib/libvtkFiltersVerdict-*.dylib $APP_DIR/Contents/Frameworks |
| 119 | + cp $BREW_PREFIX/opt/vtk/lib/libvtkfmt-*.dylib $APP_DIR/Contents/Frameworks |
| 120 | + cp $BREW_PREFIX/opt/vtk/lib/libvtkFiltersGeometry-*.dylib $APP_DIR/Contents/Frameworks |
| 121 | + cp $BREW_PREFIX/opt/vtk/lib/libvtkFiltersCore-*.dylib $APP_DIR/Contents/Frameworks |
| 122 | + cp $BREW_PREFIX/opt/vtk/lib/libvtkCommonCore-*.dylib $APP_DIR/Contents/Frameworks |
| 123 | + cp $BREW_PREFIX/opt/vtk/lib/libvtkCommonSystem-*.dylib $APP_DIR/Contents/Frameworks |
| 124 | +
|
| 125 | + echo "=== Running macdeployqt6 ===" |
| 126 | + install_name_tool -add_rpath $BREW_PREFIX/lib $MACOS_DIR/SerialPrograms |
| 127 | + otool -l $MACOS_DIR/SerialPrograms | grep -A2 LC_RPATH |
| 128 | + "$QT_BIN/macdeployqt6" $APP_DIR -no-strip -verbose=3 |
| 129 | +
|
| 130 | + echo "=== Fixing install IDs in copied libs ===" |
| 131 | + for dylib in "$FW_DIR"/*.dylib; do |
| 132 | + [ -f "$dylib" ] || continue |
| 133 | + base=$(basename "$dylib") |
| 134 | + install_name_tool -id "@executable_path/../Frameworks/$base" "$dylib" |
| 135 | + done |
| 136 | +
|
| 137 | + echo "=== Rewriting internal dylib references ===" |
| 138 | + for dylib in "$FW_DIR"/*.dylib; do |
| 139 | + [ -f "$dylib" ] || continue |
| 140 | + for linked in $(otool -L "$dylib" | awk 'NR>1 {print $1}' | grep "$BREW_PREFIX" || true); do |
| 141 | + base=$(basename "$linked") |
| 142 | + if [ -f "$FW_DIR/$base" ]; then |
| 143 | + install_name_tool -change "$linked" "@executable_path/../Frameworks/$base" "$dylib" |
| 144 | + fi |
| 145 | + done |
| 146 | + done |
| 147 | +
|
| 148 | + echo "=== Rewriting main executable references ===" |
| 149 | + for linked in $(otool -L "$MACOS_DIR/SerialPrograms" | awk 'NR>1 {print $1}' | grep "$BREW_PREFIX" || true); do |
| 150 | + base=$(basename "$linked") |
| 151 | + if [ -f "$FW_DIR/$base" ]; then |
| 152 | + install_name_tool -change "$linked" "@executable_path/../Frameworks/$base" "$MACOS_DIR/SerialPrograms" |
| 153 | + fi |
| 154 | + done |
| 155 | +
|
| 156 | + echo "=== Creating tarballs for build and symbols ===" |
| 157 | + mkdir -p "$(Pipeline.Workspace)/Arduino-Source-Internal/Repository/Public/build/$(cmake_preset)/cache-build" |
| 158 | + cd "$(Pipeline.Workspace)/Arduino-Source-Internal/Repository/Public/build/$(cmake_preset)" |
| 159 | + tar -czf "cache-build/macos-build-${{ parameters.architecture }}.tar.gz" SerialPrograms.app |
| 160 | + tar -czf "cache-symbols/macos-symbols-${{ parameters.architecture }}.tar.gz" cache-symbols/SerialPrograms.dSYM |
| 161 | +
|
| 162 | + echo "Deployment complete for $(architecture)" |
| 163 | + displayName: 'Deploy app' |
| 164 | + condition: succeeded() |
| 165 | +
|
| 166 | + - task: Cache@2 |
| 167 | + displayName: 'Cache the build artifact' |
| 168 | + inputs: |
| 169 | + key: 'macos-build-${{ parameters.architecture }} | "$(Build.BuildId)"' |
| 170 | + path: '$(Pipeline.Workspace)/Arduino-Source-Internal/Repository/Public/build/$(cmake_preset)/cache-build' |
| 171 | + condition: succeeded() |
| 172 | + |
| 173 | + - task: Cache@2 |
| 174 | + displayName: 'Cache debug symbols' |
| 175 | + inputs: |
| 176 | + key: 'macos-symbols-${{ parameters.architecture }} | "$(Build.BuildId)"' |
| 177 | + path: '$(Pipeline.Workspace)/Arduino-Source-Internal/Repository/Public/build/$(cmake_preset)/cache-symbols' |
| 178 | + condition: succeeded() |
0 commit comments