ios-configure-glog.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash
  2. # Copyright (c) Facebook, Inc. and its affiliates.
  3. #
  4. # This source code is licensed under the MIT license found in the
  5. # LICENSE file in the root directory of this source tree.
  6. set -e
  7. PLATFORM_NAME="${PLATFORM_NAME:-iphoneos}"
  8. CURRENT_ARCH="${CURRENT_ARCH}"
  9. if [ -z "$CURRENT_ARCH" ] || [ "$CURRENT_ARCH" == "undefined_arch" ]; then
  10. # Xcode 10 beta sets CURRENT_ARCH to "undefined_arch", this leads to incorrect linker arg.
  11. # it's better to rely on platform name as fallback because architecture differs between simulator and device
  12. if [[ "$PLATFORM_NAME" == *"simulator"* ]]; then
  13. CURRENT_ARCH="x86_64"
  14. else
  15. CURRENT_ARCH="armv7"
  16. fi
  17. fi
  18. export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"
  19. export CXX="$CC"
  20. # Remove automake symlink if it exists
  21. if [ -h "test-driver" ]; then
  22. rm test-driver
  23. fi
  24. ./configure --host arm-apple-darwin
  25. # Fix build for tvOS
  26. cat << EOF >> src/config.h
  27. /* Add in so we have Apple Target Conditionals */
  28. #ifdef __APPLE__
  29. #include <TargetConditionals.h>
  30. #include <Availability.h>
  31. #endif
  32. /* Special configuration for AppleTVOS */
  33. #if TARGET_OS_TV
  34. #undef HAVE_SYSCALL_H
  35. #undef HAVE_SYS_SYSCALL_H
  36. #undef OS_MACOSX
  37. #endif
  38. /* Special configuration for ucontext */
  39. #undef HAVE_UCONTEXT_H
  40. #undef PC_FROM_UCONTEXT
  41. #if defined(__x86_64__)
  42. #define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip
  43. #elif defined(__i386__)
  44. #define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip
  45. #endif
  46. EOF
  47. # Prepare exported header include
  48. EXPORTED_INCLUDE_DIR="exported/glog"
  49. mkdir -p exported/glog
  50. cp -f src/glog/log_severity.h "$EXPORTED_INCLUDE_DIR/"
  51. cp -f src/glog/logging.h "$EXPORTED_INCLUDE_DIR/"
  52. cp -f src/glog/raw_logging.h "$EXPORTED_INCLUDE_DIR/"
  53. cp -f src/glog/stl_logging.h "$EXPORTED_INCLUDE_DIR/"
  54. cp -f src/glog/vlog_is_on.h "$EXPORTED_INCLUDE_DIR/"