BuildMacOS.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #!/bin/bash
  2. export ROOT=`pwd`
  3. export NCORES=`sysctl -n hw.ncpu`
  4. export CMAKE_INSTALLED=`which cmake`
  5. #export ARCH=$(uname -m)
  6. # Check if CMake is installed
  7. if [[ -z "$CMAKE_INSTALLED" ]]
  8. then
  9. echo "Can't find CMake. Either is not installed or not in the PATH. Aborting!"
  10. exit -1
  11. fi
  12. while getopts ":iaxbh" opt; do
  13. case ${opt} in
  14. i )
  15. export BUILD_IMAGE="1"
  16. ;;
  17. a )
  18. export BUILD_ARCH="arm64"
  19. ;;
  20. x )
  21. export BUILD_ARCH="x86_64"
  22. ;;
  23. b )
  24. export BUILD_DEBUG="1"
  25. ;;
  26. h ) echo "Usage: ./BuildMacOS.sh [-i]"
  27. echo " -i: Generate DMG image (optional)"
  28. echo " -a: Build for arm64 (Apple Silicon)"
  29. echo " -x: Build for x86_64 (Intel)"
  30. echo " -b: Build with debug symbols"
  31. exit 0
  32. ;;
  33. esac
  34. done
  35. echo "Build architecture: ${BUILD_ARCH}"
  36. # mkdir build
  37. if [ ! -d "build" ]
  38. then
  39. mkdir build
  40. fi
  41. echo -n "[1/9] Updating submodules..."
  42. {
  43. # update submodule profiles
  44. pushd resources/profiles
  45. git submodule update --init
  46. popd
  47. } #> $ROOT/build/Build.log # Capture all command output
  48. echo "done"
  49. echo -n "[2/9] Changing date in version..."
  50. {
  51. # change date in version
  52. sed "s/+UNKNOWN/_$(date '+%F')/" version.inc > version.date.inc
  53. mv version.date.inc version.inc
  54. } #&> $ROOT/build/Build.log # Capture all command output
  55. echo "done"
  56. # mkdir in deps
  57. if [ ! -d "deps/build" ]
  58. then
  59. mkdir deps/build
  60. fi
  61. echo -n "[3/9] Configuring dependencies..."
  62. {
  63. BUILD_ARGS=""
  64. if [[ -n "$BUILD_ARCH" ]]
  65. then
  66. BUILD_ARGS="${BUILD_ARGS} -DCMAKE_OSX_ARCHITECTURES:STRING=${BUILD_ARCH}"
  67. fi
  68. if [[ -n "$BUILD_DEBUG" ]]
  69. then
  70. BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug"
  71. fi
  72. # cmake deps
  73. echo "Cmake command: cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=\"10.13\" ${BUILD_ARCH} "
  74. pushd deps/build
  75. cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" $BUILD_ARGS
  76. echo "ls deps/build:"
  77. ls -al
  78. echo "ls deps/build/dep_GLEW-prefix"
  79. ls -al dep_GLEW-prefix
  80. } #&> $ROOT/build/Build.log # Capture all command output
  81. echo "done"
  82. echo -n "[4/9] Building dependencies..."
  83. {
  84. # make deps
  85. make -j$NCORES
  86. } #&> $ROOT/build/Build.log # Capture all command output
  87. echo "done"
  88. echo -n "[5/9] Renaming wxscintilla library..."
  89. {
  90. # rename wxscintilla
  91. pushd destdir/usr/local/lib
  92. cp libwxscintilla-3.1.a libwx_osx_cocoau_scintilla-3.1.a
  93. echo "ls deps/build/destdir/usr/local/lib"
  94. ls -al
  95. popd
  96. } #&> $ROOT/build/Build.log # Capture all command output
  97. echo "done"
  98. echo -n "[6/9] Cleaning dependencies..."
  99. {
  100. # clean deps
  101. rm -rf dep_*
  102. popd
  103. } #&> $ROOT/build/Build.log # Capture all command output
  104. echo "done"
  105. echo -n "[7/9] Configuring Slic3r..."
  106. {
  107. BUILD_ARGS=""
  108. if [[ -n "$BUILD_ARCH" ]]
  109. then
  110. BUILD_ARGS="${BUILD_ARGS} -DCMAKE_OSX_ARCHITECTURES=${BUILD_ARCH}"
  111. fi
  112. if [[ -n "$BUILD_DEBUG" ]]
  113. then
  114. BUILD_ARGS="-DCMAKE_BUILD_TYPE=Debug ${BUILD_ARGS}"
  115. fi
  116. # cmake
  117. pushd build
  118. echo "Cmake command: cmake .. -DCMAKE_PREFIX_PATH=\"$PWD/../deps/build/destdir/usr/local\" -DCMAKE_OSX_DEPLOYMENT_TARGET=\"10.13\" -DSLIC3R_STATIC=1 ${BUILD_ARGS}"
  119. cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" -DSLIC3R_STATIC=1 ${BUILD_ARGS}
  120. } #&> $ROOT/build/Build.log # Capture all command output
  121. echo "done"
  122. echo -n "[8/9] Building Slic3r..."
  123. {
  124. # make Slic3r
  125. make -j$NCORES Slic3r
  126. # make .mo
  127. make gettext_po_to_mo
  128. } #&> $ROOT/build/Build.log # Capture all command output
  129. echo "done"
  130. echo "ls ROOT"
  131. ls $ROOT
  132. echo "ls ROOT/build"
  133. ls $ROOT/build
  134. echo "ls -al ROOT/build/src"
  135. ls -al $ROOT/build/src
  136. # Give proper permissions to script
  137. chmod 755 $ROOT/build/src/BuildMacOSImage.sh
  138. if [[ -n "$BUILD_IMAGE" ]]
  139. then
  140. $ROOT/build/src/BuildMacOSImage.sh -i
  141. else
  142. $ROOT/build/src/BuildMacOSImage.sh
  143. fi
  144. echo "ls -al ROOT/build"
  145. ls -al $ROOT/build