installPluginsVLCKit.sh 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. #!/bin/sh
  2. #
  3. # Pre-Compile.sh
  4. #
  5. # Script that installs libvlc plugins inside VLCKit.
  6. spushd()
  7. {
  8. pushd "$1" 2>&1> /dev/null
  9. }
  10. spopd()
  11. {
  12. popd 2>&1> /dev/null
  13. }
  14. info()
  15. {
  16. local green="\033[1;32m"
  17. local normal="\033[0m"
  18. echo "[${green}info${normal}] $1"
  19. }
  20. echo "running installPluginsVLCKit.sh"
  21. TARGET_BUILD_DIR="${CONFIGURATION_BUILD_DIR}"
  22. CONTENTS_FOLDER_PATH="VLCKit.framework/Versions/A"
  23. if test "${ACTION}" != "build"; then
  24. if test "${ACTION}" != "install"; then
  25. echo "This script is supposed to run from xcodebuild or Xcode"
  26. exit 1
  27. fi
  28. fi
  29. lib="lib"
  30. plugins="plugins"
  31. share="share"
  32. include="include"
  33. target="${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}"
  34. target_lib="${target}/${lib}" # Should we consider using a different well-known folder like shared resources?
  35. target_plugins="${target}/${plugins}" # Should we consider using a different well-known folder like shared resources?
  36. target_share="${target}/${share}" # Should we consider using a different well-known folder like shared resources?
  37. linked_libs=""
  38. prefix=".libs"
  39. suffix="dylib"
  40. num_archs=$(echo `echo $ARCHS | wc -w`)
  41. ##########################
  42. # @function vlc_install_object(src_lib, dest_dir, type, lib_install_prefix, destination_name, suffix)
  43. # @description Installs the specified library into the destination folder, automatically changes the references to dependencies
  44. # @param src_lib source library to copy to the destination directory
  45. # @param dest_dir destination directory where the src_lib should be copied to
  46. vlc_install_object() {
  47. local src_lib=${1}
  48. local dest_dir=${2}
  49. local type=${3}
  50. local lib_install_prefix=${4}
  51. local destination_name=${5}
  52. local suffix=${6}
  53. if [ $type = "library" ]; then
  54. local install_name="@loader_path/lib"
  55. elif [ $type = "module" ]; then
  56. local install_name="@loader_path/plugins"
  57. fi
  58. if [ "$destination_name" != "" ]; then
  59. local lib_dest="$dest_dir/$destination_name$suffix"
  60. local lib_name=`basename $destination_name`
  61. else
  62. local lib_dest="$dest_dir/`basename $src_lib`$suffix"
  63. local lib_name=`basename $src_lib`
  64. fi
  65. if [ "x$lib_install_prefix" != "x" ]; then
  66. local lib_install_prefix="$lib_install_prefix"
  67. else
  68. local lib_install_prefix="@loader_path/../lib"
  69. fi
  70. if test ! -e ${src_lib}; then
  71. return
  72. fi
  73. if ( (test ! -e ${lib_dest}) || test ${src_lib} -nt ${lib_dest} ); then
  74. mkdir -p ${dest_dir}
  75. # Lets copy the library from the source folder to our new destination folder
  76. if [ "${type}" = "bin" ]; then
  77. install -m 755 ${src_lib} ${lib_dest}
  78. else
  79. install -m 644 ${src_lib} ${lib_dest}
  80. fi
  81. # Update the dynamic library so it will know where to look for the other libraries
  82. echo "Installing ${type} `basename ${lib_dest}`"
  83. if [ "${type}" = "library" ]; then
  84. # Change the reference of libvlc.1 stored in the usr directory to libvlc.dylib in the framework's library directory
  85. install_name_tool -id "${install_name}/${lib_name}" ${lib_dest} > /dev/null
  86. fi
  87. if [ "${type}" != "data" ]; then
  88. # Iterate through each installed library and modify the references to other dynamic libraries to match the framework's library directory
  89. for linked_lib in `otool -L ${lib_dest} | grep '(' | sed 's/\((.*)\)//'`; do
  90. local name=`basename ${linked_lib}`
  91. case "${linked_lib}" in
  92. */vlc_build_dir/* | */vlc_install_dir/* | *vlc* | */extras/contrib/*)
  93. if test -e ${linked_lib}; then
  94. install_name_tool -change "$linked_lib" "${lib_install_prefix}/${name}" "${lib_dest}"
  95. linked_libs="${linked_libs} ${ref_lib}"
  96. vlc_install_object ${linked_lib} ${target_lib} "library"
  97. fi
  98. ;;
  99. esac
  100. done
  101. fi
  102. fi
  103. }
  104. # @function vlc_install_object
  105. ##########################
  106. ##########################
  107. # Create a symbolic link in the root of the framework
  108. mkdir -p ${target_lib}
  109. mkdir -p ${target_plugins}
  110. if [ "$RELEASE_MAKEFILE" != "yes" ] ; then
  111. pushd `pwd` > /dev/null
  112. cd ${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}
  113. ln -sf Versions/Current/${lib} .
  114. ln -sf Versions/Current/${plugins} .
  115. ln -sf Versions/Current/${include} .
  116. ln -sf Versions/Current/${share} .
  117. popd > /dev/null
  118. fi
  119. ##########################
  120. # Build the plugins folder (Same as VLCKit.framework/plugins in Makefile)
  121. echo "Building plugins folder..."
  122. # Figure out what plugins are available to install
  123. spushd ${VLC_SRC_DIR}/install-macos/lib/vlc/plugins
  124. for folder in `ls -d */`
  125. do
  126. cd ${folder}
  127. ITERDIR=`pwd`
  128. for i in `ls *.dylib`
  129. do
  130. vlc_install_object ${ITERDIR}/$i ${target_plugins} "module"
  131. done
  132. cd ..
  133. done
  134. spopd # install-macos/lib/vlc/plugins
  135. exit 0
  136. ##########################
  137. # Build the share folder
  138. echo "Building share folder..."
  139. echo ${VLC_BUILD_DIR}
  140. pbxcp="cp -R -L"
  141. mkdir -p ${target_share}
  142. if test -d ${VLC_BUILD_DIR}/share/lua; then
  143. $pbxcp ${VLC_BUILD_DIR}/share/lua ${target_share}
  144. fi
  145. if test -d ${main_build_dir}/share/lua; then
  146. $pbxcp ${main_build_dir}/share/lua ${target_share}
  147. fi