Pre-Compile.sh 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. if test "${ACTION}" = ""; then
  2. # Debug --
  3. TARGET_BUILD_DIR="."
  4. FULL_PRODUCT_NAME="VLCKit.framework"
  5. CONTENTS_FOLDER_PATH="${FULL_PRODUCT_NAME}/Versions/A"
  6. VLC_BUILD_DIR="../../.."
  7. VLC_SRC_DIR="../../.."
  8. ACTION="build"
  9. rm -fr ${FULL_PRODUCT_NAME}
  10. # Debug --
  11. fi
  12. if test "${ACTION}" = "build"; then
  13. vlc_config="${VLC_SRC_DIR}/vlc-config"
  14. lib="lib"
  15. modules="modules"
  16. target="${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}"
  17. target_lib="${target}/${lib}" # Should we consider using a different well-known folder like shared resources?
  18. target_modules="${target}/${modules}" # Should we consider using a different well-known folder like shared resources?
  19. target_share="${target}/${share}" # Should we consider using a different well-known folder like shared resources?
  20. linked_libs=" "
  21. ##########################
  22. # @function install_library(src_lib, dest_dir)
  23. # @description Installs the specified library into the destination folder, automatically changes the references to dependencies
  24. # @param src_lib source library to copy to the destination directory
  25. # @param dest_dir destination directory where the src_lib should be copied to
  26. install_library() {
  27. if [ ${3} = "library" ]; then
  28. install_name="@loader_path/lib"
  29. else
  30. install_name="@loader_path/modules"
  31. fi
  32. if [ "${4}" != "" ]; then
  33. lib_dest="${2}/${4}"
  34. else
  35. lib_dest="${2}/`basename ${1}`"
  36. fi
  37. if test -e ${1} && ((! test -e ${lib_dest}) || test ${1} -nt ${lib_dest} ); then
  38. mkdir -p ${2}
  39. # Lets copy the library from the source folder to our new destination folder
  40. cp ${1} ${lib_dest}
  41. # Update the dynamic library so it will know where to look for the other libraries
  42. echo "Installing ${3} `basename ${lib_dest}`"
  43. # Change the reference of libvlc.1 stored in the usr directory to libvlc.dylib in the framework's library directory
  44. install_name_tool -change /usr/local/lib/libvlc.1.dylib @loader_path/../lib/libvlc.dylib ${lib_dest}
  45. install_name_tool -change @executable_path/lib/vlc_libintl.dylib @loader_path/../lib/vlc_libintl.dylib ${lib_dest}
  46. install_name_tool -id "${install_name}/`basename ${lib_dest}`" ${lib_dest}
  47. # Iterate through each installed library and modify the references to other dynamic libraries to match the framework's library directory
  48. for linked_lib in `otool -L ${lib_dest} | grep '(' | sed 's/\((.*)\)//'`; do
  49. ref_lib=`echo "${linked_lib}" | sed 's:executable_path/:loader_path/../:'`
  50. if test "${ref_lib}" != "${linked_lib}"; then
  51. install_name_tool -change ${linked_lib} ${ref_lib} ${lib_dest}
  52. fi
  53. if test `echo "${ref_lib}" | grep "^@loader_path"`; then
  54. linked_libs="${linked_libs} ${ref_lib}"
  55. fi;
  56. done
  57. fi
  58. }
  59. # @function install_library
  60. ##########################
  61. ##########################
  62. # Build the modules folder (Same as VLCKit.framework/modules in Makefile)
  63. echo "Building modules folder..."
  64. # Figure out what modules are available to install
  65. for module in `top_builddir="${VLC_BUILD_DIR}" ${vlc_config} --target plugin` ; do
  66. # Check to see that the reported module actually exists
  67. if test -n ${module}; then
  68. module_src="`dirname ${module}`/.libs/`basename ${module}`.dylib"
  69. install_library ${module_src} ${target_modules} "module"
  70. fi
  71. done
  72. # Build the modules folder
  73. ##########################
  74. ##########################
  75. # Create a symbolic link in the root of the framework
  76. mkdir -p ${target_lib}
  77. mkdir -p ${target_modules}
  78. pushd `pwd` > /dev/null
  79. cd ${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}
  80. ln -sf Versions/Current/${lib} .
  81. ln -sf Versions/Current/${modules} .
  82. popd > /dev/null
  83. # Create a symbolic link in the root of the framework
  84. ##########################
  85. ##########################
  86. # Build the library folder (Same as VLCKit.framework/lib in Makefile)
  87. echo "Building library folder..."
  88. for linked_lib in ${linked_libs} ; do
  89. case "${linked_lib}" in
  90. @loader_path/../lib/*)
  91. ref_lib=`echo ${linked_lib} | sed 's:@loader_path/../lib/::'`
  92. if test -e ${VLC_BUILD_DIR}/extras/contrib/vlc-lib/${ref_lib}; then
  93. src_lib=${VLC_BUILD_DIR}/extras/contrib/vlc-lib/${ref_lib}
  94. elif test -e ${VLC_BUILD_DIR}/src/.libs/${ref_lib}; then
  95. src_lib=${VLC_BUILD_DIR}/src/.libs/${ref_lib}
  96. fi
  97. install_library ${src_lib} ${target_lib} "library"
  98. ;;
  99. esac
  100. done
  101. # Build the share folder
  102. ##########################
  103. # Build the library folder (Same as VLCKit.framework/lib in Makefile)
  104. echo "Building share folder..."
  105. cp -R ${VLC_BUILD_DIR}/share/luameta ${target_share}
  106. cp -R ${VLC_BUILD_DIR}/share/luaplaylist ${target_share}
  107. fi