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