Enable ObjC build by default and reenable 64-bit mac libjingle build

BUG=2124
TESTED=trybots & building for mac, mac64, ios-sim, and ios-device on my MBP all build everything in out/Debug.
R=niklas.enbom@webrtc.org, wu@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2080004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4620 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/all.gyp b/all.gyp
index e67ee61..99ca3ab 100644
--- a/all.gyp
+++ b/all.gyp
@@ -14,17 +14,9 @@
       'type': 'none',
       'dependencies': [
         'webrtc/webrtc.gyp:*',
-      ],
-      # TODO(henrike): fix build errors on 64 bit Mac for libjingle. See issue
-      # 2124.  Once done the entire conditional below can be removed.
-      'conditions': [
-        ['OS!="mac" or target_arch!="x64" or libjingle_objc==1', {
-          'dependencies': [
-            'talk/libjingle.gyp:*',
-            'talk/libjingle_examples.gyp:*',
-            'talk/libjingle_tests.gyp:*',
-          ],
-        }],
+        'talk/libjingle.gyp:*',
+        'talk/libjingle_examples.gyp:*',
+        'talk/libjingle_tests.gyp:*',
       ],
     },
   ],
diff --git a/talk/build/common.gypi b/talk/build/common.gypi
index a8fcd57..50acb39 100644
--- a/talk/build/common.gypi
+++ b/talk/build/common.gypi
@@ -2,26 +2,26 @@
 # libjingle
 # Copyright 2012, Google Inc.
 #
-# Redistribution and use in source and binary forms, with or without 
+# Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are met:
 #
-#  1. Redistributions of source code must retain the above copyright notice, 
+#  1. Redistributions of source code must retain the above copyright notice,
 #     this list of conditions and the following disclaimer.
 #  2. Redistributions in binary form must reproduce the above copyright notice,
 #     this list of conditions and the following disclaimer in the documentation
 #     and/or other materials provided with the distribution.
-#  3. The name of the author may not be used to endorse or promote products 
+#  3. The name of the author may not be used to endorse or promote products
 #     derived from this software without specific prior written permission.
 #
 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
-# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 
@@ -36,8 +36,6 @@
     # flood of chromium-style warnings.
     'clang_use_chrome_plugins%': 0,
     'libpeer_target_type%': 'static_library',
-    # Whether or not to build the ObjectiveC PeerConnection API & tests.
-    'libjingle_objc%': 0,
     'conditions': [
       ['OS=="android" or OS=="linux"', {
         # TODO(henrike): make sure waterfall bots have $JAVA_HOME configured
@@ -110,7 +108,7 @@
           'HAVE_OPENSSL_SSL_H=1',
         ],
       }],
-      ['libjingle_objc==1', {
+      ['OS=="ios" or (OS=="mac" and target_arch!="ia32")', {
         'defines': [
           'CARBON_DEPRECATED=YES',
         ],
diff --git a/talk/libjingle.gyp b/talk/libjingle.gyp
index aa61360..db19a98 100755
--- a/talk/libjingle.gyp
+++ b/talk/libjingle.gyp
@@ -42,7 +42,6 @@
        }],
      ],
     }],
-
     ['OS=="linux" or OS=="android"', {
       'targets': [
         {
@@ -150,7 +149,7 @@
         },
       ],
     }],
-    ['libjingle_objc == 1', {
+    ['OS=="ios" or (OS=="mac" and target_arch!="ia32")', {
       'targets': [
         {
           'target_name': 'libjingle_peerconnection_objc',
@@ -234,8 +233,8 @@
           'xcode_settings': {
             'CLANG_ENABLE_OBJC_ARC': 'YES',
           },
-        }
-      ]
+        },  # target libjingle_peerconnection_objc
+      ],
     }],
   ],
 
