Pre-Compile.sh 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. if [ ${ACTION} = "" ]; then
  2. # Debug --
  3. TARGET_BUILD_DIR="."
  4. FULL_PRODUCT_NAME="VLC.framework"
  5. CONTENTS_FOLDER_PATH="${FULL_PRODUCT_NAME}/Versions/A"
  6. VLC_BUILD_DIR="../../.."
  7. VLC_SRC_DIR="../../.."
  8. # Debug --
  9. fi
  10. if [ ${ACTION} = "build" ]; then
  11. vlc_config="${VLC_SRC_DIR}/vlc-config"
  12. lib="lib"
  13. modules="modules"
  14. target="${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}"
  15. target_lib="${target}/${lib}" # Should we consider using a different well-known folder like shared resources?
  16. target_modules="${target}/${modules}" # Should we consider using a different well-known folder like shared resources?
  17. ##########################
  18. # @function install_library(src_lib, dest_dir)
  19. # @description Installs the specified library into the destination folder, automatically changes the references to dependencies
  20. # @param src_lib source library to copy to the destination directory
  21. # @param dest_dir destination directory where the src_lib should be copied to
  22. install_library() {
  23. if [ ${3} = "library" ]; then
  24. install_name="@loader_path/lib"
  25. else
  26. install_name="@loader_path/modules"
  27. fi
  28. if [ "${4}" != "" ]; then
  29. lib_dest="${2}/${4}"
  30. else
  31. lib_dest="${2}/`basename ${1}`"
  32. fi
  33. if test -e ${1} && ! test -e ${lib_dest}; then
  34. mkdir -p ${2}
  35. # Lets copy the library from the source folder to our new destination folder
  36. cp ${1} ${lib_dest}
  37. # Update the dynamic library so it will know where to look for the other libraries
  38. echo "Installing ${3} `basename ${lib_dest}`"
  39. # Change the reference of libvlc.1 stored in the usr directory to libvlc.dylib in the framework's library directory
  40. install_name_tool -change /usr/local/lib/libvlc.1.dylib @loader_path/../lib/libvlc.dylib ${lib_dest}
  41. install_name_tool -change @executable_path/lib/vlc_libintl.dylib @loader_path/../lib/vlc_libintl.dylib ${lib_dest}
  42. install_name_tool -id "${install_name}/`basename ${lib_dest}`" ${lib_dest}
  43. # Iterate through each installed library and modify the references to other dynamic libraries to match the framework's library directory
  44. for linked_lib in `otool -L "${lib_dest}" | grep @executable_path | sed 's/(\([0-z]*\ *\.*\,*\)*)//g'` ; do
  45. ref_lib=`echo "${linked_lib}" | sed 's:executable_path/:loader_path/../:'`
  46. install_name_tool -change ${linked_lib} ${ref_lib} ${lib_dest}
  47. done
  48. fi
  49. }
  50. # @function install_library
  51. ##########################
  52. ##########################
  53. # Create a symbolic link in the root of the framework
  54. mkdir -p ${target_lib}
  55. mkdir -p ${target_modules}
  56. pushd `pwd` > /dev/null
  57. cd ${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}
  58. ln -sf Versions/Current/${lib} .
  59. ln -sf Versions/Current/${modules} .
  60. popd > /dev/null
  61. # Create a symbolic link in the root of the framework
  62. ##########################
  63. ##########################
  64. # Build the library folder (Same as VLC.framework/lib in Makefile)
  65. echo "Building library folder..."
  66. # Check to see if there are any vlc libraries available
  67. echo "Copying VLC libraries..."
  68. if test -d ${VLC_BUILD_DIR}/extras/contrib/vlc-lib; then
  69. # Iterate through the dyanmic libraries available
  70. for lib_src in ${VLC_BUILD_DIR}/extras/contrib/vlc-lib/*.dylib ; do
  71. install_library ${lib_src} ${target_lib} "library"
  72. done
  73. fi
  74. # Check to see if there are any core libraries available
  75. echo "Copying core libraries..."
  76. # if test -d ${VLC_BUILD_DIR}/src/.libs; then
  77. # # Iterate through all the core libraries
  78. # for lib_src = ${VLC_BUILD_DIR}/src/.libs/*.dylib; do
  79. # # Only install the library if it is not a symbolic link
  80. # if ! test -L ${lib_src}; then
  81. # echo "install_library ${lib_src} ${target_lib} `echo "${lib_src}" | sed 's:(.\d+)+.dylib:.dylib:'`"
  82. # fi
  83. # done
  84. # fi
  85. install_library "${VLC_BUILD_DIR}/src/.libs/libvlc.dylib" ${target_lib} "library"
  86. install_library "${VLC_BUILD_DIR}/src/.libs/libvlc-control.dylib" ${target_lib} "library"
  87. install_library "${VLC_BUILD_DIR}/extras/contrib/vlc-lib/vlc_libintl.dylib" ${target_lib} "library"
  88. # Build the library folder
  89. ##########################
  90. ##########################
  91. # Build the modules folder (Same as VLC.framework/modules in Makefile)
  92. echo "Building modules folder..."
  93. # Figure out what modules are available to install
  94. for module in `top_builddir="${VLC_BUILD_DIR}" ${vlc_config} --target plugin` ; do
  95. # Check to see that the reported module actually exists
  96. if test -n ${module}; then
  97. module_src="`dirname ${module}`/.libs/`basename ${module}`.dylib"
  98. install_library ${module_src} ${target_modules} "module"
  99. fi
  100. done
  101. # Build the modules folder
  102. ##########################
  103. fi
  104. if [ ${ACTION} = "" ]; then
  105. # Debug --
  106. TARGET_BUILD_DIR="."
  107. FULL_PRODUCT_NAME="VLC.framework"
  108. CONTENTS_FOLDER_PATH="${FULL_PRODUCT_NAME}/Versions/A"
  109. VLC_BUILD_DIR="../../.."
  110. VLC_SRC_DIR="../../.."
  111. # Debug --
  112. fi
  113. if [ ${ACTION} = "build" ]; then
  114. vlc_config="${VLC_SRC_DIR}/vlc-config"
  115. lib="lib"
  116. modules="modules"
  117. target="${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}"
  118. target_lib="${target}/${lib}" # Should we consider using a different well-known folder like shared resources?
  119. target_modules="${target}/${modules}" # Should we consider using a different well-known folder like shared resources?
  120. ##########################
  121. # @function install_library(src_lib, dest_dir)
  122. # @description Installs the specified library into the destination folder, automatically changes the references to dependencies
  123. # @param src_lib source library to copy to the destination directory
  124. # @param dest_dir destination directory where the src_lib should be copied to
  125. install_library() {
  126. if [ ${3} = "library" ]; then
  127. install_name="@loader_path/lib"
  128. else
  129. install_name="@loader_path/modules"
  130. fi
  131. if [ "${4}" != "" ]; then
  132. lib_dest="${2}/${4}"
  133. else
  134. lib_dest="${2}/`basename ${1}`"
  135. fi
  136. if test -e ${1} && ! test -e ${lib_dest}; then
  137. mkdir -p ${2}
  138. # Lets copy the library from the source folder to our new destination folder
  139. cp ${1} ${lib_dest}
  140. # Update the dynamic library so it will know where to look for the other libraries
  141. echo "Installing ${3} `basename ${lib_dest}`"
  142. # Change the reference of libvlc.1 stored in the usr directory to libvlc.dylib in the framework's library directory
  143. install_name_tool -change /usr/local/lib/libvlc.1.dylib @loader_path/../lib/libvlc.dylib ${lib_dest}
  144. install_name_tool -change @executable_path/lib/vlc_libintl.dylib @loader_path/../lib/vlc_libintl.dylib ${lib_dest}
  145. install_name_tool -id "${install_name}/`basename ${lib_dest}`" ${lib_dest}
  146. # Iterate through each installed library and modify the references to other dynamic libraries to match the framework's library directory
  147. for linked_lib in `otool -L "${lib_dest}" | grep @executable_path | sed 's/(\([0-z]*\ *\.*\,*\)*)//g'` ; do
  148. ref_lib=`echo "${linked_lib}" | sed 's:executable_path/:loader_path/../:'`
  149. install_name_tool -change ${linked_lib} ${ref_lib} ${lib_dest}
  150. done
  151. fi
  152. }
  153. # @function install_library
  154. ##########################
  155. ##########################
  156. # Create a symbolic link in the root of the framework
  157. mkdir -p ${target_lib}
  158. mkdir -p ${target_modules}
  159. pushd `pwd` > /dev/null
  160. cd ${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}
  161. ln -sf Versions/Current/${lib} .
  162. ln -sf Versions/Current/${modules} .
  163. popd > /dev/null
  164. # Create a symbolic link in the root of the framework
  165. ##########################
  166. ##########################
  167. # Build the library folder (Same as VLC.framework/lib in Makefile)
  168. echo "Building library folder..."
  169. # Check to see if there are any vlc libraries available
  170. echo "Copying VLC libraries..."
  171. if test -d ${VLC_BUILD_DIR}/extras/contrib/vlc-lib; then
  172. # Iterate through the dyanmic libraries available
  173. for lib_src in ${VLC_BUILD_DIR}/extras/contrib/vlc-lib/*.dylib ; do
  174. install_library ${lib_src} ${target_lib} "library"
  175. done
  176. fi
  177. # Check to see if there are any core libraries available
  178. echo "Copying core libraries..."
  179. # if test -d ${VLC_BUILD_DIR}/src/.libs; then
  180. # # Iterate through all the core libraries
  181. # for lib_src = ${VLC_BUILD_DIR}/src/.libs/*.dylib; do
  182. # # Only install the library if it is not a symbolic link
  183. # if ! test -L ${lib_src}; then
  184. # echo "install_library ${lib_src} ${target_lib} `echo "${lib_src}" | sed 's:(.\d+)+.dylib:.dylib:'`"
  185. # fi
  186. # done
  187. # fi
  188. install_library "${VLC_BUILD_DIR}/src/.libs/libvlc.dylib" ${target_lib} "library"
  189. install_library "${VLC_BUILD_DIR}/src/.libs/libvlc-control.dylib" ${target_lib} "library"
  190. install_library "${VLC_BUILD_DIR}/extras/contrib/vlc-lib/vlc_libintl.dylib" ${target_lib} "library"
  191. # Build the library folder
  192. ##########################
  193. ##########################
  194. # Build the modules folder (Same as VLC.framework/modules in Makefile)
  195. echo "Building modules folder..."
  196. # Figure out what modules are available to install
  197. for module in `top_builddir="${VLC_BUILD_DIR}" ${vlc_config} --target plugin` ; do
  198. # Check to see that the reported module actually exists
  199. if test -n ${module}; then
  200. module_src="`dirname ${module}`/.libs/`basename ${module}`.dylib"
  201. install_library ${module_src} ${target_modules} "module"
  202. fi
  203. done
  204. # Build the modules folder
  205. ##########################
  206. fi