|
14 | 14 | See the License for the specific language governing permissions and
|
15 | 15 | limitations under the License.
|
16 | 16 | """
|
17 |
| -import os |
18 | 17 |
|
| 18 | +from os import walk, sep |
19 | 19 | from os.path import splitext, basename, join, dirname
|
20 | 20 | from random import randint
|
21 | 21 | from tools.utils import mkdir
|
@@ -82,33 +82,30 @@ def __generate_uid(self):
|
82 | 82 | return "%0.9u" % randint(0, 999999999)
|
83 | 83 |
|
84 | 84 | @staticmethod
|
85 |
| - def filter_dot(str): |
| 85 | + def filter_dot(path): |
86 | 86 | """
|
87 | 87 | This function removes ./ from str.
|
88 | 88 | str must be converted with win_to_unix() before using this function.
|
89 | 89 | """
|
90 |
| - if str == None: |
| 90 | + if path is None: |
91 | 91 | return None
|
92 |
| - if str[:2] == './': |
93 |
| - return str[2:] |
94 |
| - return str |
| 92 | + if path[:2] == './': |
| 93 | + return path[2:] |
| 94 | + return path |
95 | 95 |
|
96 | 96 | def build_excludelist(self):
|
97 | 97 | self.source_folders = [self.filter_dot(s) for s in set(dirname(
|
98 | 98 | src) for src in self.resources.c_sources + self.resources.cpp_sources + self.resources.s_sources)]
|
99 | 99 | if '.' in self.source_folders:
|
100 | 100 | self.source_folders.remove('.')
|
101 |
| - #print source_folders |
102 | 101 |
|
103 | 102 | top_folders = [f for f in set(s.split('/')[0] for s in self.source_folders)]
|
104 |
| - #print top_folders |
105 | 103 |
|
106 | 104 | for top_folder in top_folders:
|
107 |
| - # |
108 |
| - for root, dirs, files in os.walk(top_folder, topdown=True): |
| 105 | + for root, dirs, files in walk(top_folder, topdown=True): |
109 | 106 | # Paths returned by os.walk() must be split with os.dep
|
110 | 107 | # to accomodate Windows weirdness.
|
111 |
| - parts = root.split(os.sep) |
| 108 | + parts = root.split(sep) |
112 | 109 | self.remove_unused('/'.join(parts))
|
113 | 110 |
|
114 | 111 | def remove_unused(self, path):
|
@@ -144,26 +141,20 @@ def generate(self):
|
144 | 141 | libraries.append(l[3:])
|
145 | 142 |
|
146 | 143 | self.include_path = [self.filter_dot(s) for s in self.resources.inc_dirs]
|
147 |
| - print 'Include folders: {0}'.format(len(self.include_path)) |
148 |
| - #for dir in self.include_path: |
149 |
| - # print "%s" % dir |
| 144 | + print 'Include folders: %d' % len(self.include_path) |
150 | 145 |
|
151 | 146 | self.exclude_dirs = []
|
152 | 147 | self.build_excludelist()
|
153 | 148 |
|
154 |
| - print 'Exclude folders: {0}'.format(len(self.exclude_dirs)) |
155 |
| - #for dir in self.exclude_dirs: |
156 |
| - # print "%s" % dir |
| 149 | + print 'Exclude folders: %d' % len(self.exclude_dirs) |
157 | 150 |
|
158 | 151 | self.exclude_dirs = '|'.join(self.exclude_dirs)
|
159 | 152 |
|
160 | 153 | self.ld_script = self.filter_dot(self.resources.linker_script)
|
161 |
| - #print 'Linker script: {0}'.format(self.ld_script) |
162 | 154 |
|
163 | 155 | self.lib_dirs = [self.filter_dot(s) for s in self.resources.lib_dirs]
|
164 | 156 |
|
165 | 157 | self.symbols = [s.replace('"', '"') for s in self.toolchain.get_symbols()]
|
166 |
| - #print "%s" % self.symbols |
167 | 158 |
|
168 | 159 | ctx = {
|
169 | 160 | 'name': self.project_name,
|
|
0 commit comments