File indexing completed on 2024-05-19 04:32:41
0001 #!/bin/bash 0002 0003 # Unofficial bash strict mode -- http://redsymbol.net/articles/unofficial-bash-strict-mode/ 0004 set -euo pipefail 0005 IFS=$'\n\t' 0006 0007 0008 # Install dependencies 0009 brew cask uninstall oclint || true # conflicts with gcc 0010 brew install gsl netcdf cfitsio libgetdata 0011 0012 0013 # BUG: macdeployqt is broken in brew -- https://github.com/Homebrew/homebrew-core/issues/3219 0014 pushd ~ 0015 curl -O http://hog.astro.utoronto.ca/kst/qt_5.9.1_mac.tar.bz2 0016 tar -xf ./qt_5.9.1_mac.tar.bz2 0017 popd 0018 export PATH="~/qt_5.9.1_mac/bin/:$PATH" 0019 0020 0021 # Build kst 0022 ./get-translations 0023 0024 mkdir -p build 0025 cd build 0026 rm -fr ./build # to allow us to run this script multiple times 0027 cmake -Dkst_qt5=1 -Dkst_svnversion=1 -Dkst_dataobjects=1 -Dkst_3rdparty=1 -Dkst_release=1 -Dkst_merge_files=1 .. 0028 make 0029 0030 0031 # Add Qt to kst2.app, and replace references to the Qt outside of kst2.app with references 0032 # to Qt inside kst2.app. 0033 macdeployqt ./build/bin/kst2.app 0034 0035 lib_folders=(./build/bin/kst2.app/Contents/plugins/ ./build/bin/kst2.app/Contents/Frameworks/) 0036 to_replace=() 0037 0038 # Copy external libraries to Frameworks and add the names of external libraries to to_replace. 0039 # We don't do this for Qt libraries, because macdeployqt already did that for us. 0040 for folder in "${lib_folders[@]}"; do 0041 to_copy=($(find -E $folder -regex '.*\.(dylib|so)' -type f -exec otool -L {} \; | sort | uniq | grep '^\t/usr/local' | sed -e $'s/^\t//g' | sed -e $'s/ .*//g')) 0042 echo "${to_copy[@]}" | xargs -J % cp -f % ./build/bin/kst2.app/Contents/Frameworks 0043 to_replace+=("${to_copy[@]}") 0044 chmod 755 $folder/* 0045 done 0046 0047 0048 # Remove references to external libraries. 0049 # We're really stupid here and just try to replace all external references in everything in 0050 # Frameworks and plugins. 0051 # TODO(joshua): Use otool -L to figure out what to replace 0052 for orig_lib in "${to_replace[@]}"; do 0053 new_lib=$(echo $orig_lib | sed -e 's,.*/,@rpath/,g') 0054 echo "Running install_name_tool on libraries to replace $orig_lib with $new_lib" 0055 for folder in "${lib_folders[@]}"; do 0056 files=($(find -E $folder -regex '.*\.(dylib|so)' -type f)) 0057 for file in "${files[@]}"; do 0058 install_name_tool -change $orig_lib $new_lib $file 0059 done 0060 done 0061 done 0062 0063 0064 # Zip it! 0065 date=$(date -u +"%Y.%m.%d-%H.%M") 0066 bundle_name="kst-plot-$date-macos.zip" 0067 pushd ./build/bin 0068 zip -r "../../$bundle_name" ./kst2.app 0069 popd 0070 0071 0072 # Deploy it 0073 cp ../cmake/kstdeploy.tar.gz ~ 0074 pushd ~ 0075 tar -xf kstdeploy.tar.gz 0076 popd 0077 0078 kstbinary=kst-build 0079 rm -rf $kstbinary 0080 mkdir $kstbinary 0081 cd $kstbinary 0082 git init --quiet 0083 git config user.name "travis" 0084 git config user.email travis@noreply.org 0085 git remote add origin git@github.com:Kst-plot/$kstbinary.git 0086 git fetch origin master --quiet 0087 git checkout master 0088 git branch -D macos || true 0089 git checkout -b macos 0090 cp -f ../$bundle_name . 0091 git add $bundle_name 0092 git commit --quiet -m "Update Mac binary" 0093 git push --quiet origin HEAD -f