OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef TOOLS_GN_XCODE_OBJECT_H_ | 5 #ifndef TOOLS_GN_XCODE_OBJECT_H_ |
6 #define TOOLS_GN_XCODE_OBJECT_H_ | 6 #define TOOLS_GN_XCODE_OBJECT_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 | 15 |
16 // Helper classes to generate Xcode project files. | 16 // Helper classes to generate Xcode project files. |
17 // | 17 // |
18 // This code is based on gyp xcodeproj_file.py generator. It does not support | 18 // This code is based on gyp xcodeproj_file.py generator. It does not support |
19 // all features of Xcode project but instead just enough to implement a hybrid | 19 // all features of Xcode project but instead just enough to implement a hybrid |
20 // mode where Xcode uses external scripts to perform the compilation steps. | 20 // mode where Xcode uses external scripts to perform the compilation steps. |
21 // | 21 // |
22 // See https://chromium.googlesource.com/external/gyp/+/master/pylib/gyp/xcodepr
oj_file.py | 22 // See https://chromium.googlesource.com/external/gyp/+/master/pylib/gyp/xcodepr
oj_file.py |
23 // for more information on Xcode project file format. | 23 // for more information on Xcode project file format. |
24 | 24 |
| 25 enum class CompilerFlags { |
| 26 NONE, |
| 27 HELP, |
| 28 }; |
| 29 |
25 // PBXObjectClass ------------------------------------------------------------- | 30 // PBXObjectClass ------------------------------------------------------------- |
26 | 31 |
27 enum PBXObjectClass { | 32 enum PBXObjectClass { |
28 // Those values needs to stay sorted in alphabetic order. | 33 // Those values needs to stay sorted in alphabetic order. |
29 PBXAggregateTargetClass, | 34 PBXAggregateTargetClass, |
30 PBXBuildFileClass, | 35 PBXBuildFileClass, |
31 PBXFileReferenceClass, | 36 PBXFileReferenceClass, |
32 PBXFrameworksBuildPhaseClass, | 37 PBXFrameworksBuildPhaseClass, |
33 PBXGroupClass, | 38 PBXGroupClass, |
34 PBXNativeTargetClass, | 39 PBXNativeTargetClass, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 152 |
148 private: | 153 private: |
149 DISALLOW_COPY_AND_ASSIGN(PBXAggregateTarget); | 154 DISALLOW_COPY_AND_ASSIGN(PBXAggregateTarget); |
150 }; | 155 }; |
151 | 156 |
152 // PBXBuildFile --------------------------------------------------------------- | 157 // PBXBuildFile --------------------------------------------------------------- |
153 | 158 |
154 class PBXBuildFile : public PBXObject { | 159 class PBXBuildFile : public PBXObject { |
155 public: | 160 public: |
156 PBXBuildFile(const PBXFileReference* file_reference, | 161 PBXBuildFile(const PBXFileReference* file_reference, |
157 const PBXSourcesBuildPhase* build_phase); | 162 const PBXSourcesBuildPhase* build_phase, |
| 163 const CompilerFlags compiler_flag); |
158 ~PBXBuildFile() override; | 164 ~PBXBuildFile() override; |
159 | 165 |
160 // PXBObject implementation. | 166 // PXBObject implementation. |
161 PBXObjectClass Class() const override; | 167 PBXObjectClass Class() const override; |
162 std::string Name() const override; | 168 std::string Name() const override; |
163 void Print(std::ostream& out, unsigned indent) const override; | 169 void Print(std::ostream& out, unsigned indent) const override; |
164 | 170 |
165 private: | 171 private: |
166 const PBXFileReference* file_reference_; | 172 const PBXFileReference* file_reference_; |
167 const PBXSourcesBuildPhase* build_phase_; | 173 const PBXSourcesBuildPhase* build_phase_; |
| 174 const CompilerFlags compiler_flag_; |
168 | 175 |
169 DISALLOW_COPY_AND_ASSIGN(PBXBuildFile); | 176 DISALLOW_COPY_AND_ASSIGN(PBXBuildFile); |
170 }; | 177 }; |
171 | 178 |
172 // PBXFileReference ----------------------------------------------------------- | 179 // PBXFileReference ----------------------------------------------------------- |
173 | 180 |
174 class PBXFileReference : public PBXObject { | 181 class PBXFileReference : public PBXObject { |
175 public: | 182 public: |
176 PBXFileReference(const std::string& name, | 183 PBXFileReference(const std::string& name, |
177 const std::string& path, | 184 const std::string& path, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 public: | 251 public: |
245 PBXNativeTarget(const std::string& name, | 252 PBXNativeTarget(const std::string& name, |
246 const std::string& shell_script, | 253 const std::string& shell_script, |
247 const std::string& config_name, | 254 const std::string& config_name, |
248 const PBXAttributes& attributes, | 255 const PBXAttributes& attributes, |
249 const std::string& product_type, | 256 const std::string& product_type, |
250 const std::string& product_name, | 257 const std::string& product_name, |
251 const PBXFileReference* product_reference); | 258 const PBXFileReference* product_reference); |
252 ~PBXNativeTarget() override; | 259 ~PBXNativeTarget() override; |
253 | 260 |
254 void AddFileForIndexing(const PBXFileReference* file_reference); | 261 void AddFileForIndexing(const PBXFileReference* file_reference, |
| 262 const CompilerFlags compiler_flag); |
255 | 263 |
256 // PBXObject implementation. | 264 // PBXObject implementation. |
257 PBXObjectClass Class() const override; | 265 PBXObjectClass Class() const override; |
258 void Print(std::ostream& out, unsigned indent) const override; | 266 void Print(std::ostream& out, unsigned indent) const override; |
259 | 267 |
260 private: | 268 private: |
261 const PBXFileReference* product_reference_; | 269 const PBXFileReference* product_reference_; |
262 std::string product_type_; | 270 std::string product_type_; |
263 std::string product_name_; | 271 std::string product_name_; |
264 | 272 |
265 DISALLOW_COPY_AND_ASSIGN(PBXNativeTarget); | 273 DISALLOW_COPY_AND_ASSIGN(PBXNativeTarget); |
266 }; | 274 }; |
267 | 275 |
268 // PBXProject ----------------------------------------------------------------- | 276 // PBXProject ----------------------------------------------------------------- |
269 | 277 |
270 class PBXProject : public PBXObject { | 278 class PBXProject : public PBXObject { |
271 public: | 279 public: |
272 PBXProject(const std::string& name, | 280 PBXProject(const std::string& name, |
273 const std::string& config_name, | 281 const std::string& config_name, |
274 const std::string& source_path, | 282 const std::string& source_path, |
275 const PBXAttributes& attributes); | 283 const PBXAttributes& attributes); |
276 ~PBXProject() override; | 284 ~PBXProject() override; |
277 | 285 |
278 void AddSourceFileToIndexingTarget(const std::string& navigator_path, | 286 void AddSourceFileToIndexingTarget(const std::string& navigator_path, |
279 const std::string& source_path); | 287 const std::string& source_path, |
| 288 const CompilerFlags compiler_flag); |
280 void AddSourceFile(const std::string& navigator_path, | 289 void AddSourceFile(const std::string& navigator_path, |
281 const std::string& source_path, | 290 const std::string& source_path, |
| 291 const CompilerFlags compiler_flag, |
282 PBXNativeTarget* target); | 292 PBXNativeTarget* target); |
283 | |
284 void AddAggregateTarget(const std::string& name, | 293 void AddAggregateTarget(const std::string& name, |
285 const std::string& shell_script); | 294 const std::string& shell_script); |
286 void AddIndexingTarget(); | 295 void AddIndexingTarget(); |
287 void AddNativeTarget(const std::string& name, | 296 void AddNativeTarget(const std::string& name, |
288 const std::string& type, | 297 const std::string& type, |
289 const std::string& output_name, | 298 const std::string& output_name, |
290 const std::string& output_type, | 299 const std::string& output_type, |
291 const std::string& shell_script); | 300 const std::string& shell_script); |
292 | 301 |
293 void SetProjectDirPath(const std::string& project_dir_path); | 302 void SetProjectDirPath(const std::string& project_dir_path); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 void Print(std::ostream& out, unsigned indent) const override; | 404 void Print(std::ostream& out, unsigned indent) const override; |
396 | 405 |
397 private: | 406 private: |
398 std::vector<std::unique_ptr<XCBuildConfiguration>> configurations_; | 407 std::vector<std::unique_ptr<XCBuildConfiguration>> configurations_; |
399 const PBXObject* owner_reference_; | 408 const PBXObject* owner_reference_; |
400 | 409 |
401 DISALLOW_COPY_AND_ASSIGN(XCConfigurationList); | 410 DISALLOW_COPY_AND_ASSIGN(XCConfigurationList); |
402 }; | 411 }; |
403 | 412 |
404 #endif // TOOLS_GN_XCODE_OBJECT_H_ | 413 #endif // TOOLS_GN_XCODE_OBJECT_H_ |
OLD | NEW |