| 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/setup.h" | 5 #include "tools/gn/setup.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 to_check = all_targets; | 195 to_check = all_targets; |
| 196 } | 196 } |
| 197 | 197 |
| 198 if (!commands::CheckPublicHeaders(&build_settings_, all_targets, | 198 if (!commands::CheckPublicHeaders(&build_settings_, all_targets, |
| 199 to_check, false)) { | 199 to_check, false)) { |
| 200 return false; | 200 return false; |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 | 203 |
| 204 // Write out tracing and timing if requested. | 204 // Write out tracing and timing if requested. |
| 205 const CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 205 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 206 if (cmdline->HasSwitch(switches::kTime)) | 206 if (cmdline->HasSwitch(switches::kTime)) |
| 207 PrintLongHelp(SummarizeTraces()); | 207 PrintLongHelp(SummarizeTraces()); |
| 208 if (cmdline->HasSwitch(switches::kTracelog)) | 208 if (cmdline->HasSwitch(switches::kTracelog)) |
| 209 SaveTraces(cmdline->GetSwitchValuePath(switches::kTracelog)); | 209 SaveTraces(cmdline->GetSwitchValuePath(switches::kTracelog)); |
| 210 | 210 |
| 211 return true; | 211 return true; |
| 212 } | 212 } |
| 213 | 213 |
| 214 // Setup ----------------------------------------------------------------------- | 214 // Setup ----------------------------------------------------------------------- |
| 215 | 215 |
| 216 Setup::Setup() | 216 Setup::Setup() |
| 217 : CommonSetup(), | 217 : CommonSetup(), |
| 218 empty_settings_(&empty_build_settings_, std::string()), | 218 empty_settings_(&empty_build_settings_, std::string()), |
| 219 dotfile_scope_(&empty_settings_), | 219 dotfile_scope_(&empty_settings_), |
| 220 fill_arguments_(true) { | 220 fill_arguments_(true) { |
| 221 empty_settings_.set_toolchain_label(Label()); | 221 empty_settings_.set_toolchain_label(Label()); |
| 222 build_settings_.set_item_defined_callback( | 222 build_settings_.set_item_defined_callback( |
| 223 base::Bind(&ItemDefinedCallback, scheduler_.main_loop(), builder_)); | 223 base::Bind(&ItemDefinedCallback, scheduler_.main_loop(), builder_)); |
| 224 | 224 |
| 225 // The scheduler's main loop wasn't created when the Loader was created, so | 225 // The scheduler's main loop wasn't created when the Loader was created, so |
| 226 // we need to set it now. | 226 // we need to set it now. |
| 227 loader_->set_main_loop(scheduler_.main_loop()); | 227 loader_->set_main_loop(scheduler_.main_loop()); |
| 228 } | 228 } |
| 229 | 229 |
| 230 Setup::~Setup() { | 230 Setup::~Setup() { |
| 231 } | 231 } |
| 232 | 232 |
| 233 bool Setup::DoSetup(const std::string& build_dir, bool force_create) { | 233 bool Setup::DoSetup(const std::string& build_dir, bool force_create) { |
| 234 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 234 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 235 | 235 |
| 236 scheduler_.set_verbose_logging(cmdline->HasSwitch(switches::kVerbose)); | 236 scheduler_.set_verbose_logging(cmdline->HasSwitch(switches::kVerbose)); |
| 237 if (cmdline->HasSwitch(switches::kTime) || | 237 if (cmdline->HasSwitch(switches::kTime) || |
| 238 cmdline->HasSwitch(switches::kTracelog)) | 238 cmdline->HasSwitch(switches::kTracelog)) |
| 239 EnableTracing(); | 239 EnableTracing(); |
| 240 | 240 |
| 241 ScopedTrace setup_trace(TraceItem::TRACE_SETUP, "DoSetup"); | 241 ScopedTrace setup_trace(TraceItem::TRACE_SETUP, "DoSetup"); |
| 242 | 242 |
| 243 if (!FillSourceDir(*cmdline)) | 243 if (!FillSourceDir(*cmdline)) |
| 244 return false; | 244 return false; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 275 } | 275 } |
| 276 | 276 |
| 277 Scheduler* Setup::GetScheduler() { | 277 Scheduler* Setup::GetScheduler() { |
| 278 return &scheduler_; | 278 return &scheduler_; |
| 279 } | 279 } |
| 280 | 280 |
| 281 SourceFile Setup::GetBuildArgFile() const { | 281 SourceFile Setup::GetBuildArgFile() const { |
| 282 return SourceFile(build_settings_.build_dir().value() + kBuildArgFileName); | 282 return SourceFile(build_settings_.build_dir().value() + kBuildArgFileName); |
| 283 } | 283 } |
| 284 | 284 |
| 285 bool Setup::FillArguments(const CommandLine& cmdline) { | 285 bool Setup::FillArguments(const base::CommandLine& cmdline) { |
| 286 // Use the args on the command line if specified, and save them. Do this even | 286 // Use the args on the command line if specified, and save them. Do this even |
| 287 // if the list is empty (this means clear any defaults). | 287 // if the list is empty (this means clear any defaults). |
| 288 if (cmdline.HasSwitch(switches::kArgs)) { | 288 if (cmdline.HasSwitch(switches::kArgs)) { |
| 289 if (!FillArgsFromCommandLine(cmdline.GetSwitchValueASCII(switches::kArgs))) | 289 if (!FillArgsFromCommandLine(cmdline.GetSwitchValueASCII(switches::kArgs))) |
| 290 return false; | 290 return false; |
| 291 SaveArgsToFile(); | 291 SaveArgsToFile(); |
| 292 return true; | 292 return true; |
| 293 } | 293 } |
| 294 | 294 |
| 295 // No command line args given, use the arguments from the build dir (if any). | 295 // No command line args given, use the arguments from the build dir (if any). |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 return false; | 390 return false; |
| 391 } | 391 } |
| 392 | 392 |
| 393 // Add a dependency on the build arguments file. If this changes, we want | 393 // Add a dependency on the build arguments file. If this changes, we want |
| 394 // to re-generate the build. | 394 // to re-generate the build. |
| 395 g_scheduler->AddGenDependency(build_arg_file); | 395 g_scheduler->AddGenDependency(build_arg_file); |
| 396 | 396 |
| 397 return true; | 397 return true; |
| 398 } | 398 } |
| 399 | 399 |
| 400 bool Setup::FillSourceDir(const CommandLine& cmdline) { | 400 bool Setup::FillSourceDir(const base::CommandLine& cmdline) { |
| 401 // Find the .gn file. | 401 // Find the .gn file. |
| 402 base::FilePath root_path; | 402 base::FilePath root_path; |
| 403 | 403 |
| 404 // Prefer the command line args to the config file. | 404 // Prefer the command line args to the config file. |
| 405 base::FilePath relative_root_path = | 405 base::FilePath relative_root_path = |
| 406 cmdline.GetSwitchValuePath(switches::kRoot); | 406 cmdline.GetSwitchValuePath(switches::kRoot); |
| 407 if (!relative_root_path.empty()) { | 407 if (!relative_root_path.empty()) { |
| 408 root_path = base::MakeAbsoluteFilePath(relative_root_path); | 408 root_path = base::MakeAbsoluteFilePath(relative_root_path); |
| 409 if (root_path.empty()) { | 409 if (root_path.empty()) { |
| 410 Err(Location(), "Root source path not found.", | 410 Err(Location(), "Root source path not found.", |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 | 535 |
| 536 dotfile_root_->AsBlock()->ExecuteBlockInScope(&dotfile_scope_, &err); | 536 dotfile_root_->AsBlock()->ExecuteBlockInScope(&dotfile_scope_, &err); |
| 537 if (err.has_error()) { | 537 if (err.has_error()) { |
| 538 err.PrintToStdout(); | 538 err.PrintToStdout(); |
| 539 return false; | 539 return false; |
| 540 } | 540 } |
| 541 | 541 |
| 542 return true; | 542 return true; |
| 543 } | 543 } |
| 544 | 544 |
| 545 bool Setup::FillOtherConfig(const CommandLine& cmdline) { | 545 bool Setup::FillOtherConfig(const base::CommandLine& cmdline) { |
| 546 Err err; | 546 Err err; |
| 547 | 547 |
| 548 // Secondary source path, read from the config file if present. | 548 // Secondary source path, read from the config file if present. |
| 549 // Read from the config file if present. | 549 // Read from the config file if present. |
| 550 const Value* secondary_value = | 550 const Value* secondary_value = |
| 551 dotfile_scope_.GetValue("secondary_source", true); | 551 dotfile_scope_.GetValue("secondary_source", true); |
| 552 if (secondary_value) { | 552 if (secondary_value) { |
| 553 if (!secondary_value->VerifyTypeIs(Value::STRING, &err)) { | 553 if (!secondary_value->VerifyTypeIs(Value::STRING, &err)) { |
| 554 err.PrintToStdout(); | 554 err.PrintToStdout(); |
| 555 return false; | 555 return false; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 } | 640 } |
| 641 | 641 |
| 642 void DependentSetup::RunPreMessageLoop() { | 642 void DependentSetup::RunPreMessageLoop() { |
| 643 CommonSetup::RunPreMessageLoop(); | 643 CommonSetup::RunPreMessageLoop(); |
| 644 } | 644 } |
| 645 | 645 |
| 646 bool DependentSetup::RunPostMessageLoop() { | 646 bool DependentSetup::RunPostMessageLoop() { |
| 647 return CommonSetup::RunPostMessageLoop(); | 647 return CommonSetup::RunPostMessageLoop(); |
| 648 } | 648 } |
| 649 | 649 |
| OLD | NEW |