summaryrefslogtreecommitdiffstats
path: root/third_party/python/gyp/test/toolsets
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/python/gyp/test/toolsets')
-rwxr-xr-xthird_party/python/gyp/test/toolsets/gyptest-toolsets.py31
-rw-r--r--third_party/python/gyp/test/toolsets/main.cc13
-rw-r--r--third_party/python/gyp/test/toolsets/toolsets.cc11
-rw-r--r--third_party/python/gyp/test/toolsets/toolsets.gyp62
-rw-r--r--third_party/python/gyp/test/toolsets/toolsets_shared.cc11
5 files changed, 128 insertions, 0 deletions
diff --git a/third_party/python/gyp/test/toolsets/gyptest-toolsets.py b/third_party/python/gyp/test/toolsets/gyptest-toolsets.py
new file mode 100755
index 0000000000..f80fce70a2
--- /dev/null
+++ b/third_party/python/gyp/test/toolsets/gyptest-toolsets.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2009 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.
+
+"""
+Verifies that toolsets are correctly applied
+"""
+import os
+import sys
+import TestGyp
+
+if sys.platform.startswith('linux'):
+
+ test = TestGyp.TestGyp(formats=['make', 'ninja'])
+
+ oldenv = os.environ.copy()
+ try:
+ os.environ['GYP_CROSSCOMPILE'] = '1'
+ test.run_gyp('toolsets.gyp')
+ finally:
+ os.environ.clear()
+ os.environ.update(oldenv)
+
+ test.build('toolsets.gyp', test.ALL)
+
+ test.run_built_executable('host-main', stdout="Host\nShared: Host\n")
+ test.run_built_executable('target-main', stdout="Target\nShared: Target\n")
+
+ test.pass_test()
diff --git a/third_party/python/gyp/test/toolsets/main.cc b/third_party/python/gyp/test/toolsets/main.cc
new file mode 100644
index 0000000000..bc47da9978
--- /dev/null
+++ b/third_party/python/gyp/test/toolsets/main.cc
@@ -0,0 +1,13 @@
+/* Copyright (c) 2009 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. */
+
+#include <stdio.h>
+
+const char *GetToolset();
+const char *GetToolsetShared();
+
+int main(void) {
+ printf("%s\n", GetToolset());
+ printf("Shared: %s\n", GetToolsetShared());
+}
diff --git a/third_party/python/gyp/test/toolsets/toolsets.cc b/third_party/python/gyp/test/toolsets/toolsets.cc
new file mode 100644
index 0000000000..a45fa029cb
--- /dev/null
+++ b/third_party/python/gyp/test/toolsets/toolsets.cc
@@ -0,0 +1,11 @@
+/* Copyright (c) 2009 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. */
+
+const char *GetToolset() {
+#ifdef TARGET
+ return "Target";
+#else
+ return "Host";
+#endif
+}
diff --git a/third_party/python/gyp/test/toolsets/toolsets.gyp b/third_party/python/gyp/test/toolsets/toolsets.gyp
new file mode 100644
index 0000000000..3bc3a784ea
--- /dev/null
+++ b/third_party/python/gyp/test/toolsets/toolsets.gyp
@@ -0,0 +1,62 @@
+# Copyright (c) 2009 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.
+
+{
+ 'target_defaults': {
+ 'target_conditions': [
+ ['_toolset=="target"', {'defines': ['TARGET']}]
+ ]
+ },
+ 'targets': [
+ {
+ 'target_name': 'toolsets',
+ 'type': 'static_library',
+ 'toolsets': ['target', 'host'],
+ 'sources': [
+ 'toolsets.cc',
+ ],
+ },
+ {
+ 'target_name': 'host-main',
+ 'type': 'executable',
+ 'toolsets': ['host'],
+ 'dependencies': ['toolsets', 'toolsets_shared'],
+ 'sources': [
+ 'main.cc',
+ ],
+ },
+ {
+ 'target_name': 'target-main',
+ 'type': 'executable',
+ 'dependencies': ['toolsets', 'toolsets_shared'],
+ 'sources': [
+ 'main.cc',
+ ],
+ },
+ # This tests that build systems can handle a shared library being build for
+ # both host and target.
+ {
+ 'target_name': 'janus',
+ 'type': 'shared_library',
+ 'toolsets': ['target', 'host'],
+ 'sources': [
+ 'toolsets.cc',
+ ],
+ 'cflags': [ '-fPIC' ],
+ },
+ {
+ 'target_name': 'toolsets_shared',
+ 'type': 'shared_library',
+ 'toolsets': ['target', 'host'],
+ 'target_conditions': [
+ # Ensure target and host have different shared_library names
+ ['_toolset=="host"', {'product_extension': 'host'}],
+ ],
+ 'sources': [
+ 'toolsets_shared.cc',
+ ],
+ 'cflags': [ '-fPIC' ],
+ },
+ ],
+}
diff --git a/third_party/python/gyp/test/toolsets/toolsets_shared.cc b/third_party/python/gyp/test/toolsets/toolsets_shared.cc
new file mode 100644
index 0000000000..794af2c0bd
--- /dev/null
+++ b/third_party/python/gyp/test/toolsets/toolsets_shared.cc
@@ -0,0 +1,11 @@
+/* Copyright (c) 2013 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. */
+
+const char *GetToolsetShared() {
+#ifdef TARGET
+ return "Target";
+#else
+ return "Host";
+#endif
+}