libjingle gyp: signal errors during gyp time to avoid cryptic failures during build time.

- $JAVA_HOME / java_home missing or not pointing to a JDK
- Multiple or zero mac codesigning identities

BUG=2206
R=henrike@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4527 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/libjingle_examples.gyp b/talk/libjingle_examples.gyp
index cc252b2..78bfe65 100755
--- a/talk/libjingle_examples.gyp
+++ b/talk/libjingle_examples.gyp
@@ -266,9 +266,20 @@
               # Ideally app signing would be a part of gyp.
               # Delete if/when that comes to pass.
               'postbuild_name': 'Sign AppRTCDemo',
+              'variables': {
+                'variables': {
+                  'key_id%': '<!(security find-identity -p codesigning -v | grep "iPhone Developer" | awk \'{print $2}\')',
+                },
+                'key_id%': '<(key_id)',
+                # Total HACK to give a more informative message when multiple
+                # codesigning keys are present in the default keychain.  Ideally
+                # 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!\'")',
+              },
               'action': [
-                '/usr/bin/codesign', '-v', '--force', '--sign',
-                '<!(security find-identity -p codesigning -v | grep "iPhone Developer" | awk \'{print $2}\')',
+                '/usr/bin/codesign', '-v', '--force', '--sign', '<(key_id)',
                 '${BUILT_PRODUCTS_DIR}/AppRTCDemo.app',
               ],
             },