Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: site_scons/site_tools/concat_source.py

Issue 9094: Adding in new software construction toolkit version. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « site_scons/site_tools/component_targets_xml.py ('k') | site_scons/site_tools/defer.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python2.4 1 #!/usr/bin/python2.4
2 # Copyright 2008, Google Inc. 2 # Copyright 2008, Google Inc.
3 # All rights reserved. 3 # All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 Returns: 45 Returns:
46 None if successful; 1 if error. 46 None if successful; 1 if error.
47 """ 47 """
48 if len(target) != 1: 48 if len(target) != 1:
49 print 'ERROR: multiple ConcatSource targets when 1 expected' 49 print 'ERROR: multiple ConcatSource targets when 1 expected'
50 return 1 50 return 1
51 51
52 output_lines = [ 52 output_lines = [
53 '// This file is auto-generated by the ConcatSource builder.'] 53 '// This file is auto-generated by the ConcatSource builder.']
54 54
55 for source_file in source: 55 for source_path in map(str, source):
56 # Skip source files which are not CPP files. These will be passed through
57 # to the output list by the pseudo-builder.
58 if source_file.suffix not in env['CONCAT_SOURCE_SUFFIXES']:
59 continue
60
61 source_path = str(source_file)
62
63 if env.get('CC') == 'cl': 56 if env.get('CC') == 'cl':
64 # Add message pragma for nicer progress indication when building with 57 # Add message pragma for nicer progress indication when building with
65 # MSVC. 58 # MSVC.
66 output_lines.append('#pragma message("--%s")' % ( 59 output_lines.append('#pragma message("--%s")' % (
67 source_path.replace("\\", "/"))) 60 source_path.replace("\\", "/")))
68 61
69 output_lines.append('#include "%s"' % source_path) 62 output_lines.append('#include "%s"' % source_path)
70 63
71 output_file = open(str(target[0]), 'w') 64 output_file = open(str(target[0]), 'w')
72 # Need an EOL at the end of the file for more finicky build tools 65 # Need an EOL at the end of the file for more finicky build tools
(...skipping 13 matching lines...) Expand all
86 If self['CONCAT_SOURCE_ENABLE'], calls self.ConcatSource and returns 79 If self['CONCAT_SOURCE_ENABLE'], calls self.ConcatSource and returns
87 the list of target nodes. Otherwise, returns the list of source nodes. 80 the list of target nodes. Otherwise, returns the list of source nodes.
88 Source nodes which are not CPP files are passed through unchanged to the 81 Source nodes which are not CPP files are passed through unchanged to the
89 list of output nodes. 82 list of output nodes.
90 """ 83 """
91 if self.get('CONCAT_SOURCE_ENABLE', True): 84 if self.get('CONCAT_SOURCE_ENABLE', True):
92 # Scan down source list and separate CPP sources (which we concatenate) 85 # Scan down source list and separate CPP sources (which we concatenate)
93 # from other files (which we pass through). 86 # from other files (which we pass through).
94 cppsource = [] 87 cppsource = []
95 outputs = [] 88 outputs = []
96 for source_file in SCons.Script.Flatten(source): 89 suffixes = self.Flatten(self.subst_list('$CONCAT_SOURCE_SUFFIXES'))
97 if self.File(source_file).suffix in self['CONCAT_SOURCE_SUFFIXES']: 90 for source_file in self.arg2nodes(source):
91 if source_file.suffix in suffixes:
98 cppsource.append(source_file) 92 cppsource.append(source_file)
99 else: 93 else:
100 outputs.append(source_file) 94 outputs.append(source_file)
101 95
102 if len(cppsource) > 1: 96 if len(cppsource) > 1:
103 # More than one file, so concatenate them together 97 # More than one file, so concatenate them together
104 outputs += self.ConcatSourceBuilder(target, cppsource) 98 outputs += self.ConcatSourceBuilder(target, cppsource)
105 else: 99 else:
106 # <2 files, so pass them through; no need for a ConcatSource target 100 # <2 files, so pass them through; no need for a ConcatSource target
107 outputs += cppsource 101 outputs += cppsource
(...skipping 16 matching lines...) Expand all
124 # Suffixes of sources we can concatenate. Files not in this list will be 118 # Suffixes of sources we can concatenate. Files not in this list will be
125 # passed through untouched. (Note that on Mac, Objective C/C++ files 119 # passed through untouched. (Note that on Mac, Objective C/C++ files
126 # cannot be concatenated with regular C/C++ files.) 120 # cannot be concatenated with regular C/C++ files.)
127 # TODO(rspangler): Probably shouldn't mix C, C++ either... 121 # TODO(rspangler): Probably shouldn't mix C, C++ either...
128 env['CONCAT_SOURCE_SUFFIXES'] = ['.c', '.C', '.cxx', '.cpp', '.c++', '.cc', 122 env['CONCAT_SOURCE_SUFFIXES'] = ['.c', '.C', '.cxx', '.cpp', '.c++', '.cc',
129 '.h', '.H', '.hxx', '.hpp', '.hh'] 123 '.h', '.H', '.hxx', '.hpp', '.hh']
130 124
131 # Add a psuedo-builder method which can look at the environment to determine 125 # Add a psuedo-builder method which can look at the environment to determine
132 # whether to call the ConcatSource builder or not 126 # whether to call the ConcatSource builder or not
133 env.AddMethod(ConcatSourcePseudoBuilder, 'ConcatSource') 127 env.AddMethod(ConcatSourcePseudoBuilder, 'ConcatSource')
OLDNEW
« no previous file with comments | « site_scons/site_tools/component_targets_xml.py ('k') | site_scons/site_tools/defer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698