gyptest-define-override.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env python
  2. # Copyright (c) 2009 Google Inc. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. """
  6. Verifies that a default gyp define can be overridden.
  7. """
  8. import os
  9. import TestGyp
  10. test = TestGyp.TestGyp()
  11. # CMake loudly warns about passing '#' to the compiler and drops the define.
  12. expect_stderr = ''
  13. if test.format == 'cmake':
  14. expect_stderr = (
  15. """WARNING: Preprocessor definitions containing '#' may not be passed on the"""
  16. """ compiler command line because many compilers do not support it.\n"""
  17. """CMake is dropping a preprocessor definition: HASH_VALUE="a#1"\n"""
  18. """Consider defining the macro in a (configured) header file.\n\n""")
  19. # Command-line define
  20. test.run_gyp('defines.gyp', '-D', 'OS=fakeos')
  21. test.build('defines.gyp', stderr=expect_stderr)
  22. test.built_file_must_exist('fakeosprogram', type=test.EXECUTABLE)
  23. # Clean up the exe so subsequent tests don't find an old exe.
  24. os.remove(test.built_file_path('fakeosprogram', type=test.EXECUTABLE))
  25. # Without "OS" override, fokeosprogram shouldn't be built.
  26. test.run_gyp('defines.gyp')
  27. test.build('defines.gyp', stderr=expect_stderr)
  28. test.built_file_must_not_exist('fakeosprogram', type=test.EXECUTABLE)
  29. # Environment define
  30. os.environ['GYP_DEFINES'] = 'OS=fakeos'
  31. test.run_gyp('defines.gyp')
  32. test.build('defines.gyp', stderr=expect_stderr)
  33. test.built_file_must_exist('fakeosprogram', type=test.EXECUTABLE)
  34. test.pass_test()