NeuralAmpModelerPlugin

Plugin for Neural Amp Modeler
Log | Files | Refs | Submodules | README | LICENSE

makedist-mac.sh (10488B)


      1 #! /bin/sh
      2 
      3 # this script requires xcpretty https://github.com/xcpretty/xcpretty
      4 
      5 BASEDIR=$(dirname $0)
      6 
      7 cd $BASEDIR/..
      8 
      9 if [ -d build-mac ]; then
     10   sudo rm -f -R build-mac
     11 fi
     12 
     13 #---------------------------------------------------------------------------------------------------------
     14 #variables
     15 
     16 IPLUG2_ROOT=../iPlug2
     17 XCCONFIG=$IPLUG2_ROOT/../common-mac.xcconfig
     18 SCRIPTS=$IPLUG2_ROOT/Scripts
     19 
     20 # CODESIGN disabled by default. 
     21 CODESIGN=0
     22 
     23 # macOS codesigning/notarization
     24 NOTARIZE_BUNDLE_ID=com.AcmeInc.TemplateProject
     25 NOTARIZE_BUNDLE_ID_DEMO=com.AcmeInc.TemplateProject.DEMO
     26 APP_SPECIFIC_ID=TODO
     27 APP_SPECIFIC_PWD=TODO
     28 
     29 # AAX/PACE wraptool codesigning
     30 ILOK_ID=TODO
     31 ILOK_PWD=TODO
     32 WRAP_GUID=TODO
     33 
     34 DEMO=0
     35 if [ "$1" == "demo" ]; then
     36   DEMO=1
     37 fi
     38 
     39 BUILD_INSTALLER=1
     40 if [ "$2" == "zip" ]; then
     41   BUILD_INSTALLER=0
     42 fi
     43 
     44 VERSION=`echo | grep PLUG_VERSION_HEX config.h`
     45 VERSION=${VERSION//\#define PLUG_VERSION_HEX }
     46 VERSION=${VERSION//\'}
     47 MAJOR_VERSION=$(($VERSION & 0xFFFF0000))
     48 MAJOR_VERSION=$(($MAJOR_VERSION >> 16))
     49 MINOR_VERSION=$(($VERSION & 0x0000FF00))
     50 MINOR_VERSION=$(($MINOR_VERSION >> 8))
     51 BUG_FIX=$(($VERSION & 0x000000FF))
     52 
     53 FULL_VERSION=$MAJOR_VERSION"."$MINOR_VERSION"."$BUG_FIX
     54 
     55 PLUGIN_NAME=`echo | grep BUNDLE_NAME config.h`
     56 PLUGIN_NAME=${PLUGIN_NAME//\#define BUNDLE_NAME }
     57 PLUGIN_NAME=${PLUGIN_NAME//\"}
     58 
     59 ARCHIVE_NAME=$PLUGIN_NAME-v$FULL_VERSION-mac
     60 
     61 if [ $DEMO == 1 ]; then
     62   ARCHIVE_NAME=$ARCHIVE_NAME-demo
     63 fi
     64 
     65 # TODO: use get_archive_name script
     66 # if [ $DEMO == 1 ]; then
     67 #   ARCHIVE_NAME=`python3 ${SCRIPTS}/get_archive_name.py ${PLUGIN_NAME} mac demo`
     68 # else
     69 #   ARCHIVE_NAME=`python3 ${SCRIPTS}/get_archive_name.py ${PLUGIN_NAME} mac full`
     70 # fi
     71 
     72 VST2=`echo | grep VST2_PATH $XCCONFIG`
     73 VST2=$HOME${VST2//\VST2_PATH = \$(HOME)}/$PLUGIN_NAME.vst
     74 
     75 VST3=`echo | grep VST3_PATH $XCCONFIG`
     76 VST3=$HOME${VST3//\VST3_PATH = \$(HOME)}/$PLUGIN_NAME.vst3
     77 
     78 AU=`echo | grep AU_PATH $XCCONFIG`
     79 AU=$HOME${AU//\AU_PATH = \$(HOME)}/$PLUGIN_NAME.component
     80 
     81 APP=`echo | grep APP_PATH $XCCONFIG`
     82 APP=$HOME${APP//\APP_PATH = \$(HOME)}/$PLUGIN_NAME.app
     83 
     84 # Dev build folder
     85 AAX=`echo | grep AAX_PATH $XCCONFIG`
     86 AAX=${AAX//\AAX_PATH = }/$PLUGIN_NAME.aaxplugin
     87 AAX_FINAL="/Library/Application Support/Avid/Audio/Plug-Ins/$PLUGIN_NAME.aaxplugin"
     88 
     89 PKG="build-mac/installer/$PLUGIN_NAME Installer.pkg"
     90 PKG_US="build-mac/installer/$PLUGIN_NAME Installer.unsigned.pkg"
     91 
     92 CERT_ID=`echo | grep CERTIFICATE_ID $XCCONFIG`
     93 CERT_ID=${CERT_ID//\CERTIFICATE_ID = }
     94 DEV_ID_APP_STR="Developer ID Application: ${CERT_ID}"
     95 DEV_ID_INST_STR="Developer ID Installer: ${CERT_ID}"
     96 
     97 echo $VST2
     98 echo $VST3
     99 echo $AU
    100 echo $APP
    101 echo $AAX
    102 
    103 if [ $DEMO == 1 ]; then
    104  echo "making $PLUGIN_NAME version $FULL_VERSION DEMO mac distribution..."
    105 #   cp "resources/img/AboutBox_Demo.png" "resources/img/AboutBox.png"
    106 else
    107  echo "making $PLUGIN_NAME version $FULL_VERSION mac distribution..."
    108 #   cp "resources/img/AboutBox_Registered.png" "resources/img/AboutBox.png"
    109 fi
    110 
    111 sleep 2
    112 
    113 echo "touching source to force recompile"
    114 echo ""
    115 touch *.cpp
    116 
    117 #---------------------------------------------------------------------------------------------------------
    118 #remove existing binaries
    119 
    120 echo "remove existing binaries"
    121 echo ""
    122 
    123 if [ -d $APP ]; then
    124   sudo rm -f -R -f $APP
    125 fi
    126 
    127 if [ -d $AU ]; then
    128  sudo rm -f -R $AU
    129 fi
    130 
    131 if [ -d $VST2 ]; then
    132   sudo rm -f -R $VST2
    133 fi
    134 
    135 if [ -d $VST3 ]; then
    136   sudo rm -f -R $VST3
    137 fi
    138 
    139 if [ -d "${AAX}" ]; then
    140   sudo rm -f -R "${AAX}"
    141 fi
    142 
    143 if [ -d "${AAX_FINAL}" ]; then
    144   sudo rm -f -R "${AAX_FINAL}"
    145 fi
    146 
    147 #---------------------------------------------------------------------------------------------------------
    148 # build xcode project. Change target to build individual formats, or add to All target in the xcode project
    149 
    150 xcodebuild -project ./projects/$PLUGIN_NAME-macOS.xcodeproj -xcconfig ./config/$PLUGIN_NAME-mac.xcconfig DEMO_VERSION=$DEMO -target "All" -UseModernBuildSystem=NO -configuration Release | tee build-mac.log | xcpretty #&& exit ${PIPESTATUS[0]}
    151 
    152 if [ "${PIPESTATUS[0]}" -ne "0" ]; then
    153   echo "ERROR: build failed, aborting"
    154   echo ""
    155   # cat build-mac.log
    156   exit 1
    157 else
    158   rm build-mac.log
    159 fi
    160 
    161 #---------------------------------------------------------------------------------------------------------
    162 # set bundle icons - http://www.hamsoftengineering.com/codeSharing/SetFileIcon/SetFileIcon.html
    163 
    164 echo "setting icons"
    165 echo ""
    166 
    167 if [ -d $AU ]; then
    168   ./$SCRIPTS/SetFileIcon -image resources/$PLUGIN_NAME.icns -file $AU
    169 fi
    170 
    171 if [ -d $VST2 ]; then
    172   ./$SCRIPTS/SetFileIcon -image resources/$PLUGIN_NAME.icns -file $VST2
    173 fi
    174 
    175 if [ -d $VST3 ]; then
    176   ./$SCRIPTS/SetFileIcon -image resources/$PLUGIN_NAME.icns -file $VST3
    177 fi
    178 
    179 if [ -d "${AAX}" ]; then
    180   ./$SCRIPTS/SetFileIcon -image resources/$PLUGIN_NAME.icns -file "${AAX}"
    181 fi
    182 
    183 #---------------------------------------------------------------------------------------------------------
    184 #strip symbols from binaries
    185 
    186 echo "stripping binaries"
    187 echo ""
    188 
    189 if [ -d $APP ]; then
    190   strip -x $APP/Contents/MacOS/$PLUGIN_NAME
    191 fi
    192 
    193 if [ -d $AU ]; then
    194   strip -x $AU/Contents/MacOS/$PLUGIN_NAME
    195 fi
    196 
    197 if [ -d $VST2 ]; then
    198   strip -x $VST2/Contents/MacOS/$PLUGIN_NAME
    199 fi
    200 
    201 if [ -d $VST3 ]; then
    202   strip -x $VST3/Contents/MacOS/$PLUGIN_NAME
    203 fi
    204 
    205 if [ -d "${AAX}" ]; then
    206   strip -x "${AAX}/Contents/MacOS/$PLUGIN_NAME"
    207 fi
    208 
    209 if [ $CODESIGN == 1 ]; then
    210   #---------------------------------------------------------------------------------------------------------
    211   # code sign AAX binary with wraptool
    212 
    213   # echo "copying AAX ${PLUGIN_NAME} from 3PDev to main AAX folder"
    214   # sudo cp -p -R "${AAX}" "${AAX_FINAL}"
    215   # mkdir "${AAX_FINAL}/Contents/Factory Presets/"
    216   
    217   # echo "code sign AAX binary"
    218   # /Applications/PACEAntiPiracy/Eden/Fusion/Current/bin/wraptool sign --verbose --account $ILOK_ID --password $ILOK_PWD --wcguid $WRAP_GUID --signid "${DEV_ID_APP_STR}" --in "${AAX_FINAL}" --out "${AAX_FINAL}"
    219 
    220   #---------------------------------------------------------------------------------------------------------
    221 
    222   #---------------------------------------------------------------------------------------------------------
    223   echo "code-sign binaries"
    224   echo ""
    225 
    226   codesign --force -s "${DEV_ID_APP_STR}" -v $APP --deep --strict --options=runtime #hardened runtime for app
    227   xattr -cr $AU 
    228   codesign --force -s "${DEV_ID_APP_STR}" -v $AU --deep --strict
    229   # xattr -cr $VST2 
    230   # codesign --force -s "${DEV_ID_APP_STR}" -v $VST2 --deep --strict
    231   xattr -cr $VST3 
    232   codesign --force -s "${DEV_ID_APP_STR}" -v $VST3 --deep --strict
    233   #---------------------------------------------------------------------------------------------------------
    234 fi
    235 
    236 if [ $BUILD_INSTALLER == 1 ]; then
    237   #---------------------------------------------------------------------------------------------------------
    238   # installer
    239 
    240   sudo rm -R -f build-mac/$PLUGIN_NAME-*.dmg
    241 
    242   echo "building installer"
    243   echo ""
    244 
    245   ./scripts/makeinstaller-mac.sh $FULL_VERSION
    246 
    247   if [ $CODESIGN == 1 ]; then
    248     echo "code-sign installer for Gatekeeper on macOS 10.8+"
    249     echo ""
    250     mv "${PKG}" "${PKG_US}"
    251     productsign --sign "${DEV_ID_INST_STR}" "${PKG_US}" "${PKG}"
    252     rm -R -f "${PKG_US}"
    253   fi
    254 
    255   #set installer icon
    256   ./$SCRIPTS/SetFileIcon -image resources/$PLUGIN_NAME.icns -file "${PKG}"
    257 
    258   #---------------------------------------------------------------------------------------------------------
    259   # make dmg, can use dmgcanvas http://www.araelium.com/dmgcanvas/ to make a nice dmg, fallback to hdiutil
    260   echo "building dmg"
    261   echo ""
    262 
    263   if [ -d installer/$PLUGIN_NAME.dmgCanvas ]; then
    264     dmgcanvas installer/$PLUGIN_NAME.dmgCanvas build-mac/$ARCHIVE_NAME.dmg
    265   else
    266     cp installer/changelog.txt build-mac/installer/
    267     cp installer/known-issues.txt build-mac/installer/
    268     cp "manual/$PLUGIN_NAME manual.pdf" build-mac/installer/
    269     hdiutil create build-mac/$ARCHIVE_NAME.dmg -format UDZO -srcfolder build-mac/installer/ -ov -anyowners -volname $PLUGIN_NAME
    270   fi
    271 
    272   sudo rm -R -f build-mac/installer/
    273 
    274   if [ $CODESIGN == 1 ]; then
    275     #---------------------------------------------------------------------------------------------------------
    276     #notarize dmg
    277     echo "notarizing"
    278     echo ""
    279     # you need to create an app-specific id/password https://support.apple.com/en-us/HT204397
    280     # arg 1 Set to the dmg path
    281     # arg 2 Set to a bundle ID (doesn't have to match your )
    282     # arg 3 Set to the app specific Apple ID username/email
    283     # arg 4 Set to the app specific Apple password  
    284     PWD=`pwd`
    285 
    286     if [ $DEMO == 1 ]; then
    287       ./$SCRIPTS/notarise.sh "${PWD}/build-mac" "${PWD}/build-mac/${ARCHIVE_NAME}.dmg" $NOTARIZE_BUNDLE_ID $APP_SPECIFIC_ID $APP_SPECIFIC_PWD
    288     else
    289       ./$SCRIPTS/notarise.sh "${PWD}/build-mac" "${PWD}/build-mac/${ARCHIVE_NAME}.dmg" $NOTARIZE_BUNDLE_ID_DEMO $APP_SPECIFIC_ID $APP_SPECIFIC_PWD
    290     fi
    291 
    292     if [ "${PIPESTATUS[0]}" -ne "0" ]; then
    293       echo "ERROR: notarize script failed, aborting"
    294       exit 1
    295     fi
    296 
    297   fi
    298 else
    299   #---------------------------------------------------------------------------------------------------------
    300   # zip
    301 
    302   if [ -d build-mac/zip ]; then
    303     rm -R build-mac/zip
    304   fi
    305 
    306   mkdir -p build-mac/zip
    307 
    308   if [ -d $APP ]; then
    309     cp -R $APP build-mac/zip/$PLUGIN_NAME.app
    310   fi
    311 
    312   if [ -d $AU ]; then
    313     cp -R $AU build-mac/zip/$PLUGIN_NAME.component
    314   fi
    315 
    316   if [ -d $VST2 ]; then
    317     cp -R $VST2 build-mac/zip/$PLUGIN_NAME.vst
    318   fi
    319 
    320   if [ -d $VST3 ]; then
    321     cp -R $VST3 build-mac/zip/$PLUGIN_NAME.vst3
    322   fi
    323 
    324   if [ -d "${AAX_FINAL}" ]; then
    325     cp -R $AAX_FINAL build-mac/zip/$PLUGIN_NAME.aaxplugin
    326   fi
    327 
    328   echo "zipping binaries..."
    329   echo ""
    330   ditto -c -k build-mac/zip build-mac/$ARCHIVE_NAME.zip
    331   rm -R build-mac/zip
    332 fi
    333 
    334 #---------------------------------------------------------------------------------------------------------
    335 # dSYMs
    336 sudo rm -R -f build-mac/*-dSYMs.zip
    337 
    338 echo "packaging dSYMs"
    339 echo ""
    340 zip -r ./build-mac/$ARCHIVE_NAME-dSYMs.zip ./build-mac/*.dSYM
    341 
    342 #---------------------------------------------------------------------------------------------------------
    343 
    344 # prepare out folder for CI
    345 
    346 echo "preparing output folder"
    347 echo ""
    348 mkdir -p ./build-mac/out
    349 if [ -f ./build-mac/$ARCHIVE_NAME.dmg ]; then
    350   mv ./build-mac/$ARCHIVE_NAME.dmg ./build-mac/out
    351 fi
    352 mv ./build-mac/*.zip ./build-mac/out
    353 
    354 #---------------------------------------------------------------------------------------------------------
    355 
    356 #if [ $DEMO == 1 ]
    357 #then
    358 #  git checkout installer/TemplateProject.iss
    359 #  git checkout installer/TemplateProject.pkgproj
    360 #  git checkout resources/img/AboutBox.png
    361 #fi
    362 
    363 echo "done!"
    364 echo ""