summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsbaig1@bloomberg.net <sbaig1@bloomberg.net>2014-09-24 21:53:35 +0000
committersbaig1@bloomberg.net <sbaig1@bloomberg.net>2014-09-24 21:53:35 +0000
commit0f464a10fcfd14e5fca0a8a9c59a53d36327c452 (patch)
treee624992886a88a6ded1a793d04d62ab402067609
parent825a7599122b805333733db2332883516758376c (diff)
downloadgyp-0f464a10fcfd14e5fca0a8a9c59a53d36327c452.tar.gz
ninja win: Add support for 'CallingConvention'
Each calling convention decorates C functions in a different way, so we can use that to test the flag. BUG= R=scottmg@chromium.org Review URL: https://codereview.chromium.org/597993003 git-svn-id: http://gyp.googlecode.com/svn/trunk@1984 78cadc50-ecff-11dd-a971-7dbc132099af
-rw-r--r--pylib/gyp/msvs_emulation.py2
-rw-r--r--test/win/compiler-flags/calling-convention-cdecl.def6
-rw-r--r--test/win/compiler-flags/calling-convention-fastcall.def6
-rw-r--r--test/win/compiler-flags/calling-convention-stdcall.def6
-rw-r--r--test/win/compiler-flags/calling-convention.cc6
-rw-r--r--test/win/compiler-flags/calling-convention.gyp47
-rw-r--r--test/win/gyptest-cl-calling-convention.py22
7 files changed, 95 insertions, 0 deletions
diff --git a/pylib/gyp/msvs_emulation.py b/pylib/gyp/msvs_emulation.py
index 5384df1c..fa97aaf3 100644
--- a/pylib/gyp/msvs_emulation.py
+++ b/pylib/gyp/msvs_emulation.py
@@ -406,6 +406,8 @@ class MsvsSettings(object):
cl('WholeProgramOptimization', map={'true': '/GL'})
cl('WarningLevel', prefix='/W')
cl('WarnAsError', map={'true': '/WX'})
+ cl('CallingConvention',
+ map={'0': 'd', '1': 'r', '2': 'z'}, prefix='/G')
cl('DebugInformationFormat',
map={'1': '7', '3': 'i', '4': 'I'}, prefix='/Z')
cl('RuntimeTypeInfo', map={'true': '/GR', 'false': '/GR-'})
diff --git a/test/win/compiler-flags/calling-convention-cdecl.def b/test/win/compiler-flags/calling-convention-cdecl.def
new file mode 100644
index 00000000..dc1dba05
--- /dev/null
+++ b/test/win/compiler-flags/calling-convention-cdecl.def
@@ -0,0 +1,6 @@
+; 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.
+
+EXPORTS
+ foo
diff --git a/test/win/compiler-flags/calling-convention-fastcall.def b/test/win/compiler-flags/calling-convention-fastcall.def
new file mode 100644
index 00000000..2c61afe2
--- /dev/null
+++ b/test/win/compiler-flags/calling-convention-fastcall.def
@@ -0,0 +1,6 @@
+; 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.
+
+EXPORTS
+ @foo@0
diff --git a/test/win/compiler-flags/calling-convention-stdcall.def b/test/win/compiler-flags/calling-convention-stdcall.def
new file mode 100644
index 00000000..6c7e05e9
--- /dev/null
+++ b/test/win/compiler-flags/calling-convention-stdcall.def
@@ -0,0 +1,6 @@
+; 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.
+
+EXPORTS
+ _foo@0
diff --git a/test/win/compiler-flags/calling-convention.cc b/test/win/compiler-flags/calling-convention.cc
new file mode 100644
index 00000000..0d78a0cc
--- /dev/null
+++ b/test/win/compiler-flags/calling-convention.cc
@@ -0,0 +1,6 @@
+// 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.
+
+extern "C" void foo() {
+}
diff --git a/test/win/compiler-flags/calling-convention.gyp b/test/win/compiler-flags/calling-convention.gyp
new file mode 100644
index 00000000..e2cdd772
--- /dev/null
+++ b/test/win/compiler-flags/calling-convention.gyp
@@ -0,0 +1,47 @@
+# 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_cdecl',
+ 'type': 'loadable_module',
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'CallingConvention': 0,
+ },
+ },
+ 'sources': [
+ 'calling-convention.cc',
+ 'calling-convention-cdecl.def',
+ ],
+ },
+ {
+ 'target_name': 'test_fastcall',
+ 'type': 'loadable_module',
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'CallingConvention': 1,
+ },
+ },
+ 'sources': [
+ 'calling-convention.cc',
+ 'calling-convention-fastcall.def',
+ ],
+ },
+ {
+ 'target_name': 'test_stdcall',
+ 'type': 'loadable_module',
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'CallingConvention': 2,
+ },
+ },
+ 'sources': [
+ 'calling-convention.cc',
+ 'calling-convention-stdcall.def',
+ ],
+ },
+ ]
+}
diff --git a/test/win/gyptest-cl-calling-convention.py b/test/win/gyptest-cl-calling-convention.py
new file mode 100644
index 00000000..b5fdc477
--- /dev/null
+++ b/test/win/gyptest-cl-calling-convention.py
@@ -0,0 +1,22 @@
+#!/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.
+
+"""
+Make sure calling convention setting is extracted properly.
+"""
+
+import TestGyp
+
+import sys
+
+if sys.platform == 'win32':
+ test = TestGyp.TestGyp(formats=['msvs', 'ninja'])
+
+ CHDIR = 'compiler-flags'
+ test.run_gyp('calling-convention.gyp', chdir=CHDIR)
+ test.build('calling-convention.gyp', test.ALL, chdir=CHDIR)
+
+ test.pass_test()