summaryrefslogtreecommitdiffstats
path: root/third_party/python/gyp/test/cflags
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/python/gyp/test/cflags')
-rw-r--r--third_party/python/gyp/test/cflags/cflags.c15
-rw-r--r--third_party/python/gyp/test/cflags/cflags.gyp23
-rwxr-xr-xthird_party/python/gyp/test/cflags/gyptest-cflags.py75
3 files changed, 113 insertions, 0 deletions
diff --git a/third_party/python/gyp/test/cflags/cflags.c b/third_party/python/gyp/test/cflags/cflags.c
new file mode 100644
index 0000000000..0a02ba9074
--- /dev/null
+++ b/third_party/python/gyp/test/cflags/cflags.c
@@ -0,0 +1,15 @@
+/* Copyright (c) 2010 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>
+
+int main(void)
+{
+#ifdef FOO
+ printf("FOO defined\n");
+#else
+ printf("FOO not defined\n");
+#endif
+ return 0;
+}
diff --git a/third_party/python/gyp/test/cflags/cflags.gyp b/third_party/python/gyp/test/cflags/cflags.gyp
new file mode 100644
index 0000000000..2840dc6318
--- /dev/null
+++ b/third_party/python/gyp/test/cflags/cflags.gyp
@@ -0,0 +1,23 @@
+# Copyright (c) 2010 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': 'cflags',
+ 'type': 'executable',
+ 'sources': [
+ 'cflags.c',
+ ],
+ },
+ {
+ 'target_name': 'cflags_host',
+ 'toolsets': ['host'],
+ 'type': 'executable',
+ 'sources': [
+ 'cflags.c',
+ ],
+ },
+ ],
+}
diff --git a/third_party/python/gyp/test/cflags/gyptest-cflags.py b/third_party/python/gyp/test/cflags/gyptest-cflags.py
new file mode 100755
index 0000000000..f4efccba9b
--- /dev/null
+++ b/third_party/python/gyp/test/cflags/gyptest-cflags.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2012 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 the use of the environment during regeneration when the gyp file
+changes, specifically via build of an executable with C preprocessor
+definition specified by CFLAGS.
+
+In this test, gyp and build both run in same local environment.
+"""
+
+import TestGyp
+
+# CPPFLAGS works in ninja but not make; CFLAGS works in both
+FORMATS = ('make', 'ninja')
+
+test = TestGyp.TestGyp(formats=FORMATS)
+
+# First set CFLAGS to blank in case the platform doesn't support unsetenv.
+with TestGyp.LocalEnv({'CFLAGS': '',
+ 'GYP_CROSSCOMPILE': '1'}):
+ test.run_gyp('cflags.gyp')
+ test.build('cflags.gyp')
+
+expect = """FOO not defined\n"""
+test.run_built_executable('cflags', stdout=expect)
+test.run_built_executable('cflags_host', stdout=expect)
+
+test.sleep()
+
+with TestGyp.LocalEnv({'CFLAGS': '-DFOO=1',
+ 'GYP_CROSSCOMPILE': '1'}):
+ test.run_gyp('cflags.gyp')
+ test.build('cflags.gyp')
+
+expect = """FOO defined\n"""
+test.run_built_executable('cflags', stdout=expect)
+
+# Environment variable CFLAGS shouldn't influence the flags for the host.
+expect = """FOO not defined\n"""
+test.run_built_executable('cflags_host', stdout=expect)
+
+test.sleep()
+
+with TestGyp.LocalEnv({'CFLAGS_host': '-DFOO=1',
+ 'GYP_CROSSCOMPILE': '1'}):
+ test.run_gyp('cflags.gyp')
+ test.build('cflags.gyp')
+
+# Environment variable CFLAGS_host should influence the flags for the host.
+expect = """FOO defined\n"""
+test.run_built_executable('cflags_host', stdout=expect)
+
+test.sleep()
+
+with TestGyp.LocalEnv({'CFLAGS': ''}):
+ test.run_gyp('cflags.gyp')
+ test.build('cflags.gyp')
+
+expect = """FOO not defined\n"""
+test.run_built_executable('cflags', stdout=expect)
+
+test.sleep()
+
+with TestGyp.LocalEnv({'CFLAGS': '-DFOO=1'}):
+ test.run_gyp('cflags.gyp')
+ test.build('cflags.gyp')
+
+expect = """FOO defined\n"""
+test.run_built_executable('cflags', stdout=expect)
+
+test.pass_test()