Pre-Compile.sh 5.4 KB

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