Build-iOS.command 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/bash
  2. # CMake-powered script for compiling iOS builds of ENET
  3. # Script written by Coburn (SoftwareGuy) as part of the forked
  4. # version of upstream ENET-CSharp tree.
  5. # Licensed under MIT. Don't be a code thief.
  6. OLDDIR=$(pwd)
  7. CMAKE=$(which cmake)
  8. CODE_ROOT=$(pwd)
  9. UPPER_ROOT="$(pwd)/.."
  10. DEBUG_STATUS=0
  11. # Change this to OS64 for ARM64 only builds, OS for ARMv7 + ARM64 builds
  12. DEV_TYPE="OS"
  13. # Change this for Release/Debug versions
  14. BUILD_TYPE="Release"
  15. # Banner
  16. echo "-------------"
  17. echo "iOS Build Script for ENET, by Coburn (SoftwareGuy)"
  18. echo "Make sure you get the latest from http://github.com/SoftwareGuy/ENet-CSharp"
  19. echo "This script is beta quality and may break. Fixes welcome. Report them on the git."
  20. echo "-------------"
  21. # Phase 1
  22. if [ -d build ]
  23. then
  24. echo "Removing directory contents for a clean iOS build"
  25. rm -vrf build/*
  26. else
  27. echo "Making directory for iOS Building..."
  28. mkdir build
  29. fi
  30. # Phase 2
  31. # cd build
  32. if [ -f $CMAKE ]
  33. then
  34. echo "Setting up Xcode project for building..."
  35. if [ $BUILD_TYPE == "Debug" ]
  36. then
  37. echo "*** DEBUG TARGET: RESULTING LIBRARY WILL BE A DEBUG BUILD ***"
  38. echo ""
  39. DEBUG_STATUS=1
  40. fi
  41. cmake $CODE_ROOT -B$CODE_ROOT/build -G Xcode -DCMAKE_TOOLCHAIN_FILE=$UPPER_ROOT/MobileToolchains/ios.toolchain.cmake -DPLATFORM=OS -DENABLE_ARC=0 -DENABLE_VISIBILITY=0 -DENET_DEBUG=$DEBUG_STATUS -DENET_STATIC=1 -DENET_SHARED=0 -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO
  42. if [ $? -eq 0 ]
  43. then
  44. # Phase 3
  45. cd $CODE_ROOT/build
  46. if [ -f $(which xcodebuild) ]
  47. then
  48. [ ! -d Release-iphoneos ] && rm -rvf Release-iphoneos && mkdir Release-iphoneos
  49. [ ! -d Debug-iphoneos ] && rm -rvf Debug-iphoneos && mkdir Debug-iphoneos
  50. xcodebuild -configuration $BUILD_TYPE
  51. if [ $? -eq 0 ]
  52. then
  53. echo "*** SUCCESSFUL BUILD! ***"
  54. echo ""
  55. echo "Good show, good show. Nicely done."
  56. echo "You'll find the static library under the respective folder, "
  57. echo "ie. Release-iphoneos or Debug-iphoneos . You may also want "
  58. echo "to run a 'lipo -archs libenet.a' check on that file to "
  59. echo "ensure that your architecture has been compiled in. "
  60. else
  61. echo "*** ERROR: XCode Build Failed! Check the logs and "
  62. echo "make sure you have updated XCode. It might be simple "
  63. echo "fix, but it might also be something complex."
  64. fi
  65. else
  66. echo "*** ERROR: You don't seem to have XCode installed correctly!"
  67. echo "*** How do you expect this script to compile ENET?"
  68. fi
  69. else
  70. echo "*** ERROR: CMake reported a failure. Sorry, but we can't continue!"
  71. echo "*** Hint: Check the logs and see if it's an easy fix. Otherwise, "
  72. echo "*** file a bug report on the GitHub with what happened."
  73. fi
  74. else
  75. echo "*** ERROR: CMake is not present on your device!"
  76. echo "*** You probably need to install either the XCode Command Line tools, "
  77. echo "*** or grab a third party package manager like Homebrew and install "
  78. echo "*** a copy of CMake that way. Sorry, but we can't continue!"
  79. fi
  80. # Get back to the directory you were in.
  81. cd $pwd
  82. # Bye bye.
  83. echo ""
  84. echo "Thanks for using SoftwareGuy's fork of ENet-CSharp!"
  85. echo "Support the fork at http://github.com/SoftwareGuy/ENet-CSharp"