Build-iOS.command 2.9 KB

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