BuildMacOS.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/bin/bash
  2. export ROOT=`pwd`
  3. export NCORES=`sysctl -n hw.ncpu`
  4. export CMAKE_INSTALLED=`which cmake`
  5. # Check if CMake is installed
  6. if [[ -z "$CMAKE_INSTALLED" ]]
  7. then
  8. echo "Can't find CMake. Either is not installed or not in the PATH. Aborting!"
  9. exit -1
  10. fi
  11. while getopts ":ih" opt; do
  12. case ${opt} in
  13. i )
  14. export BUILD_IMAGE="1"
  15. ;;
  16. h ) echo "Usage: ./BuildMacOS.sh [-i]"
  17. echo " -i: Generate DMG image (optional)"
  18. exit 0
  19. ;;
  20. esac
  21. done
  22. # mkdir build
  23. if [ ! -d "build" ]
  24. then
  25. mkdir build
  26. fi
  27. echo -n "[1/9] Updating submodules..."
  28. {
  29. # update submodule profiles
  30. pushd resources/profiles
  31. git submodule update --init
  32. popd
  33. } > $ROOT/build/Build.log # Capture all command output
  34. echo "done"
  35. echo -n "[2/9] Changing date in version..."
  36. {
  37. # change date in version
  38. sed "s/+UNKNOWN/_$(date '+%F')/" version.inc > version.date.inc
  39. mv version.date.inc version.inc
  40. } &> $ROOT/build/Build.log # Capture all command output
  41. echo "done"
  42. # mkdir in deps
  43. if [ ! -d "deps/build" ]
  44. then
  45. mkdir deps/build
  46. fi
  47. echo -n "[3/9] Configuring dependencies..."
  48. {
  49. # cmake deps
  50. pushd deps/build
  51. cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13"
  52. } &> $ROOT/build/Build.log # Capture all command output
  53. echo "done"
  54. echo -n "[4/9] Building dependencies..."
  55. {
  56. # make deps
  57. make -j$NCORES
  58. } &> $ROOT/build/Build.log # Capture all command output
  59. echo "done"
  60. echo -n "[5/9] Renaming wxscintilla library..."
  61. {
  62. # rename wxscintilla
  63. pushd destdir/usr/local/lib
  64. cp libwxscintilla-3.1.a libwx_osx_cocoau_scintilla-3.1.a
  65. popd
  66. } &> $ROOT/build/Build.log # Capture all command output
  67. echo "done"
  68. echo -n "[6/9] Cleaning dependencies..."
  69. {
  70. # clean deps
  71. rm -rf dep_*
  72. popd
  73. } &> $ROOT/build/Build.log # Capture all command output
  74. echo "done"
  75. echo -n "[7/9] Configuring Slic3r..."
  76. {
  77. # cmake
  78. pushd build
  79. cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" -DSLIC3R_STATIC=1
  80. } &> $ROOT/build/Build.log # Capture all command output
  81. echo "done"
  82. echo -n "[8/9] Building Slic3r..."
  83. {
  84. # make Slic3r
  85. make -j$NCORES Slic3r
  86. # make .mo
  87. make gettext_po_to_mo
  88. } &> $ROOT/build/Build.log # Capture all command output
  89. echo "done"
  90. # Give proper permissions to script
  91. chmod 755 $ROOT/build/src/BuildMacOSImage.sh
  92. if [[ -n "$BUILD_IMAGE" ]]
  93. then
  94. $ROOT/build/src/BuildMacOSImage.sh -i
  95. else
  96. $ROOT/build/src/BuildMacOSImage.sh
  97. fi