1dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter#!/usr/bin/env python 2dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# 3dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# Copyright 2009, Google Inc. 4dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# All rights reserved. 5dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# 6dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# Redistribution and use in source and binary forms, with or without 7dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# modification, are permitted provided that the following conditions are 8dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# met: 9dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# 10dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# * Redistributions of source code must retain the above copyright 11dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# notice, this list of conditions and the following disclaimer. 12dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# * Redistributions in binary form must reproduce the above 13dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# copyright notice, this list of conditions and the following disclaimer 14dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# in the documentation and/or other materials provided with the 15dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# distribution. 16dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# * Neither the name of Google Inc. nor the names of its 17dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# contributors may be used to endorse or promote products derived from 18dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# this software without specific prior written permission. 19dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# 20dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter 32dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter"""upload_gtest.py v0.1.0 -- uploads a Google Test patch for review. 33dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter 34dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken MixterThis simple wrapper passes all command line flags and 35dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter--cc=googletestframework@googlegroups.com to upload.py. 36dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter 37dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken MixterUSAGE: upload_gtest.py [options for upload.py] 38dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter""" 39dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter 40dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter__author__ = 'wan@google.com (Zhanyong Wan)' 41dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter 42dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixterimport os 43dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixterimport sys 44dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter 45dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken MixterCC_FLAG = '--cc=' 46dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken MixterGTEST_GROUP = 'googletestframework@googlegroups.com' 47dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter 48dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter 49dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixterdef main(): 50dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter # Finds the path to upload.py, assuming it is in the same directory 51dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter # as this file. 52dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter my_dir = os.path.dirname(os.path.abspath(__file__)) 53dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter upload_py_path = os.path.join(my_dir, 'upload.py') 54dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter 55dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter # Adds Google Test discussion group to the cc line if it's not there 56dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter # already. 57dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter upload_py_argv = [upload_py_path] 58dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter found_cc_flag = False 59dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter for arg in sys.argv[1:]: 60dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter if arg.startswith(CC_FLAG): 61dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter found_cc_flag = True 62dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter cc_line = arg[len(CC_FLAG):] 63dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter cc_list = [addr for addr in cc_line.split(',') if addr] 64dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter if GTEST_GROUP not in cc_list: 65dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter cc_list.append(GTEST_GROUP) 66dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter upload_py_argv.append(CC_FLAG + ','.join(cc_list)) 67dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter else: 68dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter upload_py_argv.append(arg) 69dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter 70dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter if not found_cc_flag: 71dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter upload_py_argv.append(CC_FLAG + GTEST_GROUP) 72dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter 73dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter # Invokes upload.py with the modified command line flags. 74dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter os.execv(upload_py_path, upload_py_argv) 75dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter 76dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter 77dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixterif __name__ == '__main__': 78dd1c93d5709e32713961cfd95fe30489a4ad2d26Ken Mixter main() 79