summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/toolsets/gyptest-toolsets.py19
-rw-r--r--test/toolsets/main.cc7
-rw-r--r--test/toolsets/toolsets.cc7
-rw-r--r--test/toolsets/toolsets.gyp34
4 files changed, 67 insertions, 0 deletions
diff --git a/test/toolsets/gyptest-toolsets.py b/test/toolsets/gyptest-toolsets.py
new file mode 100644
index 00000000..4d74a117
--- /dev/null
+++ b/test/toolsets/gyptest-toolsets.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+
+"""
+Verifies that toolsets are correctly applied
+"""
+
+import TestGyp
+
+# Multiple toolsets are currently only supported by the make generator.
+test = TestGyp.TestGyp(formats=['make'])
+
+test.run_gyp('toolsets.gyp')
+
+test.build_all('toolsets.gyp')
+
+test.run_built_executable('host-main', stdout="Host\n")
+test.run_built_executable('target-main', stdout="Target\n")
+
+test.pass_test()
diff --git a/test/toolsets/main.cc b/test/toolsets/main.cc
new file mode 100644
index 00000000..25a53f2d
--- /dev/null
+++ b/test/toolsets/main.cc
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+const char *GetToolset();
+
+int main(int argc, char *argv[]) {
+ printf("%s\n", GetToolset());
+}
diff --git a/test/toolsets/toolsets.cc b/test/toolsets/toolsets.cc
new file mode 100644
index 00000000..0a21e99f
--- /dev/null
+++ b/test/toolsets/toolsets.cc
@@ -0,0 +1,7 @@
+const char *GetToolset() {
+#ifdef TARGET
+ return "Target";
+#else
+ return "Host";
+#endif
+}
diff --git a/test/toolsets/toolsets.gyp b/test/toolsets/toolsets.gyp
new file mode 100644
index 00000000..c709fb10
--- /dev/null
+++ b/test/toolsets/toolsets.gyp
@@ -0,0 +1,34 @@
+{
+ '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'],
+ 'sources': [
+ 'main.cc',
+ ],
+ },
+ {
+ 'target_name': 'target-main',
+ 'type': 'executable',
+ 'dependencies': ['toolsets'],
+ 'sources': [
+ 'main.cc',
+ ],
+ },
+ ],
+}