| 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/builder.h" | 5 #include "tools/gn/builder.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "tools/gn/action_values.h" |
| 10 #include "tools/gn/config.h" | 11 #include "tools/gn/config.h" |
| 11 #include "tools/gn/deps_iterator.h" | 12 #include "tools/gn/deps_iterator.h" |
| 12 #include "tools/gn/err.h" | 13 #include "tools/gn/err.h" |
| 13 #include "tools/gn/loader.h" | 14 #include "tools/gn/loader.h" |
| 14 #include "tools/gn/pool.h" | 15 #include "tools/gn/pool.h" |
| 15 #include "tools/gn/scheduler.h" | 16 #include "tools/gn/scheduler.h" |
| 16 #include "tools/gn/settings.h" | 17 #include "tools/gn/settings.h" |
| 17 #include "tools/gn/target.h" | 18 #include "tools/gn/target.h" |
| 18 #include "tools/gn/trace.h" | 19 #include "tools/gn/trace.h" |
| 19 | 20 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 221 |
| 221 bool Builder::TargetDefined(BuilderRecord* record, Err* err) { | 222 bool Builder::TargetDefined(BuilderRecord* record, Err* err) { |
| 222 Target* target = record->item()->AsTarget(); | 223 Target* target = record->item()->AsTarget(); |
| 223 | 224 |
| 224 if (!AddDeps(record, target->public_deps(), err) || | 225 if (!AddDeps(record, target->public_deps(), err) || |
| 225 !AddDeps(record, target->private_deps(), err) || | 226 !AddDeps(record, target->private_deps(), err) || |
| 226 !AddDeps(record, target->data_deps(), err) || | 227 !AddDeps(record, target->data_deps(), err) || |
| 227 !AddDeps(record, target->configs().vector(), err) || | 228 !AddDeps(record, target->configs().vector(), err) || |
| 228 !AddDeps(record, target->all_dependent_configs(), err) || | 229 !AddDeps(record, target->all_dependent_configs(), err) || |
| 229 !AddDeps(record, target->public_configs(), err) || | 230 !AddDeps(record, target->public_configs(), err) || |
| 231 !AddActionValuesDep(record, target->action_values(), err) || |
| 230 !AddToolchainDep(record, target, err)) | 232 !AddToolchainDep(record, target, err)) |
| 231 return false; | 233 return false; |
| 232 | 234 |
| 233 // All targets in the default toolchain get generated by default. We also | 235 // All targets in the default toolchain get generated by default. We also |
| 234 // check if this target was previously marked as "required" and force setting | 236 // check if this target was previously marked as "required" and force setting |
| 235 // the bit again so the target's dependencies (which we now know) get the | 237 // the bit again so the target's dependencies (which we now know) get the |
| 236 // required bit pushed to them. | 238 // required bit pushed to them. |
| 237 if (record->should_generate() || target->settings()->is_default()) | 239 if (record->should_generate() || target->settings()->is_default()) |
| 238 RecursiveSetShouldGenerate(record, true); | 240 RecursiveSetShouldGenerate(record, true); |
| 239 | 241 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 for (const auto& target : targets) { | 384 for (const auto& target : targets) { |
| 383 BuilderRecord* dep_record = GetOrCreateRecordOfType( | 385 BuilderRecord* dep_record = GetOrCreateRecordOfType( |
| 384 target.label, target.origin, BuilderRecord::ITEM_TARGET, err); | 386 target.label, target.origin, BuilderRecord::ITEM_TARGET, err); |
| 385 if (!dep_record) | 387 if (!dep_record) |
| 386 return false; | 388 return false; |
| 387 record->AddDep(dep_record); | 389 record->AddDep(dep_record); |
| 388 } | 390 } |
| 389 return true; | 391 return true; |
| 390 } | 392 } |
| 391 | 393 |
| 394 bool Builder::AddActionValuesDep(BuilderRecord* record, |
| 395 const ActionValues& action_values, |
| 396 Err* err) { |
| 397 if (action_values.pool().label.is_null()) |
| 398 return true; |
| 399 |
| 400 BuilderRecord* pool_record = GetResolvedRecordOfType( |
| 401 action_values.pool().label, action_values.pool().origin, |
| 402 BuilderRecord::ITEM_POOL, err); |
| 403 if (!pool_record) |
| 404 return false; |
| 405 record->AddDep(pool_record); |
| 406 |
| 407 return true; |
| 408 } |
| 409 |
| 392 bool Builder::AddToolchainDep(BuilderRecord* record, | 410 bool Builder::AddToolchainDep(BuilderRecord* record, |
| 393 const Target* target, | 411 const Target* target, |
| 394 Err* err) { | 412 Err* err) { |
| 395 BuilderRecord* toolchain_record = GetOrCreateRecordOfType( | 413 BuilderRecord* toolchain_record = GetOrCreateRecordOfType( |
| 396 target->settings()->toolchain_label(), target->defined_from(), | 414 target->settings()->toolchain_label(), target->defined_from(), |
| 397 BuilderRecord::ITEM_TOOLCHAIN, err); | 415 BuilderRecord::ITEM_TOOLCHAIN, err); |
| 398 if (!toolchain_record) | 416 if (!toolchain_record) |
| 399 return false; | 417 return false; |
| 400 record->AddDep(toolchain_record); | 418 record->AddDep(toolchain_record); |
| 401 | 419 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 432 DCHECK(record->can_resolve() && !record->resolved()); | 450 DCHECK(record->can_resolve() && !record->resolved()); |
| 433 | 451 |
| 434 if (record->type() == BuilderRecord::ITEM_TARGET) { | 452 if (record->type() == BuilderRecord::ITEM_TARGET) { |
| 435 Target* target = record->item()->AsTarget(); | 453 Target* target = record->item()->AsTarget(); |
| 436 if (!ResolveDeps(&target->public_deps(), err) || | 454 if (!ResolveDeps(&target->public_deps(), err) || |
| 437 !ResolveDeps(&target->private_deps(), err) || | 455 !ResolveDeps(&target->private_deps(), err) || |
| 438 !ResolveDeps(&target->data_deps(), err) || | 456 !ResolveDeps(&target->data_deps(), err) || |
| 439 !ResolveConfigs(&target->configs(), err) || | 457 !ResolveConfigs(&target->configs(), err) || |
| 440 !ResolveConfigs(&target->all_dependent_configs(), err) || | 458 !ResolveConfigs(&target->all_dependent_configs(), err) || |
| 441 !ResolveConfigs(&target->public_configs(), err) || | 459 !ResolveConfigs(&target->public_configs(), err) || |
| 460 !ResolveActionValues(&target->action_values(), err) || |
| 442 !ResolveToolchain(target, err)) | 461 !ResolveToolchain(target, err)) |
| 443 return false; | 462 return false; |
| 444 } else if (record->type() == BuilderRecord::ITEM_CONFIG) { | 463 } else if (record->type() == BuilderRecord::ITEM_CONFIG) { |
| 445 Config* config = record->item()->AsConfig(); | 464 Config* config = record->item()->AsConfig(); |
| 446 if (!ResolveConfigs(&config->configs(), err)) | 465 if (!ResolveConfigs(&config->configs(), err)) |
| 447 return false; | 466 return false; |
| 448 } else if (record->type() == BuilderRecord::ITEM_TOOLCHAIN) { | 467 } else if (record->type() == BuilderRecord::ITEM_TOOLCHAIN) { |
| 449 Toolchain* toolchain = record->item()->AsToolchain(); | 468 Toolchain* toolchain = record->item()->AsToolchain(); |
| 450 if (!ResolveDeps(&toolchain->deps(), err)) | 469 if (!ResolveDeps(&toolchain->deps(), err)) |
| 451 return false; | 470 return false; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 target->settings()->toolchain_label().GetUserVisibleName(false)); | 531 target->settings()->toolchain_label().GetUserVisibleName(false)); |
| 513 return false; | 532 return false; |
| 514 } | 533 } |
| 515 | 534 |
| 516 if (!target->SetToolchain(record->item()->AsToolchain(), err)) | 535 if (!target->SetToolchain(record->item()->AsToolchain(), err)) |
| 517 return false; | 536 return false; |
| 518 | 537 |
| 519 return true; | 538 return true; |
| 520 } | 539 } |
| 521 | 540 |
| 541 bool Builder::ResolveActionValues(ActionValues* action_values, Err* err) { |
| 542 if (action_values->pool().label.is_null()) |
| 543 return true; |
| 544 |
| 545 BuilderRecord* record = GetResolvedRecordOfType( |
| 546 action_values->pool().label, action_values->pool().origin, |
| 547 BuilderRecord::ITEM_POOL, err); |
| 548 if (!record) |
| 549 return false; |
| 550 action_values->set_pool(LabelPtrPair<Pool>(record->item()->AsPool())); |
| 551 |
| 552 return true; |
| 553 } |
| 554 |
| 522 bool Builder::ResolvePools(Toolchain* toolchain, Err* err) { | 555 bool Builder::ResolvePools(Toolchain* toolchain, Err* err) { |
| 523 for (int i = Toolchain::TYPE_NONE + 1; i < Toolchain::TYPE_NUMTYPES; i++) { | 556 for (int i = Toolchain::TYPE_NONE + 1; i < Toolchain::TYPE_NUMTYPES; i++) { |
| 524 Toolchain::ToolType tool_type = static_cast<Toolchain::ToolType>(i); | 557 Toolchain::ToolType tool_type = static_cast<Toolchain::ToolType>(i); |
| 525 Tool* tool = toolchain->GetTool(tool_type); | 558 Tool* tool = toolchain->GetTool(tool_type); |
| 526 if (!tool || tool->pool().label.is_null()) | 559 if (!tool || tool->pool().label.is_null()) |
| 527 continue; | 560 continue; |
| 528 | 561 |
| 529 BuilderRecord* record = | 562 BuilderRecord* record = |
| 530 GetResolvedRecordOfType(tool->pool().label, toolchain->defined_from(), | 563 GetResolvedRecordOfType(tool->pool().label, toolchain->defined_from(), |
| 531 BuilderRecord::ITEM_POOL, err); | 564 BuilderRecord::ITEM_POOL, err); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 551 std::string ret; | 584 std::string ret; |
| 552 for (size_t i = 0; i < cycle.size(); i++) { | 585 for (size_t i = 0; i < cycle.size(); i++) { |
| 553 ret += " " + cycle[i]->label().GetUserVisibleName(false); | 586 ret += " " + cycle[i]->label().GetUserVisibleName(false); |
| 554 if (i != cycle.size() - 1) | 587 if (i != cycle.size() - 1) |
| 555 ret += " ->"; | 588 ret += " ->"; |
| 556 ret += "\n"; | 589 ret += "\n"; |
| 557 } | 590 } |
| 558 | 591 |
| 559 return ret; | 592 return ret; |
| 560 } | 593 } |
| OLD | NEW |