1*d12e9282SDamjan Jovanovic--- misc/build/gtest-1.7.0/scripts/fuse_gtest_files.py	2020-01-25 02:36:23.509596000 +0200
2*d12e9282SDamjan Jovanovic+++ misc/build/gtest-1.7.0/scripts/fuse_gtest_files.py	2020-01-25 02:50:02.624028000 +0200
3*d12e9282SDamjan Jovanovic@@ -60,7 +60,10 @@
4*d12e9282SDamjan Jovanovic
5*d12e9282SDamjan Jovanovic import os
6*d12e9282SDamjan Jovanovic import re
7*d12e9282SDamjan Jovanovic-import sets
8*d12e9282SDamjan Jovanovic+try:
9*d12e9282SDamjan Jovanovic+    import sets
10*d12e9282SDamjan Jovanovic+except ImportError:
11*d12e9282SDamjan Jovanovic+    pass
12*d12e9282SDamjan Jovanovic import sys
13*d12e9282SDamjan Jovanovic
14*d12e9282SDamjan Jovanovic # We assume that this file is in the scripts/ directory in the Google
15*d12e9282SDamjan Jovanovic@@ -90,8 +93,8 @@
16*d12e9282SDamjan Jovanovic   """
17*d12e9282SDamjan Jovanovic
18*d12e9282SDamjan Jovanovic   if not os.path.isfile(os.path.join(directory, relative_path)):
19*d12e9282SDamjan Jovanovic-    print 'ERROR: Cannot find %s in directory %s.' % (relative_path,
20*d12e9282SDamjan Jovanovic-                                                      directory)
21*d12e9282SDamjan Jovanovic+    print ('ERROR: Cannot find %s in directory %s.' % (relative_path,
22*d12e9282SDamjan Jovanovic+                                                      directory))
23*d12e9282SDamjan Jovanovic     print ('Please either specify a valid project root directory '
24*d12e9282SDamjan Jovanovic            'or omit it on the command line.')
25*d12e9282SDamjan Jovanovic     sys.exit(1)
26*d12e9282SDamjan Jovanovic@@ -123,7 +126,7 @@
27*d12e9282SDamjan Jovanovic            (relative_path, output_dir))
28*d12e9282SDamjan Jovanovic     answer = sys.stdin.readline().strip()
29*d12e9282SDamjan Jovanovic     if answer not in ['y', 'Y']:
30*d12e9282SDamjan Jovanovic-      print 'ABORTED.'
31*d12e9282SDamjan Jovanovic+      print ('ABORTED.')
32*d12e9282SDamjan Jovanovic       sys.exit(1)
33*d12e9282SDamjan Jovanovic
34*d12e9282SDamjan Jovanovic   # Makes sure the directory holding the output file exists; creates
35*d12e9282SDamjan Jovanovic@@ -146,8 +149,11 @@
36*d12e9282SDamjan Jovanovic def FuseGTestH(gtest_root, output_dir):
37*d12e9282SDamjan Jovanovic   """Scans folder gtest_root to generate gtest/gtest.h in output_dir."""
38*d12e9282SDamjan Jovanovic
39*d12e9282SDamjan Jovanovic-  output_file = file(os.path.join(output_dir, GTEST_H_OUTPUT), 'w')
40*d12e9282SDamjan Jovanovic-  processed_files = sets.Set()  # Holds all gtest headers we've processed.
41*d12e9282SDamjan Jovanovic+  output_file = open(os.path.join(output_dir, GTEST_H_OUTPUT), 'w')
42*d12e9282SDamjan Jovanovic+  if sys.version_info[0] > 2:
43*d12e9282SDamjan Jovanovic+      processed_files = set()
44*d12e9282SDamjan Jovanovic+  else:
45*d12e9282SDamjan Jovanovic+      processed_files = sets.Set()  # Holds all gtest headers we've processed.
46*d12e9282SDamjan Jovanovic
47*d12e9282SDamjan Jovanovic   def ProcessFile(gtest_header_path):
48*d12e9282SDamjan Jovanovic     """Processes the given gtest header file."""
49*d12e9282SDamjan Jovanovic@@ -159,7 +165,7 @@
50*d12e9282SDamjan Jovanovic     processed_files.add(gtest_header_path)
51*d12e9282SDamjan Jovanovic
52*d12e9282SDamjan Jovanovic     # Reads each line in the given gtest header.
53*d12e9282SDamjan Jovanovic-    for line in file(os.path.join(gtest_root, gtest_header_path), 'r'):
54*d12e9282SDamjan Jovanovic+    for line in open(os.path.join(gtest_root, gtest_header_path), 'r'):
55*d12e9282SDamjan Jovanovic       m = INCLUDE_GTEST_FILE_REGEX.match(line)
56*d12e9282SDamjan Jovanovic       if m:
57*d12e9282SDamjan Jovanovic         # It's '#include "gtest/..."' - let's process it recursively.
58*d12e9282SDamjan Jovanovic@@ -175,7 +181,10 @@
59*d12e9282SDamjan Jovanovic def FuseGTestAllCcToFile(gtest_root, output_file):
60*d12e9282SDamjan Jovanovic   """Scans folder gtest_root to generate gtest/gtest-all.cc in output_file."""
61*d12e9282SDamjan Jovanovic
62*d12e9282SDamjan Jovanovic-  processed_files = sets.Set()
63*d12e9282SDamjan Jovanovic+  if sys.version_info[0] > 2:
64*d12e9282SDamjan Jovanovic+      processed_files = set()
65*d12e9282SDamjan Jovanovic+  else:
66*d12e9282SDamjan Jovanovic+      processed_files = sets.Set()
67*d12e9282SDamjan Jovanovic
68*d12e9282SDamjan Jovanovic   def ProcessFile(gtest_source_file):
69*d12e9282SDamjan Jovanovic     """Processes the given gtest source file."""
70*d12e9282SDamjan Jovanovic@@ -187,7 +196,7 @@
71*d12e9282SDamjan Jovanovic     processed_files.add(gtest_source_file)
72*d12e9282SDamjan Jovanovic
73*d12e9282SDamjan Jovanovic     # Reads each line in the given gtest source file.
74*d12e9282SDamjan Jovanovic-    for line in file(os.path.join(gtest_root, gtest_source_file), 'r'):
75*d12e9282SDamjan Jovanovic+    for line in open(os.path.join(gtest_root, gtest_source_file), 'r'):
76*d12e9282SDamjan Jovanovic       m = INCLUDE_GTEST_FILE_REGEX.match(line)
77*d12e9282SDamjan Jovanovic       if m:
78*d12e9282SDamjan Jovanovic         if 'include/' + m.group(1) == GTEST_SPI_H_SEED:
79*d12e9282SDamjan Jovanovic@@ -218,7 +227,7 @@
80*d12e9282SDamjan Jovanovic def FuseGTestAllCc(gtest_root, output_dir):
81*d12e9282SDamjan Jovanovic   """Scans folder gtest_root to generate gtest/gtest-all.cc in output_dir."""
82*d12e9282SDamjan Jovanovic
83*d12e9282SDamjan Jovanovic-  output_file = file(os.path.join(output_dir, GTEST_ALL_CC_OUTPUT), 'w')
84*d12e9282SDamjan Jovanovic+  output_file = open(os.path.join(output_dir, GTEST_ALL_CC_OUTPUT), 'w')
85*d12e9282SDamjan Jovanovic   FuseGTestAllCcToFile(gtest_root, output_file)
86*d12e9282SDamjan Jovanovic   output_file.close()
87*d12e9282SDamjan Jovanovic
88*d12e9282SDamjan Jovanovic@@ -242,7 +251,7 @@
89*d12e9282SDamjan Jovanovic     # fuse_gtest_files.py GTEST_ROOT_DIR OUTPUT_DIR
90*d12e9282SDamjan Jovanovic     FuseGTest(sys.argv[1], sys.argv[2])
91*d12e9282SDamjan Jovanovic   else:
92*d12e9282SDamjan Jovanovic-    print __doc__
93*d12e9282SDamjan Jovanovic+    print (__doc__)
94*d12e9282SDamjan Jovanovic     sys.exit(1)
95*d12e9282SDamjan Jovanovic
96*d12e9282SDamjan Jovanovic
97