buildft.sh 4.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/bash
  2. # Compile-Freetype-For-iOS
  3. # Original Script https://github.com/jkyin/Compile-Freetype-For-iOS/blob/master/build_freetype.sh
  4. # Revised by: l'L'l
  5. #
  6. # New Features Include: auto download latest version, fixed toolchain locations, other various tweeks
  7. #
  8. # The MIT License (MIT)
  9. # Copyright (c) 2016 l'L'l
  10. BUILD_DIR=$HOME/Desktop/FreeType_iOS_Release # RELEASE_DIR
  11. mkdir -p ${BUILD_DIR}
  12. cd $BUILD_DIR
  13. PACKAGE=$"http://download.savannah.gnu.org/releases/freetype"
  14. LATEST=$(curl -fL ${PACKAGE} | grep -oE "freetype\-\d\.\d\.\d\.tar.gz" | grep -vE "sig|asc" | sed 's/">.*//g' | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tail -n 1)
  15. curl -fL ${PACKAGE}/${LATEST} | tar xzf -
  16. VERSION=$(echo $LATEST | sed 's/.tar.gz//g')
  17. cd $VERSION
  18. set -e
  19. iphoneos="5.1.1"
  20. export CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  21. ARCH="arm64"
  22. echo "---> Building ${ARCH}-${iphoneos}" | awk '/'${ARCH}'/ {print "\033[34;25;62m" $0 "\033[0m"}'
  23. export CFLAGS="-arch ${ARCH} -pipe -mdynamic-no-pic -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=$iphoneos -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"
  24. export AR="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar"
  25. export LDFLAGS="-arch ${ARCH} -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -miphoneos-version-min=7.0"
  26. ./configure --host="aarch64-apple-darwin" --enable-static=yes --enable-shared=no
  27. make clean
  28. make
  29. cp objs/.libs/libfreetype.a "${BUILD_DIR}/libfreetype-${ARCH}.a"
  30. build_one="$ARCH"
  31. ARCH="armv7"
  32. echo "---> Building ${ARCH}-${iphoneos}" | awk '/'${ARCH}'/ {print "\033[34;25;62m" $0 "\033[0m"}'
  33. export CFLAGS="-arch ${ARCH} -pipe -mdynamic-no-pic -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=$iphoneos -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"
  34. export AR="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar"
  35. export LDFLAGS="-arch ${ARCH} -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -miphoneos-version-min=$iphoneos"
  36. ./configure --host="${ARCH}-apple-darwin" --enable-static=yes --enable-shared=no
  37. make clean
  38. make
  39. cp objs/.libs/libfreetype.a "${BUILD_DIR}/libfreetype-${ARCH}.a"
  40. build_two="$ARCH"
  41. iphoneos="7.0"
  42. ARCH="i386"
  43. echo "---> Building ${ARCH}-${iphoneos}" | awk '/'${ARCH}'/ {print "\033[34;25;62m" $0 "\033[0m"}'
  44. export CFLAGS="-arch ${ARCH} -pipe -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=$iphoneos -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
  45. export LDFLAGS="-arch ${ARCH} -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk -miphoneos-version-min=$iphoneos"
  46. ./configure --disable-shared --enable-static --host="${ARCH}-apple-darwin"
  47. make clean
  48. make
  49. cp objs/.libs/libfreetype.a "${BUILD_DIR}/libfreetype-${ARCH}.a"
  50. build_three="$ARCH"
  51. ARCH="x86_64"
  52. echo "---> Building ${ARCH}-${iphoneos}" | awk '/'${ARCH}'/ {print "\033[34;25;62m" $0 "\033[0m"}'
  53. export CFLAGS="-arch ${ARCH} -pipe -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=$iphoneos -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
  54. export LDFLAGS="-arch ${ARCH} -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk -miphoneos-version-min=$iphoneos"
  55. ./configure --disable-shared --enable-static --host="${ARCH}-apple-darwin"
  56. make clean
  57. make
  58. cp objs/.libs/libfreetype.a "${BUILD_DIR}/libfreetype-${ARCH}.a"
  59. build_four="$ARCH"
  60. echo "---> Success: $build_one $build_two $build_three $build_four" | awk '/Success/ {print "\033[37;35;53m" $0 "\033[0m"}'
  61. lipo -create "${BUILD_DIR}/libfreetype-armv7.a" "${BUILD_DIR}/libfreetype-arm64.a" "${BUILD_DIR}/libfreetype-i386.a" "${BUILD_DIR}/libfreetype-x86_64.a" -output "${BUILD_DIR}/libfreetype.a"
  62. lipolog="$(lipo -info ${BUILD_DIR}/libfreetype.a)"
  63. echo "---> $lipolog" | awk '/Arch/ {print "\033[32;35;52m" $0 "\033[0m"}'
  64. echo "---> Build Process Complete!" | awk '/!/ {print "\033[36;35;54m" $0 "\033[0m"}'