| 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 <iostream> | 5 #include <iostream> |
| 6 #include <map> | 6 #include <map> |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/environment.h" | 11 #include "base/environment.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/timer/elapsed_timer.h" | 13 #include "base/timer/elapsed_timer.h" |
| 14 #include "build/build_config.h" |
| 14 #include "tools/gn/build_settings.h" | 15 #include "tools/gn/build_settings.h" |
| 15 #include "tools/gn/commands.h" | 16 #include "tools/gn/commands.h" |
| 16 #include "tools/gn/err.h" | 17 #include "tools/gn/err.h" |
| 17 #include "tools/gn/filesystem_utils.h" | 18 #include "tools/gn/filesystem_utils.h" |
| 18 #include "tools/gn/gyp_helper.h" | 19 #include "tools/gn/gyp_helper.h" |
| 19 #include "tools/gn/gyp_target_writer.h" | 20 #include "tools/gn/gyp_target_writer.h" |
| 20 #include "tools/gn/location.h" | 21 #include "tools/gn/location.h" |
| 21 #include "tools/gn/parser.h" | 22 #include "tools/gn/parser.h" |
| 22 #include "tools/gn/setup.h" | 23 #include "tools/gn/setup.h" |
| 23 #include "tools/gn/source_file.h" | 24 #include "tools/gn/source_file.h" |
| 24 #include "tools/gn/standard_out.h" | 25 #include "tools/gn/standard_out.h" |
| 25 #include "tools/gn/target.h" | 26 #include "tools/gn/target.h" |
| 26 #include "tools/gn/tokenizer.h" | 27 #include "tools/gn/tokenizer.h" |
| 27 | 28 |
| 28 namespace commands { | 29 namespace commands { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 typedef GypTargetWriter::TargetGroup TargetGroup; | 33 typedef GypTargetWriter::TargetGroup TargetGroup; |
| 33 typedef std::map<Label, TargetGroup> CorrelatedTargetsMap; | 34 typedef std::map<Label, TargetGroup> CorrelatedTargetsMap; |
| 34 typedef std::map<SourceFile, std::vector<TargetGroup> > GroupedTargetsMap; | 35 typedef std::map<SourceFile, std::vector<TargetGroup> > GroupedTargetsMap; |
| 35 typedef std::map<std::string, std::string> StringStringMap; | 36 typedef std::map<std::string, std::string> StringStringMap; |
| 36 typedef std::vector<const BuilderRecord*> RecordVector; | 37 typedef std::vector<const BuilderRecord*> RecordVector; |
| 37 | 38 |
| 39 struct Setups { |
| 40 Setups() |
| 41 : debug(NULL), |
| 42 release(NULL), |
| 43 host_debug(NULL), |
| 44 host_release(NULL), |
| 45 debug64(NULL), |
| 46 release64(NULL), |
| 47 xcode_debug(NULL), |
| 48 xcode_release(NULL), |
| 49 xcode_host_debug(NULL), |
| 50 xcode_host_release(NULL) { |
| 51 } |
| 52 |
| 53 Setup* debug; |
| 54 DependentSetup* release; |
| 55 DependentSetup* host_debug; |
| 56 DependentSetup* host_release; |
| 57 DependentSetup* debug64; |
| 58 DependentSetup* release64; |
| 59 DependentSetup* xcode_debug; |
| 60 DependentSetup* xcode_release; |
| 61 DependentSetup* xcode_host_debug; |
| 62 DependentSetup* xcode_host_release; |
| 63 }; |
| 64 |
| 65 struct TargetVectors { |
| 66 RecordVector debug; |
| 67 RecordVector release; |
| 68 RecordVector host_debug; |
| 69 RecordVector host_release; |
| 70 RecordVector debug64; |
| 71 RecordVector release64; |
| 72 RecordVector xcode_debug; |
| 73 RecordVector xcode_release; |
| 74 RecordVector xcode_host_debug; |
| 75 RecordVector xcode_host_release; |
| 76 }; |
| 77 |
| 38 // This function appends a suffix to the given source directory name. We append | 78 // This function appends a suffix to the given source directory name. We append |
| 39 // a suffix to the last directory component rather than adding a new level so | 79 // a suffix to the last directory component rather than adding a new level so |
| 40 // that the relative location of the files don't change (i.e. a file | 80 // that the relative location of the files don't change (i.e. a file |
| 41 // relative to the build dir might be "../../foo/bar.cc") and we want these to | 81 // relative to the build dir might be "../../foo/bar.cc") and we want these to |
| 42 // be the same in all builds, and in particular the GYP build directories. | 82 // be the same in all builds, and in particular the GYP build directories. |
| 43 SourceDir AppendDirSuffix(const SourceDir& base, const std::string& suffix) { | 83 SourceDir AppendDirSuffix(const SourceDir& base, const std::string& suffix) { |
| 44 return SourceDir(DirectoryWithNoLastSlash(base) + suffix + "/"); | 84 return SourceDir(DirectoryWithNoLastSlash(base) + suffix + "/"); |
| 45 } | 85 } |
| 46 | 86 |
| 87 // We need a "host" build when targeting a device (iOS, Android, ChromeOS). The |
| 88 // host build will correspond to the the system doing the building. |
| 89 bool NeedsHostBuild(CommonSetup* setup) { |
| 90 Args& args = setup->build_settings().build_args(); |
| 91 const Value* os_override = args.GetArgOverride("os"); |
| 92 if (!os_override) |
| 93 return false; // Target OS is the default, which is always the host. |
| 94 if (os_override->type() != Value::STRING) |
| 95 return false; // Build will likely fail later. |
| 96 return os_override->string_value() == "android" || |
| 97 os_override->string_value() == "ios" || |
| 98 os_override->string_value() == "chromeos"; |
| 99 } |
| 100 |
| 101 void SetupHostBuildParams(CommonSetup* setup) { |
| 102 // Re-override the target OS to the default of the current system. |
| 103 #if defined(OS_WIN) |
| 104 const char kDefaultOs[] = "win"; |
| 105 #elif defined(OS_MACOSX) |
| 106 const char kDefaultOs[] = "mac"; |
| 107 #elif defined(OS_LINUX) |
| 108 const char kDefaultOs[] = "linux"; |
| 109 #endif |
| 110 setup->build_settings().build_args().AddArgOverride( |
| 111 "os", Value(NULL, kDefaultOs)); |
| 112 } |
| 113 |
| 47 std::vector<const BuilderRecord*> GetAllResolvedTargetRecords( | 114 std::vector<const BuilderRecord*> GetAllResolvedTargetRecords( |
| 48 const Builder* builder) { | 115 const Builder* builder) { |
| 49 std::vector<const BuilderRecord*> all = builder->GetAllRecords(); | 116 std::vector<const BuilderRecord*> all = builder->GetAllRecords(); |
| 50 std::vector<const BuilderRecord*> result; | 117 std::vector<const BuilderRecord*> result; |
| 51 result.reserve(all.size()); | 118 result.reserve(all.size()); |
| 52 for (size_t i = 0; i < all.size(); i++) { | 119 for (size_t i = 0; i < all.size(); i++) { |
| 53 if (all[i]->type() == BuilderRecord::ITEM_TARGET && | 120 if (all[i]->type() == BuilderRecord::ITEM_TARGET && |
| 54 all[i]->should_generate() && | 121 all[i]->should_generate() && |
| 55 all[i]->item()) | 122 all[i]->item()) |
| 56 result.push_back(all[i]); | 123 result.push_back(all[i]); |
| 57 } | 124 } |
| 58 return result; | 125 return result; |
| 59 } | 126 } |
| 60 | 127 |
| 128 void CorrelateRecordVector(const RecordVector& records, |
| 129 CorrelatedTargetsMap* correlated, |
| 130 const BuilderRecord* TargetGroup::* record_ptr) { |
| 131 for (size_t i = 0; i < records.size(); i++) { |
| 132 const BuilderRecord* record = records[i]; |
| 133 (*correlated)[record->label().GetWithNoToolchain()].*record_ptr = record; |
| 134 } |
| 135 } |
| 136 |
| 137 |
| 61 // Groups targets sharing the same label between debug and release. | 138 // Groups targets sharing the same label between debug and release. |
| 62 // | 139 // |
| 63 // We strip the toolchain label because the 64-bit and 32-bit builds, for | 140 // We strip the toolchain label because the 64-bit and 32-bit builds, for |
| 64 // example, will have different toolchains but we want to correlate them. | 141 // example, will have different toolchains but we want to correlate them. |
| 65 // | 142 // |
| 66 // TODO(brettw) this assumes that everything in the build has the same | 143 // TODO(brettw) this assumes that everything in the build has the same |
| 67 // toolchain. To support cross-compiling and nacl, we'll need to differentiate | 144 // toolchain. To support cross-compiling and nacl, we'll need to differentiate |
| 68 // the 32-vs-64-bit case and the default-toolchain-vs-not case. When we find | 145 // the 32-vs-64-bit case and the default-toolchain-vs-not case. When we find |
| 69 // a target not using hte default toolchain, we should probably just shell | 146 // a target not using hte default toolchain, we should probably just shell |
| 70 // out to ninja. | 147 // out to ninja. |
| 71 void CorrelateTargets(const RecordVector& debug_targets, | 148 void CorrelateTargets(const TargetVectors& targets, |
| 72 const RecordVector& release_targets, | |
| 73 const RecordVector& host_debug_targets, | |
| 74 const RecordVector& host_release_targets, | |
| 75 const RecordVector& debug64_targets, | |
| 76 const RecordVector& release64_targets, | |
| 77 CorrelatedTargetsMap* correlated) { | 149 CorrelatedTargetsMap* correlated) { |
| 78 // Normal. | 150 // Normal. |
| 79 for (size_t i = 0; i < debug_targets.size(); i++) { | 151 CorrelateRecordVector( |
| 80 const BuilderRecord* record = debug_targets[i]; | 152 targets.debug, correlated, &TargetGroup::debug); |
| 81 (*correlated)[record->label().GetWithNoToolchain()].debug = record; | 153 CorrelateRecordVector( |
| 82 } | 154 targets.release, correlated, &TargetGroup::release); |
| 83 for (size_t i = 0; i < release_targets.size(); i++) { | |
| 84 const BuilderRecord* record = release_targets[i]; | |
| 85 (*correlated)[record->label().GetWithNoToolchain()].release = record; | |
| 86 } | |
| 87 | 155 |
| 88 // Host build. | 156 // Host build. |
| 89 for (size_t i = 0; i < host_debug_targets.size(); i++) { | 157 CorrelateRecordVector( |
| 90 const BuilderRecord* record = host_debug_targets[i]; | 158 targets.host_debug, correlated, &TargetGroup::host_debug); |
| 91 (*correlated)[record->label().GetWithNoToolchain()].host_debug = record; | 159 CorrelateRecordVector( |
| 92 } | 160 targets.host_release, correlated, &TargetGroup::host_release); |
| 93 for (size_t i = 0; i < host_release_targets.size(); i++) { | |
| 94 const BuilderRecord* record = host_release_targets[i]; | |
| 95 (*correlated)[record->label().GetWithNoToolchain()].host_release = record; | |
| 96 } | |
| 97 | 161 |
| 98 // Host build. | 162 // 64-bit build. |
| 99 for (size_t i = 0; i < debug64_targets.size(); i++) { | 163 CorrelateRecordVector( |
| 100 const BuilderRecord* record = debug64_targets[i]; | 164 targets.debug64, correlated, &TargetGroup::debug64); |
| 101 (*correlated)[record->label().GetWithNoToolchain()].debug64 = record; | 165 CorrelateRecordVector( |
| 102 } | 166 targets.release64, correlated, &TargetGroup::release64); |
| 103 for (size_t i = 0; i < release64_targets.size(); i++) { | 167 |
| 104 const BuilderRecord* record = release64_targets[i]; | 168 // XCode build. |
| 105 (*correlated)[record->label().GetWithNoToolchain()].release64 = record; | 169 CorrelateRecordVector( |
| 106 } | 170 targets.xcode_debug, correlated, &TargetGroup::xcode_debug); |
| 171 CorrelateRecordVector( |
| 172 targets.xcode_release, correlated, &TargetGroup::xcode_release); |
| 173 CorrelateRecordVector( |
| 174 targets.xcode_host_debug, correlated, &TargetGroup::xcode_host_debug); |
| 175 CorrelateRecordVector( |
| 176 targets.xcode_host_release, correlated, &TargetGroup::xcode_host_release); |
| 107 } | 177 } |
| 108 | 178 |
| 109 // Verifies that both debug and release variants match. They can differ only | 179 // Verifies that both debug and release variants match. They can differ only |
| 110 // by flags. | 180 // by flags. |
| 111 bool EnsureTargetsMatch(const TargetGroup& group, Err* err) { | 181 bool EnsureTargetsMatch(const TargetGroup& group, Err* err) { |
| 182 if (!group.debug && !group.release) |
| 183 return true; |
| 184 |
| 112 // Check that both debug and release made this target. | 185 // Check that both debug and release made this target. |
| 113 if (!group.debug || !group.release) { | 186 if (!group.debug || !group.release) { |
| 114 const BuilderRecord* non_null_one = | 187 const BuilderRecord* non_null_one = |
| 115 group.debug ? group.debug : group.release; | 188 group.debug ? group.debug : group.release; |
| 116 *err = Err(Location(), "The debug and release builds did not both generate " | 189 *err = Err(Location(), "The debug and release builds did not both generate " |
| 117 "a target with the name\n" + | 190 "a target with the name\n" + |
| 118 non_null_one->label().GetUserVisibleName(true)); | 191 non_null_one->label().GetUserVisibleName(true)); |
| 119 return false; | 192 return false; |
| 120 } | 193 } |
| 121 | 194 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 group.debug->label().GetUserVisibleName(true) + | 237 group.debug->label().GetUserVisibleName(true) + |
| 165 "\ndon't agree on the dep\n" + | 238 "\ndon't agree on the dep\n" + |
| 166 debug_target->deps()[i].label.GetUserVisibleName(true)); | 239 debug_target->deps()[i].label.GetUserVisibleName(true)); |
| 167 return false; | 240 return false; |
| 168 } | 241 } |
| 169 } | 242 } |
| 170 return true; | 243 return true; |
| 171 } | 244 } |
| 172 | 245 |
| 173 // Returns the (number of targets, number of GYP files). | 246 // Returns the (number of targets, number of GYP files). |
| 174 std::pair<int, int> WriteGypFiles(CommonSetup* debug_setup, | 247 std::pair<int, int> WriteGypFiles(Setups& setups, Err* err) { |
| 175 CommonSetup* release_setup, | 248 TargetVectors targets; |
| 176 CommonSetup* host_debug_setup, | 249 |
| 177 CommonSetup* host_release_setup, | |
| 178 CommonSetup* debug64_setup, | |
| 179 CommonSetup* release64_setup, | |
| 180 Err* err) { | |
| 181 // Group all targets by output GYP file name. | 250 // Group all targets by output GYP file name. |
| 182 std::vector<const BuilderRecord*> debug_targets = | 251 targets.debug = GetAllResolvedTargetRecords(setups.debug->builder()); |
| 183 GetAllResolvedTargetRecords(debug_setup->builder()); | 252 targets.release = GetAllResolvedTargetRecords(setups.release->builder()); |
| 184 std::vector<const BuilderRecord*> release_targets = | |
| 185 GetAllResolvedTargetRecords(release_setup->builder()); | |
| 186 | 253 |
| 187 // Host build is optional. | 254 // Host build is optional. |
| 188 std::vector<const BuilderRecord*> host_debug_targets; | 255 if (setups.host_debug && setups.host_release) { |
| 189 std::vector<const BuilderRecord*> host_release_targets; | 256 targets.host_debug = |
| 190 if (host_debug_setup && host_release_setup) { | 257 GetAllResolvedTargetRecords(setups.host_debug->builder()); |
| 191 host_debug_targets = GetAllResolvedTargetRecords( | 258 targets.host_release = |
| 192 host_debug_setup->builder()); | 259 GetAllResolvedTargetRecords(setups.host_release->builder()); |
| 193 host_release_targets = GetAllResolvedTargetRecords( | |
| 194 host_release_setup->builder()); | |
| 195 } | 260 } |
| 196 | 261 |
| 197 // 64-bit build is optional. | 262 // 64-bit build is optional. |
| 198 std::vector<const BuilderRecord*> debug64_targets; | 263 if (setups.debug64 && setups.release64) { |
| 199 std::vector<const BuilderRecord*> release64_targets; | 264 targets.debug64 = |
| 200 if (debug64_setup && release64_setup) { | 265 GetAllResolvedTargetRecords(setups.debug64->builder()); |
| 201 debug64_targets = GetAllResolvedTargetRecords( | 266 targets.release64 = |
| 202 debug64_setup->builder()); | 267 GetAllResolvedTargetRecords(setups.release64->builder()); |
| 203 release64_targets = GetAllResolvedTargetRecords( | 268 } |
| 204 release64_setup->builder()); | 269 |
| 270 // Xcode build is optional. |
| 271 if (setups.xcode_debug && setups.xcode_release) { |
| 272 targets.xcode_debug = |
| 273 GetAllResolvedTargetRecords(setups.xcode_debug->builder()); |
| 274 targets.xcode_release = |
| 275 GetAllResolvedTargetRecords(setups.xcode_release->builder()); |
| 276 } |
| 277 if (setups.xcode_host_debug && setups.xcode_host_release) { |
| 278 targets.xcode_host_debug = |
| 279 GetAllResolvedTargetRecords(setups.xcode_host_debug->builder()); |
| 280 targets.xcode_host_release = |
| 281 GetAllResolvedTargetRecords(setups.xcode_host_release->builder()); |
| 205 } | 282 } |
| 206 | 283 |
| 207 // Match up the debug and release version of each target by label. | 284 // Match up the debug and release version of each target by label. |
| 208 CorrelatedTargetsMap correlated; | 285 CorrelatedTargetsMap correlated; |
| 209 CorrelateTargets(debug_targets, release_targets, | 286 CorrelateTargets(targets, &correlated); |
| 210 host_debug_targets, host_release_targets, | |
| 211 debug64_targets, release64_targets, | |
| 212 &correlated); | |
| 213 | 287 |
| 214 GypHelper helper; | 288 GypHelper helper; |
| 215 GroupedTargetsMap grouped_targets; | 289 GroupedTargetsMap grouped_targets; |
| 216 int target_count = 0; | 290 int target_count = 0; |
| 217 for (CorrelatedTargetsMap::iterator i = correlated.begin(); | 291 for (CorrelatedTargetsMap::iterator i = correlated.begin(); |
| 218 i != correlated.end(); ++i) { | 292 i != correlated.end(); ++i) { |
| 219 const TargetGroup& group = i->second; | 293 const TargetGroup& group = i->second; |
| 220 if (!group.debug->should_generate()) | 294 if (!group.get()->should_generate()) |
| 221 continue; // Skip non-generated ones. | 295 continue; // Skip non-generated ones. |
| 222 if (group.debug->item()->AsTarget()->external()) | 296 if (group.get()->item()->AsTarget()->external()) |
| 223 continue; // Skip external ones. | 297 continue; // Skip external ones. |
| 224 if (group.debug->item()->AsTarget()->gyp_file().is_null()) | 298 if (group.get()->item()->AsTarget()->gyp_file().is_null()) |
| 225 continue; // Skip ones without GYP files. | 299 continue; // Skip ones without GYP files. |
| 226 | 300 |
| 227 if (!EnsureTargetsMatch(group, err)) | 301 if (!EnsureTargetsMatch(group, err)) |
| 228 return std::make_pair(0, 0); | 302 return std::make_pair(0, 0); |
| 229 | 303 |
| 230 target_count++; | 304 target_count++; |
| 231 grouped_targets[ | 305 grouped_targets[ |
| 232 helper.GetGypFileForTarget(group.debug->item()->AsTarget(), err)] | 306 helper.GetGypFileForTarget(group.debug->item()->AsTarget(), err)] |
| 233 .push_back(group); | 307 .push_back(group); |
| 234 if (err->has_error()) | 308 if (err->has_error()) |
| 235 return std::make_pair(0, 0); | 309 return std::make_pair(0, 0); |
| 236 } | 310 } |
| 237 | 311 |
| 238 // Extract the toolchain for the debug targets. | 312 // Extract the toolchain for the debug targets. |
| 239 const Toolchain* debug_toolchain = NULL; | 313 const Toolchain* debug_toolchain = NULL; |
| 240 if (!grouped_targets.empty()) { | 314 if (!grouped_targets.empty()) { |
| 241 debug_toolchain = debug_setup->builder()->GetToolchain( | 315 debug_toolchain = setups.debug->builder()->GetToolchain( |
| 242 grouped_targets.begin()->second[0].debug->item()->settings()-> | 316 grouped_targets.begin()->second[0].debug->item()->settings()-> |
| 243 default_toolchain_label()); | 317 default_toolchain_label()); |
| 244 } | 318 } |
| 245 | 319 |
| 246 // Write each GYP file. | 320 // Write each GYP file. |
| 247 for (GroupedTargetsMap::iterator i = grouped_targets.begin(); | 321 for (GroupedTargetsMap::iterator i = grouped_targets.begin(); |
| 248 i != grouped_targets.end(); ++i) { | 322 i != grouped_targets.end(); ++i) { |
| 249 GypTargetWriter::WriteFile(i->first, i->second, debug_toolchain, err); | 323 GypTargetWriter::WriteFile(i->first, i->second, debug_toolchain, err); |
| 250 if (err->has_error()) | 324 if (err->has_error()) |
| 251 return std::make_pair(0, 0); | 325 return std::make_pair(0, 0); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 " }\n" | 394 " }\n" |
| 321 "\n" | 395 "\n" |
| 322 " executable(\"my_app\") {\n" | 396 " executable(\"my_app\") {\n" |
| 323 " deps = [ \":gyp_target\" ]\n" | 397 " deps = [ \":gyp_target\" ]\n" |
| 324 " gyp_file = \"//foo/myapp.gyp\"\n" | 398 " gyp_file = \"//foo/myapp.gyp\"\n" |
| 325 " sources = ...\n" | 399 " sources = ...\n" |
| 326 " }\n"; | 400 " }\n"; |
| 327 | 401 |
| 328 int RunGyp(const std::vector<std::string>& args) { | 402 int RunGyp(const std::vector<std::string>& args) { |
| 329 base::ElapsedTimer timer; | 403 base::ElapsedTimer timer; |
| 404 Setups setups; |
| 330 | 405 |
| 331 // Deliberately leaked to avoid expensive process teardown. | 406 // Deliberately leaked to avoid expensive process teardown. |
| 332 Setup* setup_debug = new Setup; | 407 setups.debug = new Setup; |
| 333 if (!setup_debug->DoSetup()) | 408 if (!setups.debug->DoSetup()) |
| 334 return 1; | 409 return 1; |
| 335 const char kIsDebug[] = "is_debug"; | 410 const char kIsDebug[] = "is_debug"; |
| 336 | 411 |
| 337 SourceDir base_build_dir = setup_debug->build_settings().build_dir(); | 412 SourceDir base_build_dir = setups.debug->build_settings().build_dir(); |
| 338 setup_debug->build_settings().SetBuildDir( | 413 setups.debug->build_settings().SetBuildDir( |
| 339 AppendDirSuffix(base_build_dir, ".Debug")); | 414 AppendDirSuffix(base_build_dir, ".Debug")); |
| 340 | 415 |
| 341 // Make a release build based on the debug one. We use a new directory for | 416 // Make a release build based on the debug one. We use a new directory for |
| 342 // the build output so that they don't stomp on each other. | 417 // the build output so that they don't stomp on each other. |
| 343 DependentSetup* setup_release = new DependentSetup(setup_debug); | 418 setups.release = new DependentSetup(setups.debug); |
| 344 setup_release->build_settings().build_args().AddArgOverride( | 419 setups.release->build_settings().build_args().AddArgOverride( |
| 345 kIsDebug, Value(NULL, false)); | 420 kIsDebug, Value(NULL, false)); |
| 346 setup_release->build_settings().SetBuildDir( | 421 setups.release->build_settings().SetBuildDir( |
| 347 AppendDirSuffix(base_build_dir, ".Release")); | 422 AppendDirSuffix(base_build_dir, ".Release")); |
| 348 | 423 |
| 349 // Host build. | 424 // Host build. |
| 350 DependentSetup* setup_host_debug = NULL; | 425 if (NeedsHostBuild(setups.debug)) { |
| 351 DependentSetup* setup_host_release = NULL; | 426 setups.host_debug = new DependentSetup(setups.debug); |
| 352 // TODO(brettw) hook up host build. | 427 setups.host_debug->build_settings().SetBuildDir( |
| 428 AppendDirSuffix(base_build_dir, ".HostDebug")); |
| 429 SetupHostBuildParams(setups.host_debug); |
| 430 |
| 431 setups.host_release = new DependentSetup(setups.release); |
| 432 setups.host_release->build_settings().SetBuildDir( |
| 433 AppendDirSuffix(base_build_dir, ".HostRelease")); |
| 434 SetupHostBuildParams(setups.host_release); |
| 435 } |
| 353 | 436 |
| 354 // 64-bit build (Windows only). | 437 // 64-bit build (Windows only). |
| 355 DependentSetup* setup_debug64 = NULL; | |
| 356 DependentSetup* setup_release64 = NULL; | |
| 357 #if defined(OS_WIN) | 438 #if defined(OS_WIN) |
| 358 static const char kForceWin64[] = "force_win64"; | 439 static const char kForceWin64[] = "force_win64"; |
| 359 setup_debug64 = new DependentSetup(setup_debug); | 440 setups.debug64 = new DependentSetup(setups.debug); |
| 360 setup_debug64->build_settings().build_args().AddArgOverride( | 441 setups.debug64->build_settings().build_args().AddArgOverride( |
| 361 kForceWin64, Value(NULL, true)); | 442 kForceWin64, Value(NULL, true)); |
| 362 setup_debug64->build_settings().SetBuildDir( | 443 setups.debug64->build_settings().SetBuildDir( |
| 363 AppendDirSuffix(base_build_dir, ".Debug64")); | 444 AppendDirSuffix(base_build_dir, ".Debug64")); |
| 364 | 445 |
| 365 setup_release64 = new DependentSetup(setup_release); | 446 setups.release64 = new DependentSetup(setups.release); |
| 366 setup_release64->build_settings().build_args().AddArgOverride( | 447 setups.release64->build_settings().build_args().AddArgOverride( |
| 367 kForceWin64, Value(NULL, true)); | 448 kForceWin64, Value(NULL, true)); |
| 368 setup_release64->build_settings().SetBuildDir( | 449 setups.release64->build_settings().SetBuildDir( |
| 369 AppendDirSuffix(base_build_dir, ".Release64")); | 450 AppendDirSuffix(base_build_dir, ".Release64")); |
| 370 #endif | 451 #endif |
| 371 | 452 |
| 453 // XCode build (Mac only). |
| 454 #if defined(OS_MACOSX) |
| 455 static const char kGypXCode[] = "is_gyp_xcode_generator"; |
| 456 setups.xcode_debug = new DependentSetup(setups.debug); |
| 457 setups.xcode_debug->build_settings().build_args().AddArgOverride( |
| 458 kGypXCode, Value(NULL, true)); |
| 459 setups.xcode_debug->build_settings().SetBuildDir( |
| 460 AppendDirSuffix(base_build_dir, ".XCodeDebug")); |
| 461 |
| 462 setups.xcode_release = new DependentSetup(setups.release); |
| 463 setups.xcode_release->build_settings().build_args().AddArgOverride( |
| 464 kGypXCode, Value(NULL, true)); |
| 465 setups.xcode_release->build_settings().SetBuildDir( |
| 466 AppendDirSuffix(base_build_dir, ".XCodeRelease")); |
| 467 |
| 468 if (NeedsHostBuild(setups.debug)) { |
| 469 setups.xcode_host_debug = new DependentSetup(setups.xcode_debug); |
| 470 setups.xcode_host_debug->build_settings().SetBuildDir( |
| 471 AppendDirSuffix(base_build_dir, ".XCodeHostDebug")); |
| 472 SetupHostBuildParams(setups.xcode_host_debug); |
| 473 |
| 474 setups.xcode_host_release = new DependentSetup(setups.xcode_release); |
| 475 setups.xcode_host_release->build_settings().SetBuildDir( |
| 476 AppendDirSuffix(base_build_dir, ".XCodeHostRelease")); |
| 477 SetupHostBuildParams(setups.xcode_host_release); |
| 478 } |
| 479 #endif |
| 480 |
| 372 // Run all the builds in parellel. | 481 // Run all the builds in parellel. |
| 373 setup_release->RunPreMessageLoop(); | 482 setups.release->RunPreMessageLoop(); |
| 374 if (setup_host_debug && setup_host_release) { | 483 if (setups.host_debug && setups.host_release) { |
| 375 setup_host_debug->RunPreMessageLoop(); | 484 setups.host_debug->RunPreMessageLoop(); |
| 376 setup_host_release->RunPreMessageLoop(); | 485 setups.host_release->RunPreMessageLoop(); |
| 377 } | 486 } |
| 378 if (setup_debug64 && setup_release64) { | 487 if (setups.debug64 && setups.release64) { |
| 379 setup_debug64->RunPreMessageLoop(); | 488 setups.debug64->RunPreMessageLoop(); |
| 380 setup_release64->RunPreMessageLoop(); | 489 setups.release64->RunPreMessageLoop(); |
| 490 } |
| 491 if (setups.xcode_debug && setups.xcode_release) { |
| 492 setups.xcode_debug->RunPreMessageLoop(); |
| 493 setups.xcode_release->RunPreMessageLoop(); |
| 494 } |
| 495 if (setups.xcode_host_debug && setups.xcode_host_release) { |
| 496 setups.xcode_host_debug->RunPreMessageLoop(); |
| 497 setups.xcode_host_release->RunPreMessageLoop(); |
| 381 } | 498 } |
| 382 | 499 |
| 383 if (!setup_debug->Run()) | 500 if (!setups.debug->Run()) |
| 384 return 1; | 501 return 1; |
| 385 | 502 |
| 386 if (!setup_release->RunPostMessageLoop()) | 503 if (!setups.release->RunPostMessageLoop()) |
| 387 return 1; | 504 return 1; |
| 388 if (setup_host_debug && !setup_host_debug->RunPostMessageLoop()) | 505 if (setups.host_debug && !setups.host_debug->RunPostMessageLoop()) |
| 389 return 1; | 506 return 1; |
| 390 if (setup_host_release && !setup_host_release->RunPostMessageLoop()) | 507 if (setups.host_release && !setups.host_release->RunPostMessageLoop()) |
| 391 return 1; | 508 return 1; |
| 392 if (setup_debug64 && !setup_debug64->RunPostMessageLoop()) | 509 if (setups.debug64 && !setups.debug64->RunPostMessageLoop()) |
| 393 return 1; | 510 return 1; |
| 394 if (setup_release64 && !setup_release64->RunPostMessageLoop()) | 511 if (setups.release64 && !setups.release64->RunPostMessageLoop()) |
| 512 return 1; |
| 513 if (setups.xcode_debug && !setups.xcode_debug->RunPostMessageLoop()) |
| 514 return 1; |
| 515 if (setups.xcode_release && !setups.xcode_release->RunPostMessageLoop()) |
| 516 return 1; |
| 517 if (setups.xcode_host_debug && |
| 518 !setups.xcode_host_debug->RunPostMessageLoop()) |
| 519 return 1; |
| 520 if (setups.xcode_host_release && |
| 521 !setups.xcode_host_release->RunPostMessageLoop()) |
| 395 return 1; | 522 return 1; |
| 396 | 523 |
| 397 Err err; | 524 Err err; |
| 398 std::pair<int, int> counts = | 525 std::pair<int, int> counts = WriteGypFiles(setups, &err); |
| 399 WriteGypFiles(setup_debug, setup_release, | |
| 400 setup_host_debug, setup_host_release, | |
| 401 setup_debug64, setup_release64, | |
| 402 &err); | |
| 403 if (err.has_error()) { | 526 if (err.has_error()) { |
| 404 err.PrintToStdout(); | 527 err.PrintToStdout(); |
| 405 return 1; | 528 return 1; |
| 406 } | 529 } |
| 407 | 530 |
| 408 base::TimeDelta elapsed_time = timer.Elapsed(); | 531 base::TimeDelta elapsed_time = timer.Elapsed(); |
| 409 | 532 |
| 410 if (!CommandLine::ForCurrentProcess()->HasSwitch(kSwitchQuiet)) { | 533 if (!CommandLine::ForCurrentProcess()->HasSwitch(kSwitchQuiet)) { |
| 411 OutputString("Done. ", DECORATION_GREEN); | 534 OutputString("Done. ", DECORATION_GREEN); |
| 412 | 535 |
| 413 std::string stats = "Wrote " + | 536 std::string stats = "Wrote " + |
| 414 base::IntToString(counts.first) + " targets to " + | 537 base::IntToString(counts.first) + " targets to " + |
| 415 base::IntToString(counts.second) + " GYP files read from " + | 538 base::IntToString(counts.second) + " GYP files read from " + |
| 416 base::IntToString( | 539 base::IntToString( |
| 417 setup_debug->scheduler().input_file_manager()->GetInputFileCount()) | 540 setups.debug->scheduler().input_file_manager()->GetInputFileCount()) |
| 418 + " GN files in " + | 541 + " GN files in " + |
| 419 base::IntToString(elapsed_time.InMilliseconds()) + "ms\n"; | 542 base::IntToString(elapsed_time.InMilliseconds()) + "ms\n"; |
| 420 | 543 |
| 421 OutputString(stats); | 544 OutputString(stats); |
| 422 } | 545 } |
| 423 | 546 |
| 424 return 0; | 547 return 0; |
| 425 } | 548 } |
| 426 | 549 |
| 427 } // namespace commands | 550 } // namespace commands |
| OLD | NEW |