diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-16 16:46:14 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-16 16:46:14 +0000 |
commit | e3730f817be9693b5ad140a002abff4cbaf674ec (patch) | |
tree | b0aa15b4099915ca23a673a11356b73db2321844 /tools/gn/setup.cc | |
parent | 5fb863442b955f859bee4baf67aeeaf4fdc4b6c4 (diff) | |
download | chromium_src-e3730f817be9693b5ad140a002abff4cbaf674ec.zip chromium_src-e3730f817be9693b5ad140a002abff4cbaf674ec.tar.gz chromium_src-e3730f817be9693b5ad140a002abff4cbaf674ec.tar.bz2 |
GYP generator for GN.
This creates a GYP generator for GN. The GN build is run twice, once for debug and once for release mode. The resulting targets are paired to find the debug/release version of each one, and we write out the results as a GYP file.
Since a GN build can change anything based on the debug/release status, including changing the file list, and GYP can't there are a bunch of checks to make sure that the source files and deps don't vary between the debug and release version of the same target.
I split the Setup class apart so I can make duplicate Setup classes base on an original one (I use this to configure a release build based on the debug one). I added some copy constructors to the necessary classes so this would work.
This reads in the GYP_DEFINES and configures the GN build in the same way. The mapping between GYP_DEFINES and gl flags is hardcoded. I had to write some parsing code for the GYP_DEFINES which is unfortunate.
I added a new GN variable "gyp_file" for targets to set the GYP file that they should be written to.
I added a parameter for the Windows SDK path that matches the GYP build.
This removes the old "GYP" command.
I commented out all of the grit rules. These aren't helping anything right now and just slow down testing.
BUG=307571
R=scottmg@chromium.org
Review URL: https://codereview.chromium.org/26561005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228933 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gn/setup.cc')
-rw-r--r-- | tools/gn/setup.cc | 95 |
1 files changed, 68 insertions, 27 deletions
diff --git a/tools/gn/setup.cc b/tools/gn/setup.cc index b94a4ae..add7101 100644 --- a/tools/gn/setup.cc +++ b/tools/gn/setup.cc @@ -153,8 +153,55 @@ base::FilePath ExtractDepotToolsFromPath() { } // namespace +// CommonSetup ----------------------------------------------------------------- + +CommonSetup::CommonSetup() + : check_for_bad_items_(true) { +} + +CommonSetup::CommonSetup(const CommonSetup& other) + : build_settings_(other.build_settings_), + check_for_bad_items_(other.check_for_bad_items_) { +} + +CommonSetup::~CommonSetup() { +} + +void CommonSetup::RunPreMessageLoop() { + // Load the root build file. + build_settings_.toolchain_manager().StartLoadingUnlocked( + SourceFile("//BUILD.gn")); +} + +bool CommonSetup::RunPostMessageLoop() { + Err err; + if (check_for_bad_items_) { + err = build_settings_.item_tree().CheckForBadItems(); + if (err.has_error()) { + err.PrintToStdout(); + return false; + } + } + + if (!build_settings_.build_args().VerifyAllOverridesUsed(&err)) { + err.PrintToStdout(); + return false; + } + + // Write out tracing and timing if requested. + const CommandLine* cmdline = CommandLine::ForCurrentProcess(); + if (cmdline->HasSwitch(kTimeSwitch)) + PrintLongHelp(SummarizeTraces()); + if (cmdline->HasSwitch(kTracelogSwitch)) + SaveTraces(cmdline->GetSwitchValuePath(kTracelogSwitch)); + + return true; +} + +// Setup ----------------------------------------------------------------------- + Setup::Setup() - : check_for_bad_items_(true), + : CommonSetup(), empty_toolchain_(Label()), empty_settings_(&empty_build_settings_, &empty_toolchain_, std::string()), dotfile_scope_(&empty_settings_) { @@ -198,34 +245,10 @@ bool Setup::DoSetup() { } bool Setup::Run() { - // Load the root build file and start runnung. - build_settings_.toolchain_manager().StartLoadingUnlocked( - SourceFile("//BUILD.gn")); + RunPreMessageLoop(); if (!scheduler_.Run()) return false; - - Err err; - if (check_for_bad_items_) { - err = build_settings_.item_tree().CheckForBadItems(); - if (err.has_error()) { - err.PrintToStdout(); - return false; - } - } - - if (!build_settings_.build_args().VerifyAllOverridesUsed(&err)) { - err.PrintToStdout(); - return false; - } - - // Write out tracing and timing if requested. - const CommandLine* cmdline = CommandLine::ForCurrentProcess(); - if (cmdline->HasSwitch(kTimeSwitch)) - PrintLongHelp(SummarizeTraces()); - if (cmdline->HasSwitch(kTracelogSwitch)) - SaveTraces(cmdline->GetSwitchValuePath(kTracelogSwitch)); - - return true; + return RunPostMessageLoop(); } bool Setup::FillArguments(const CommandLine& cmdline) { @@ -395,3 +418,21 @@ bool Setup::FillOtherConfig(const CommandLine& cmdline) { return true; } + +// DependentSetup -------------------------------------------------------------- + +DependentSetup::DependentSetup(const Setup& main_setup) + : CommonSetup(main_setup) { +} + +DependentSetup::~DependentSetup() { +} + +void DependentSetup::RunPreMessageLoop() { + CommonSetup::RunPreMessageLoop(); +} + +bool DependentSetup::RunPostMessageLoop() { + return CommonSetup::RunPostMessageLoop(); +} + |