@@ -591,17 +590,6 @@
           ],
         }],
         ['OS=="mac"', {
-          'conditions': [
-            ['libjingle_objc != 1', {
-              'link_settings' :{
-                'xcode_settings': {
-                  'OTHER_LDFLAGS': [
-                    '-framework Carbon',
-                  ],
-                },
-              },
-            }],
-          ],
           'sources': [
             'base/macasyncsocket.cc',
             'base/macasyncsocket.h',
@@ -619,18 +607,36 @@
           ],
           'link_settings': {
             'libraries': [
-             '$(SDKROOT)/usr/lib/libcrypto.dylib',
-             '$(SDKROOT)/usr/lib/libssl.dylib',
+              '$(SDKROOT)/usr/lib/libcrypto.dylib',
+              '$(SDKROOT)/usr/lib/libssl.dylib',
             ],
-            'xcode_settings': {
-              'OTHER_LDFLAGS': [
-                '-framework Cocoa',
-                '-framework IOKit',
-                '-framework Security',
-                '-framework SystemConfiguration',
-              ],
+          },
+          'all_dependent_settings': {
+            'link_settings': {
+              'xcode_settings': {
+                'OTHER_LDFLAGS': [
+                  '-framework Cocoa',
+                  '-framework Foundation',
+                  '-framework IOKit',
+                  '-framework Security',
+                  '-framework SystemConfiguration',
+                ],
+              },
             },
           },
+          'conditions': [
+            ['target_arch=="ia32"', {
+              'all_dependent_settings': {
+                'link_settings': {
+                  'xcode_settings': {
+                    'OTHER_LDFLAGS': [
+                      '-framework Carbon',
+                    ],
+                  },
+                },
+              },
+            }],
+          ],
         }],
         ['OS=="ios"', {
           'sources': [
@@ -639,13 +645,16 @@
           'dependencies': [
             '../net/third_party/nss/ssl.gyp:libssl',
           ],
-          'xcode_settings': {
-            'OTHER_LDFLAGS': [
-              '-framework IOKit',
-              '-framework Security',
-              '-framework SystemConfiguration',
-              '-framework UIKit',
-            ],
+          'all_dependent_settings': {
+            'xcode_settings': {
+              'OTHER_LDFLAGS': [
+                '-framework Foundation',
+                '-framework IOKit',
+                '-framework Security',
+                '-framework SystemConfiguration',
+                '-framework UIKit',
+              ],
+            },
           },
         }],
         ['OS=="win"', {
@@ -903,12 +912,18 @@
             'media/devices/macdevicemanagermm.mm',
           ],
           'conditions': [
-            # TODO(hughv):  Investigate if this is needed.
-            [ 'libjingle_objc != 1', {
+            ['target_arch=="ia32"', {
               'sources': [
                 'media/devices/carbonvideorenderer.cc',
                 'media/devices/carbonvideorenderer.h',
               ],
+              'link_settings': {
+                'xcode_settings': {
+                  'OTHER_LDFLAGS': [
+                    '-framework Carbon',
+                  ],
+                },
+              },
             }],
           ],
           'xcode_settings': {
diff --git a/talk/libjingle_examples.gyp b/talk/libjingle_examples.gyp
index 78bfe65..d4aa4a4 100755
--- a/talk/libjingle_examples.gyp
+++ b/talk/libjingle_examples.gyp
@@ -218,7 +218,7 @@
       ], # targets
     }],  # OS=="linux" or OS=="win"
 
-    ['libjingle_objc==1 and OS=="ios"', {
+    ['OS=="ios"', {
       'targets': [
         {
           'target_name': 'AppRTCDemo',
@@ -276,17 +276,23 @@
                 # we could pick more intelligently among the keys, but as a
                 # first cut just tell the developer to specify a key identity
                 # explicitly.
-                'ensure_single_key': '<!(python -c "assert len(\'\'\'<(key_id)\'\'\') > 0 and \'\\n\' not in \'\'\'<(key_id)\'\'\', \'key_id gyp variable needs to be set explicitly because there are multiple codesigning keys, or none!\'")',
+                'ensure_single_key': '<!(python -c "assert \'\\n\' not in \'\'\'<(key_id)\'\'\', \'key_id gyp variable needs to be set explicitly because there are multiple codesigning keys!\'")',
               },
-              'action': [
-                '/usr/bin/codesign', '-v', '--force', '--sign', '<(key_id)',
-                '${BUILT_PRODUCTS_DIR}/AppRTCDemo.app',
+              'conditions': [
+                ['key_id==""', {
+                  'action': [ 'echo', 'Skipping signing' ],
+                }, {
+                  'action': [
+                    '/usr/bin/codesign', '-v', '--force', '--sign', '<(key_id)',
+                    '${BUILT_PRODUCTS_DIR}/AppRTCDemo.app',
+                  ],
+                }],
               ],
             },
           ],
         },  # target AppRTCDemo
       ],  # targets
-    }],  # libjingle_objc==1
+    }],  # OS=="ios"
 
     ['OS=="android"', {
       'targets': [
diff --git a/talk/libjingle_tests.gyp b/talk/libjingle_tests.gyp
index 9ea81af..e0cc239 100755
--- a/talk/libjingle_tests.gyp
+++ b/talk/libjingle_tests.gyp
@@ -464,13 +464,16 @@
         },
       ],
     }],
-    ['libjingle_objc == 1', {
+    ['OS=="ios" or (OS=="mac" and target_arch!="ia32" and mac_sdk>="10.7")', {
+      # The >=10.7 above is required to make ARC link cleanly (e.g. as
+      # opposed to _compile_ cleanly, which the library under test
+      # does just fine on 10.6 too).
       'targets': [
         {
+        'target_name': 'libjingle_peerconnection_objc_test',
           'variables': {
             'infoplist_file': './app/webrtc/objctests/Info.plist',
           },
-          'target_name': 'libjingle_peerconnection_objc_test',
           'type': 'executable',
           'mac_bundle': 1,
           'mac_bundle_resources': [
@@ -510,7 +513,7 @@
               ],
             }],
           ],
-        },
+        },  # target libjingle_peerconnection_objc_test
       ],
     }],
   ],
