vlc | branch: master | Faustino E. Osuna <[email protected]> | Tue Jan 24 
01:31:56 2012 +0100| [3562db63c343c0d2c7c516393d73e303566ae0bb] | committer: 
Jean-Baptiste Kempf

VLCKit: make sure that the right archs exist

When preparing the framework, guarantee that the expected
architectures are present. If they are not present, or if an
unexpected architecture is present, then reconstruct the universal
binary.

Signed-off-by: Jean-Baptiste Kempf <[email protected]>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3562db63c343c0d2c7c516393d73e303566ae0bb
---

 projects/macosx/framework/Pre-Compile.sh |   54 ++++++++++++++++++++---------
 1 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/projects/macosx/framework/Pre-Compile.sh 
b/projects/macosx/framework/Pre-Compile.sh
index 0ac2b28..ef0aea6 100644
--- a/projects/macosx/framework/Pre-Compile.sh
+++ b/projects/macosx/framework/Pre-Compile.sh
@@ -148,34 +148,54 @@ vlc_install() {
             vlc_install_object "$main_build_dir/$src_dir/$src" "$dest_dir" 
"$type" $5
         else
             local fatdest="$dest_dir/$2"
-            local shouldUpdateFat="no"
+            local shouldUpdate="no"
 
-            local objects=""
+            # Determine what architectures are available in the destination 
image
+            local fatdest_archs=""
+            if [ -e ${fatdest} ]; then
+                fatdest_archs=`lipo -info "${fatdest}" 2> /dev/null | sed -E 
-e 's/[[:space:]]+$//' -e 's/.+:[[:space:]]*//' -e 's/[^[:space:]]+/(&)/g'`
 
-            # Create a temporary destination dir to store each ARCH object file
-            local tmp_dest_dir="$VLC_BUILD_DIR/tmp/$type"
-            rm -Rf "${tmp_dest_dir}/*"
-            mkdir -p "$tmp_dest_dir"
+                # Check to see if the destination image needs to be 
reconstructed
+                for arch in $ARCHS; do
+                    # Only install if the new image is newer than the one we 
have installed or the required arch is missing.
+                    if test $shouldUpdate = "no"  && (! [[ "$fatdest_archs" =~ 
\($arch\) ]] || test "$VLC_BUILD_DIR/$arch/$src_dir/$src" -nt "${fatdest}"); 
then
+                        shouldUpdate="yes"
+                    fi
+                    fatdest_archs=${fatdest_archs//\($arch\)/}
+                done
+
+                # Reconstruct the destination image, if the update flag is set 
or if there are more archs in the desintation then we need
+                fatdest_archs=${fatdest_archs// /}
+            else
+                # If the destination image does not exist, then we have to 
reconstruct it
+                shouldUpdate="yes"
+            fi
 
-            for arch in $ARCHS; do
-                local arch_src="$VLC_BUILD_DIR/$arch/$src_dir/$src"
+            # If we should update the destination image or if there were 
unexpected archs in the destination image, then reconstruct it
+            if test "$shouldUpdate" = "yes" || test -n "${fatdest_archs}"; then
+                # If the destination image exists, get rid of it so we can 
copy over the newly constructed image
+                if test -e ${fatdest}; then
+                    rm "$fatdest"
+                fi
 
-                # Only install if the new image is newer than the one we have 
installed.
-                if ( (! test -e ${fatdest}) || test ${arch_src} -nt ${fatdest} 
); then
+                # Create a temporary destination dir to store each ARCH object 
file
+                local tmp_dest_dir="$VLC_BUILD_DIR/tmp/$type"
+                rm -Rf "${tmp_dest_dir}/*"
+                mkdir -p "$tmp_dest_dir"
+
+                # Search for each ARCH object file used to construct a fat 
image
+                local objects=""
+                for arch in $ARCHS; do
+                    local arch_src="$VLC_BUILD_DIR/$arch/$src_dir/$src"
                     vlc_install_object "$arch_src" "$tmp_dest_dir" "$type" 
"$5" "" ".$arch"
                     local dest="$tmp_dest_dir/$src.$arch"
-                    if test -e ${dest}; then
-                        if (! test "$dest_dir/$arch_src" -nt "${dest}"); then
-                            shouldUpdateFat="yes"
-                        fi
+                    if [ -e ${dest} ]; then
                         objects="${dest} $objects"
                     else
                         echo "Warning: building $arch_src without $arch"
                     fi
-                fi
-            done;
+                done;
 
-            if test "$shouldUpdateFat" = "yes"; then
                 echo "Creating fat $type $fatdest"
                 lipo $objects -output "$fatdest" -create
             fi

_______________________________________________
vlc-commits mailing list
[email protected]
http://mailman.videolan.org/listinfo/vlc-commits

Reply via email to