BuildMacOS.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. echo "\nls /usr/local/opt:\n"
  37. ls /usr/local/opt
  38. echo "\nls /usr/local/opt/zstd:\n"
  39. ls /usr/local/opt/zstd
  40. echo "\nls /usr/local/opt/zstd/lib:\n"
  41. ls /usr/local/opt/zstd/lib
  42. echo "\nbrew --prefix zstd:\n"
  43. brew --prefix zstd
  44. # mkdir build
  45. if [ ! -d "build" ]
  46. then
  47. mkdir build
  48. fi
  49. echo -n "[1/9] Updating submodules..."
  50. {
  51. # update submodule profiles
  52. pushd resources/profiles
  53. git submodule update --init
  54. popd
  55. } #> $ROOT/build/Build.log # Capture all command output
  56. echo "done"
  57. echo -n "[2/9] Changing date in version..."
  58. {
  59. # change date in version
  60. sed "s/+UNKNOWN/_$(date '+%F')/" version.inc > version.date.inc
  61. mv version.date.inc version.inc
  62. } #&> $ROOT/build/Build.log # Capture all command output
  63. echo "done"
  64. # mkdir in deps
  65. if [ ! -d "deps/build" ]
  66. then
  67. mkdir deps/build
  68. fi
  69. echo -n "[3/9] Configuring dependencies..."
  70. {
  71. BUILD_ARGS=""
  72. if [[ -n "$BUILD_ARCH" ]]
  73. then
  74. BUILD_ARGS="${BUILD_ARGS} -DCMAKE_OSX_ARCHITECTURES:STRING=${BUILD_ARCH}"
  75. fi
  76. if [[ -n "$BUILD_DEBUG" ]]
  77. then
  78. BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug"
  79. fi
  80. # cmake deps
  81. echo "Cmake command: cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=\"10.13\" ${BUILD_ARCH} "
  82. pushd deps/build
  83. cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" $BUILD_ARGS
  84. echo "ls deps/build:"
  85. ls -al
  86. echo "ls deps/build/dep_GLEW-prefix"
  87. ls -al dep_GLEW-prefix
  88. } #&> $ROOT/build/Build.log # Capture all command output
  89. echo "done"
  90. echo -n "[4/9] Building dependencies..."
  91. {
  92. # make deps
  93. make -j$NCORES
  94. } #&> $ROOT/build/Build.log # Capture all command output
  95. echo "done"
  96. echo -n "[5/9] Renaming wxscintilla library..."
  97. {
  98. # rename wxscintilla
  99. pushd destdir/usr/local/lib
  100. cp libwxscintilla-3.1.a libwx_osx_cocoau_scintilla-3.1.a
  101. echo "ls deps/build/destdir/usr/local/lib"
  102. ls -al
  103. popd
  104. } #&> $ROOT/build/Build.log # Capture all command output
  105. echo "done"
  106. echo -n "[6/9] Cleaning dependencies..."
  107. {
  108. # clean deps
  109. rm -rf dep_*
  110. popd
  111. } #&> $ROOT/build/Build.log # Capture all command output
  112. echo "done"
  113. echo -n "[7/9] Configuring Slic3r..."
  114. {
  115. BUILD_ARGS=""
  116. if [[ -n "$BUILD_ARCH" ]]
  117. then
  118. BUILD_ARGS="${BUILD_ARGS} -DCMAKE_OSX_ARCHITECTURES=${BUILD_ARCH}"
  119. fi
  120. if [[ -n "$BUILD_DEBUG" ]]
  121. then
  122. BUILD_ARGS="-DCMAKE_BUILD_TYPE=Debug ${BUILD_ARGS}"
  123. fi
  124. # cmake
  125. pushd build
  126. echo "Cmake command: cmake .. -DCMAKE_PREFIX_PATH=\"$PWD/../deps/build/destdir/usr/local\" -DCMAKE_OSX_DEPLOYMENT_TARGET=\"10.13\" -DSLIC3R_STATIC=1 ${BUILD_ARGS}"
  127. cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" -DSLIC3R_STATIC=1 ${BUILD_ARGS}
  128. } #&> $ROOT/build/Build.log # Capture all command output
  129. echo "done"
  130. echo -n "[8/9] Building Slic3r..."
  131. {
  132. # make Slic3r
  133. make -j$NCORES Slic3r
  134. # make .mo
  135. make gettext_po_to_mo
  136. } #&> $ROOT/build/Build.log # Capture all command output
  137. echo "done"
  138. echo "ls ROOT"
  139. ls $ROOT
  140. echo "ls ROOT/build"
  141. ls $ROOT/build
  142. echo "ls -al ROOT/build/src"
  143. ls -al $ROOT/build/src
  144. # Give proper permissions to script
  145. chmod 755 $ROOT/build/src/BuildMacOSImage.sh
  146. if [[ -n "$BUILD_IMAGE" ]]
  147. then
  148. $ROOT/build/src/BuildMacOSImage.sh -i
  149. else
  150. $ROOT/build/src/BuildMacOSImage.sh
  151. fi
  152. echo "ls -al ROOT/build"
  153. ls -al $ROOT/build