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_WRITER_H_ | 5 #ifndef TOOLS_GN_XCODE_WRITER_H_ |
6 #define TOOLS_GN_XCODE_WRITER_H_ | 6 #define TOOLS_GN_XCODE_WRITER_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 using PBXAttributes = std::map<std::string, std::string>; | 22 using PBXAttributes = std::map<std::string, std::string>; |
23 class PBXProject; | 23 class PBXProject; |
24 | 24 |
25 namespace base { | 25 namespace base { |
26 class FilePath; | 26 class FilePath; |
27 } | 27 } |
28 | 28 |
29 class XcodeWriter { | 29 class XcodeWriter { |
30 public: | 30 public: |
31 enum TargetOsType { | |
32 WRITER_TARGET_OS_IOS, | |
33 WRITER_TARGET_OS_MACOS, | |
34 }; | |
35 | |
36 // Writes Xcode workspace and project files. | 31 // Writes Xcode workspace and project files. |
37 // | 32 // |
38 // |workspace_name| is the optional name of the workspace file name ("all" | 33 // |workspace_name| is the optional name of the workspace file name ("all" |
39 // is used if not specified). |root_target_name| is the name of the main | 34 // is used if not specified). |root_target_name| is the name of the main |
40 // target corresponding to building "All" (for example "gn_all" in Chromium). | 35 // target corresponding to building "All" (for example "gn_all" in Chromium). |
41 // |ninja_extra_args| are additional arguments to pass to ninja invocation | 36 // |ninja_extra_args| are additional arguments to pass to ninja invocation |
42 // (can be used to increase limit of concurrent processes when using goma). | 37 // (can be used to increase limit of concurrent processes when using goma). |
43 // |dir_filters_string| is optional semicolon-separated list of label patterns | 38 // |dir_filters_string| is optional semicolon-separated list of label patterns |
44 // used to limit the set of generated projects. Only matching targets will be | 39 // used to limit the set of generated projects. Only matching targets will be |
45 // included to the workspace. On failure will populate |err| and return false. | 40 // included to the workspace. On failure will populate |err| and return false. |
46 static bool RunAndWriteFiles(const std::string& workspace_name, | 41 static bool RunAndWriteFiles(const std::string& workspace_name, |
47 const std::string& root_target_name, | 42 const std::string& root_target_name, |
48 const std::string& ninja_extra_args, | 43 const std::string& ninja_extra_args, |
49 const std::string& dir_filters_string, | 44 const std::string& dir_filters_string, |
50 const BuildSettings* build_settings, | 45 const BuildSettings* build_settings, |
51 Builder* builder, | 46 Builder* builder, |
52 Err* err); | 47 Err* err); |
53 | 48 |
54 private: | 49 private: |
55 XcodeWriter(const std::string& name); | 50 XcodeWriter(const std::string& name); |
56 ~XcodeWriter(); | 51 ~XcodeWriter(); |
57 | 52 |
| 53 // Returns the attributes to use for the projects. |
| 54 static bool GetProjectsAttributes( |
| 55 const BuildSettings* build_settings, |
| 56 PBXAttributes* attributes, |
| 57 Err* err); |
| 58 |
58 // Filters the list of targets to only return the targets with artifacts | 59 // Filters the list of targets to only return the targets with artifacts |
59 // usable from Xcode (mostly application bundles). On failure populate |err| | 60 // usable from Xcode (mostly application bundles). On failure populate |err| |
60 // and return false. | 61 // and return false. |
61 static bool FilterTargets(const BuildSettings* build_settings, | 62 static bool FilterTargets(const BuildSettings* build_settings, |
62 const std::vector<const Target*>& all_targets, | 63 const std::vector<const Target*>& all_targets, |
63 const std::string& dir_filters_string, | 64 const std::string& dir_filters_string, |
64 std::vector<const Target*>* targets, | 65 std::vector<const Target*>* targets, |
65 Err* err); | 66 Err* err); |
66 | 67 |
67 // Generate the "products.xcodeproj" project that reference all products | 68 // Generate the "products.xcodeproj" project that reference all products |
68 // (i.e. targets that have a build artefact usable from Xcode, mostly | 69 // (i.e. targets that have a build artefact usable from Xcode, mostly |
69 // application bundles). | 70 // application bundles). |
70 void CreateProductsProject(const std::vector<const Target*>& targets, | 71 void CreateProductsProject(const std::vector<const Target*>& targets, |
71 const PBXAttributes& attributes, | 72 const PBXAttributes& attributes, |
72 const std::string& source_path, | 73 const std::string& source_path, |
73 const std::string& config_name, | 74 const std::string& config_name, |
74 const std::string& root_target, | 75 const std::string& root_target, |
75 const std::string& ninja_extra_args, | 76 const std::string& ninja_extra_args, |
76 const BuildSettings* build_settings, | 77 const BuildSettings* build_settings); |
77 TargetOsType target_os); | |
78 | 78 |
79 // Generates the "sources.xcodeproj" project that reference all source | 79 // Generates the "sources.xcodeproj" project that reference all source |
80 // files to allow Xcode to index them. | 80 // files to allow Xcode to index them. |
81 void CreateSourcesProject(const std::vector<const Target*>& targets, | 81 void CreateSourcesProject(const std::vector<const Target*>& targets, |
82 const SourceDir& root_build_dir, | 82 const SourceDir& root_build_dir, |
83 const PBXAttributes& attributes, | 83 const PBXAttributes& attributes, |
84 const std::string& source_path, | 84 const std::string& source_path, |
85 const std::string& config_name, | 85 const std::string& config_name); |
86 TargetOsType target_os); | |
87 | 86 |
88 bool WriteFiles(const BuildSettings* build_settings, Err* err); | 87 bool WriteFiles(const BuildSettings* build_settings, Err* err); |
89 bool WriteProjectFile(const BuildSettings* build_settings, | 88 bool WriteProjectFile(const BuildSettings* build_settings, |
90 PBXProject* project, | 89 PBXProject* project, |
91 Err* err); | 90 Err* err); |
92 | 91 |
93 void WriteWorkspaceContent(std::ostream& out); | 92 void WriteWorkspaceContent(std::ostream& out); |
94 void WriteProjectContent(std::ostream& out, PBXProject* project); | 93 void WriteProjectContent(std::ostream& out, PBXProject* project); |
95 | 94 |
96 std::string name_; | 95 std::string name_; |
97 std::vector<std::unique_ptr<PBXProject>> projects_; | 96 std::vector<std::unique_ptr<PBXProject>> projects_; |
98 | 97 |
99 DISALLOW_COPY_AND_ASSIGN(XcodeWriter); | 98 DISALLOW_COPY_AND_ASSIGN(XcodeWriter); |
100 }; | 99 }; |
101 | 100 |
102 #endif // TOOLS_GN_XCODE_WRITER_H_ | 101 #endif // TOOLS_GN_XCODE_WRITER_H_ |
OLD | NEW |