Enable custom suffixes for Mac bundles.

Patch by Johannes Sartisohn <jsartisohn@google.com>

Review URL: https://codereview.chromium.org/401633002/


git-svn-id: http://gyp.googlecode.com/svn/trunk@1957 78cadc50-ecff-11dd-a971-7dbc132099af
diff --git a/pylib/gyp/xcodeproj_file.py b/pylib/gyp/xcodeproj_file.py
index 2b91f5f..7c7f1fb 100644
--- a/pylib/gyp/xcodeproj_file.py
+++ b/pylib/gyp/xcodeproj_file.py
@@ -2316,11 +2316,11 @@
 
         if force_extension is not None:
           # If it's a wrapper (bundle), set WRAPPER_EXTENSION.
+          # Extension override.
+          suffix = '.' + force_extension
           if filetype.startswith('wrapper.'):
             self.SetBuildSetting('WRAPPER_EXTENSION', force_extension)
           else:
-            # Extension override.
-            suffix = '.' + force_extension
             self.SetBuildSetting('EXECUTABLE_EXTENSION', force_extension)
 
           if filetype.startswith('compiled.mach-o.executable'):
diff --git a/test/mac/gyptest-loadable-module-bundle-product-extension.py b/test/mac/gyptest-loadable-module-bundle-product-extension.py
new file mode 100644
index 0000000..90c2083
--- /dev/null
+++ b/test/mac/gyptest-loadable-module-bundle-product-extension.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2014 Google Inc. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+Tests that loadable_modules don't collide when using the same name with
+different file extensions.
+"""
+
+import TestGyp
+
+import os
+import struct
+import sys
+
+if sys.platform == 'darwin':
+  test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
+
+  CHDIR = 'loadable-module-bundle-product-extension'
+  test.run_gyp('test.gyp', chdir=CHDIR)
+  test.build('test.gyp', test.ALL, chdir=CHDIR)
+
+  test.must_exist(test.built_file_path('Collide.foo', chdir=CHDIR))
+  test.must_exist(test.built_file_path('Collide.bar', chdir=CHDIR))
+
+  test.pass_test()
diff --git a/test/mac/loadable-module-bundle-product-extension/src.cc b/test/mac/loadable-module-bundle-product-extension/src.cc
new file mode 100644
index 0000000..3d878e9
--- /dev/null
+++ b/test/mac/loadable-module-bundle-product-extension/src.cc
@@ -0,0 +1,7 @@
+// Copyright (c) 2014 Google Inc. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+int test() {
+  return 1337;
+}
diff --git a/test/mac/loadable-module-bundle-product-extension/test.gyp b/test/mac/loadable-module-bundle-product-extension/test.gyp
new file mode 100644
index 0000000..684a2c0
--- /dev/null
+++ b/test/mac/loadable-module-bundle-product-extension/test.gyp
@@ -0,0 +1,24 @@
+# Copyright (c) 2014 Google Inc. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+{
+  'targets': [{
+    'target_name': 'test',
+    'type': 'none',
+    'dependencies': ['child_one', 'child_two'],
+  }, {
+    'target_name': 'child_one',
+    'product_name': 'Collide',
+    'product_extension': 'bar',
+    'sources': ['src.cc'],
+    'type': 'loadable_module',
+    'mac_bundle': 1,
+  }, {
+    'target_name': 'child_two',
+    'product_name': 'Collide',
+    'product_extension': 'foo',
+    'sources': ['src.cc'],
+    'type': 'loadable_module',
+    'mac_bundle': 1,
+  }],
+}