diff options
author | brettw <brettw@chromium.org> | 2015-06-29 16:00:15 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-29 23:01:02 +0000 |
commit | 3dab5fe87ddb0efe646f6ab393ab07533d75237d (patch) | |
tree | 81ca968a3e2cb0bd140cd1de88ad1af8cbab54bd /tools/gn/target_unittest.cc | |
parent | 6cd7b1a4af16d8d5d81d450edc6ac06105ca8f7e (diff) | |
download | chromium_src-3dab5fe87ddb0efe646f6ab393ab07533d75237d.zip chromium_src-3dab5fe87ddb0efe646f6ab393ab07533d75237d.tar.gz chromium_src-3dab5fe87ddb0efe646f6ab393ab07533d75237d.tar.bz2 |
Windows precompiled header support in GN.
Introduces aprecompiled_header_type flag on a tool to say whether it supports precompiled headers, and flags on configs/targets that allow one to specify which header is precompiled.
This does not implement GCC precompiled headers, but the type flag will allow future expansion (the implementation will be mostly separate).
Renames SOURCE_CC to SOURCE_CPP to avoid confusion with Toolchain::TYPE_CC (which is actually the C compiler).
BUG=297678
Review URL: https://codereview.chromium.org/1207903002
Cr-Commit-Position: refs/heads/master@{#336674}
Diffstat (limited to 'tools/gn/target_unittest.cc')
-rw-r--r-- | tools/gn/target_unittest.cc | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tools/gn/target_unittest.cc b/tools/gn/target_unittest.cc index 48fb84c..c9e0b1e 100644 --- a/tools/gn/target_unittest.cc +++ b/tools/gn/target_unittest.cc @@ -558,3 +558,58 @@ TEST(Target, WriteFileGeneratedInputs) { // Should be OK. EXPECT_TRUE(scheduler.GetUnknownGeneratedInputs().empty()); } + +TEST(Target, ResolvePrecompiledHeaders) { + TestWithScope setup; + Err err; + + Target target(setup.settings(), Label(SourceDir("//foo/"), "bar")); + + // Target with no settings, no configs, should be a no-op. + EXPECT_TRUE(target.ResolvePrecompiledHeaders(&err)); + + // Config with PCH values. + Config config_1(setup.settings(), Label(SourceDir("//foo/"), "c1")); + std::string pch_1("pch.h"); + SourceFile pcs_1("//pcs.cc"); + config_1.config_values().set_precompiled_header(pch_1); + config_1.config_values().set_precompiled_source(pcs_1); + target.configs().push_back(LabelConfigPair(&config_1)); + + // No PCH info specified on target, but the config specifies one, the + // values should get copied to the target. + EXPECT_TRUE(target.ResolvePrecompiledHeaders(&err)); + EXPECT_EQ(pch_1, target.config_values().precompiled_header()); + EXPECT_TRUE(target.config_values().precompiled_source() == pcs_1); + + // Now both target and config have matching PCH values. Resolving again + // should be a no-op since they all match. + EXPECT_TRUE(target.ResolvePrecompiledHeaders(&err)); + EXPECT_TRUE(target.config_values().precompiled_header() == pch_1); + EXPECT_TRUE(target.config_values().precompiled_source() == pcs_1); + + // Second config with different PCH values. + Config config_2(setup.settings(), Label(SourceDir("//foo/"), "c2")); + std::string pch_2("pch2.h"); + SourceFile pcs_2("//pcs2.cc"); + config_2.config_values().set_precompiled_header(pch_2); + config_2.config_values().set_precompiled_source(pcs_2); + target.configs().push_back(LabelConfigPair(&config_2)); + + // This should be an error since they don't match. + EXPECT_FALSE(target.ResolvePrecompiledHeaders(&err)); + + // Make sure the proper labels are blamed. + EXPECT_EQ( + "The target //foo:bar\n" + "has conflicting precompiled header settings.\n" + "\n" + "From //foo:bar\n" + " header: pch.h\n" + " source: //pcs.cc\n" + "\n" + "From //foo:c2\n" + " header: pch2.h\n" + " source: //pcs2.cc", + err.help_text()); +} |