diff --git a/webrtc/build/ios-webrtc.sh b/webrtc/build/ios-webrtc.sh
index 7cb6ac9..e2fe8a2 100755
--- a/webrtc/build/ios-webrtc.sh
+++ b/webrtc/build/ios-webrtc.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/bash -e
 
 # Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
 #
@@ -8,66 +8,18 @@
 # in the file PATENTS.  All contributing project authors may
 # be found in the AUTHORS file in the root of the source tree.
 
-function build_project() {
-  # make the target string
-  if [[ -z "$2" ]]; then
-    target_string=""
-  else
-    declare -a arg_target=("${!2}")
+# Work in trunk/.
+cd "$(dirname $0)/../.."
 
-  for item in ${arg_target[*]}
-    do
-      temp_string="-target $item "
-      target_string=$target_string$temp_string
-    done
-  fi
+export GYP_DEFINES="build_with_libjingle=1 build_with_chromium=0"
+GYP_DEFINES="$GYP_DEFINES OS=ios target_arch=armv7 key_id=\"\""
+export GYP_GENERATORS="ninja"
+export GYP_CROSSCOMPILE=1
 
-  # xcodebuild
-  xcodebuild -project "$1" -sdk iphoneos \
-  -configuration ${CONFIGURATION} \
-  -CONFIGURATION_BUILD_DIR=${CONFIGURATION_BUILD_DIR} $target_string
-
-  if [ "$?" != "0" ]; then
-    echo "[Error] build $1 failed!" 1>&2
-    echo "@@@STEP_FAILURE@@@"
-    exit 1
-  fi
-}
-
-# change the working directory to trunk
-cd "$( dirname "${BASH_SOURCE[0]}" )/../.."
-
-# build setting
-CONFIGURATION_BUILD_DIR=./xcodebuild
-CONFIGURATION=Debug
-GYPDEF="OS=ios target_arch=arm armv7=1 arm_neon=1 enable_video=0 include_opus=1"
-
-export GYP_DEFINES=$GYPDEF
-echo "[Running gclient runhooks...]"
 echo "@@@BUILD_STEP runhooks@@@"
-gclient runhooks
-if [ "$?" != "0" ]; then
-  echo "[Error] gclient runhooks failed!" 1>&2
-  echo "@@@STEP_FAILURE@@@"
-  exit 2
-fi
-echo "[Projects updated]\n"
+gclient runhooks || { echo "@@@STEP_FAILURE@@@"; exit 2; }
 
 echo "@@@BUILD_STEP compile@@@"
-echo "[Building XCode projects...]"
-array_target_module=(
-  "bitrate_controller" "media_file" "paced_sender" "remote_bitrate_estimator"
-  "webrtc_utility" "rtp_rtcp" "CNG" "G711" "G722" "iLBC" "iSACFix" "PCM16B"
-  "audio_coding_module" "NetEq" "audio_conference_mixer" "audio_device"
-  "audio_processing" "iSAC" "isac_neon" "audio_processing_neon" "webrtc_opus"
-)
-array_target_opus=("opus")
-
-build_project "webrtc/common_audio/common_audio.xcodeproj"
-build_project "webrtc/modules/modules.xcodeproj" array_target_module[@]
-build_project "webrtc/system_wrappers/source/system_wrappers.xcodeproj"
-build_project "webrtc/voice_engine/voice_engine.xcodeproj"
-build_project "third_party/opus/opus.xcodeproj" array_target_opus[@]
-echo "[Building XCode projects is successful]\n"
+ninja -C out/Debug || { echo "@@@STEP_FAILURE@@@"; exit 2; }
 
 exit 0
diff --git a/webrtc/modules/video_capture/video_capture.gypi b/webrtc/modules/video_capture/video_capture.gypi
index bbba9bf..f2cecd1 100644
--- a/webrtc/modules/video_capture/video_capture.gypi
+++ b/webrtc/modules/video_capture/video_capture.gypi
@@ -132,6 +132,7 @@
                     '-framework AVFoundation',
                     '-framework CoreMedia',
                     '-framework CoreVideo',
+                    '-framework UIKit',
                   ],
                 },
               },