1831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.org#!/usr/bin/env python
2831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.org
3831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.org# Copyright (c) 2012 Google Inc. All rights reserved.
4831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.org# Use of this source code is governed by a BSD-style license that can be
5831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.org# found in the LICENSE file.
6831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.org
7831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.org"""
8831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.orgVerifies that when multiple values are supplied for a gyp define, the last one
9831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.orgis used.
10831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.org"""
11831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.org
12831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.orgimport os
13831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.orgimport TestGyp
14831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.org
15831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.orgtest = TestGyp.TestGyp()
16831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.org
17831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.orgos.environ['GYP_DEFINES'] = 'key=value1 key=value2 key=value3'
18831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.orgtest.run_gyp('defines.gyp')
19831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.orgtest.build('defines.gyp')
20831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.orgtest.must_contain('action.txt', 'value3')
21831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.org
22831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.org# The last occurrence of a repeated set should take precedence over other
23831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.org# values.
24831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.orgos.environ['GYP_DEFINES'] = 'key=repeated_value key=value1 key=repeated_value'
25831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.orgtest.run_gyp('defines.gyp')
2621fdfec927e6c146062c13e2eac79ccc655cef47bradnelson@google.comif test.format == 'msvs' and not test.uses_msbuild:
2721fdfec927e6c146062c13e2eac79ccc655cef47bradnelson@google.com  # msvs versions before 2010 don't detect build rule changes not reflected
2821fdfec927e6c146062c13e2eac79ccc655cef47bradnelson@google.com  # in file system timestamps. Rebuild to see differences.
2921fdfec927e6c146062c13e2eac79ccc655cef47bradnelson@google.com  test.build('defines.gyp', rebuild=True)
3049f5a9877ff88aa5e04b305674a0b56eb378f1d6torne@chromium.orgelif test.format == 'android':
3149f5a9877ff88aa5e04b305674a0b56eb378f1d6torne@chromium.org  # The Android build system doesn't currently have a way to get files whose
3249f5a9877ff88aa5e04b305674a0b56eb378f1d6torne@chromium.org  # build rules have changed (but whose timestamps haven't) to be rebuilt.
3349f5a9877ff88aa5e04b305674a0b56eb378f1d6torne@chromium.org  # See bug http://code.google.com/p/gyp/issues/detail?id=308
3449f5a9877ff88aa5e04b305674a0b56eb378f1d6torne@chromium.org  test.unlink('action.txt')
3549f5a9877ff88aa5e04b305674a0b56eb378f1d6torne@chromium.org  test.build('defines.gyp')
3621fdfec927e6c146062c13e2eac79ccc655cef47bradnelson@google.comelse:
3721fdfec927e6c146062c13e2eac79ccc655cef47bradnelson@google.com  test.build('defines.gyp')
38831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.orgtest.must_contain('action.txt', 'repeated_value')
39831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.org
40831ee126ee146d0740953d95e586a45b9bdbe26dsteveblock@chromium.orgtest.pass_test()
41