OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/gn/filesystem_utils.h" | 5 #include "tools/gn/filesystem_utils.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 return ::CompareString(LOCALE_USER_DEFAULT, LINGUISTIC_IGNORECASE, | 158 return ::CompareString(LOCALE_USER_DEFAULT, LINGUISTIC_IGNORECASE, |
159 a.c_str(), -1, b.c_str(), -1) == CSTR_EQUAL; | 159 a.c_str(), -1, b.c_str(), -1) == CSTR_EQUAL; |
160 #else | 160 #else |
161 // Assume case-sensitive filesystems on non-Windows. | 161 // Assume case-sensitive filesystems on non-Windows. |
162 return a == b; | 162 return a == b; |
163 #endif | 163 #endif |
164 } | 164 } |
165 | 165 |
166 } // namespace | 166 } // namespace |
167 | 167 |
168 SourceFileType GetSourceFileType(const SourceFile& file, | 168 SourceFileType GetSourceFileType(const SourceFile& file) { |
169 Settings::TargetOS os) { | |
170 base::StringPiece extension = FindExtension(&file.value()); | 169 base::StringPiece extension = FindExtension(&file.value()); |
171 if (extension == "cc" || extension == "cpp" || extension == "cxx") | 170 if (extension == "cc" || extension == "cpp" || extension == "cxx") |
172 return SOURCE_CC; | 171 return SOURCE_CC; |
173 if (extension == "h") | 172 if (extension == "h") |
174 return SOURCE_H; | 173 return SOURCE_H; |
175 if (extension == "c") | 174 if (extension == "c") |
176 return SOURCE_C; | 175 return SOURCE_C; |
177 | 176 if (extension == "m") |
178 switch (os) { | 177 return SOURCE_M; |
179 case Settings::MAC: | 178 if (extension == "mm") |
180 if (extension == "m") | 179 return SOURCE_MM; |
181 return SOURCE_M; | 180 if (extension == "rc") |
182 if (extension == "mm") | 181 return SOURCE_RC; |
183 return SOURCE_MM; | 182 if (extension == "S") |
184 break; | 183 return SOURCE_S; |
185 | |
186 case Settings::WIN: | |
187 if (extension == "rc") | |
188 return SOURCE_RC; | |
189 // TODO(brettw) asm files. | |
190 break; | |
191 | |
192 default: | |
193 break; | |
194 } | |
195 | |
196 if (os != Settings::WIN) { | |
197 if (extension == "S") | |
198 return SOURCE_S; | |
199 } | |
200 | 184 |
201 return SOURCE_UNKNOWN; | 185 return SOURCE_UNKNOWN; |
202 } | 186 } |
203 | 187 |
204 const char* GetExtensionForOutputType(Target::OutputType type, | 188 const char* GetExtensionForOutputType(Target::OutputType type, |
205 Settings::TargetOS os) { | 189 Settings::TargetOS os) { |
206 switch (os) { | 190 switch (os) { |
207 case Settings::MAC: | 191 case Settings::MAC: |
208 switch (type) { | 192 switch (type) { |
209 case Target::EXECUTABLE: | 193 case Target::EXECUTABLE: |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 return GetGenDirForSourceDir(target->settings(), target->label().dir()); | 708 return GetGenDirForSourceDir(target->settings(), target->label().dir()); |
725 } | 709 } |
726 | 710 |
727 SourceDir GetCurrentOutputDir(const Scope* scope) { | 711 SourceDir GetCurrentOutputDir(const Scope* scope) { |
728 return GetOutputDirForSourceDir(scope->settings(), scope->GetSourceDir()); | 712 return GetOutputDirForSourceDir(scope->settings(), scope->GetSourceDir()); |
729 } | 713 } |
730 | 714 |
731 SourceDir GetCurrentGenDir(const Scope* scope) { | 715 SourceDir GetCurrentGenDir(const Scope* scope) { |
732 return GetGenDirForSourceDir(scope->settings(), scope->GetSourceDir()); | 716 return GetGenDirForSourceDir(scope->settings(), scope->GetSourceDir()); |
733 } | 717 } |
OLD | NEW |