Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tools/gn/target_unittest.cc

Issue 2394163004: GN: Check if targets with precompiled headers use unsupported toolchains. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/target.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/target.h" 5 #include "tools/gn/target.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "tools/gn/build_settings.h" 10 #include "tools/gn/build_settings.h"
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 "From //foo:bar\n" 862 "From //foo:bar\n"
863 " header: pch.h\n" 863 " header: pch.h\n"
864 " source: //pcs.cc\n" 864 " source: //pcs.cc\n"
865 "\n" 865 "\n"
866 "From //foo:c2\n" 866 "From //foo:c2\n"
867 " header: pch2.h\n" 867 " header: pch2.h\n"
868 " source: //pcs2.cc", 868 " source: //pcs2.cc",
869 err.help_text()); 869 err.help_text());
870 } 870 }
871 871
872 TEST(Target, PrecompiledHeaderSupport) {
873 TestWithScope setup;
874 Err err;
875
876 std::string pch_1("pch.h");
877 SourceFile pcs_1("//pcs.cc");
878
879 // No source files, so it doesn't matter
880 TestTarget a(setup, "//a", Target::SOURCE_SET);
881 a.config_values().set_precompiled_header(pch_1);
882 a.config_values().set_precompiled_source(pcs_1);
883 ASSERT_TRUE(a.OnResolved(&err));
884
885 // TestWithScope toolchain doesn't support precompiled headers.
886 TestTarget b(setup, "//b", Target::SOURCE_SET);
887 b.config_values().set_precompiled_header(pch_1);
888 b.config_values().set_precompiled_source(pcs_1);
889 b.sources().push_back(SourceFile("//foo/b1.c"));
890 ASSERT_FALSE(b.OnResolved(&err));
891
892 Tool* cxx = setup.toolchain()->GetTool(Toolchain::TYPE_CXX);
893 ASSERT_NE(nullptr, cxx);
894
895 cxx->set_precompiled_header_type(Tool::PCH_GCC);
896
897 // CXX tool now supports PCHs.
898 TestTarget c(setup, "//c", Target::SOURCE_SET);
899 c.config_values().set_precompiled_header(pch_1);
900 c.config_values().set_precompiled_source(pcs_1);
901 c.sources().push_back(SourceFile("//foo/c1.cpp"));
902 ASSERT_TRUE(c.OnResolved(&err));
903 }
904
872 TEST(Target, AssertNoDeps) { 905 TEST(Target, AssertNoDeps) {
873 TestWithScope setup; 906 TestWithScope setup;
874 Err err; 907 Err err;
875 908
876 // A target. 909 // A target.
877 TestTarget a(setup, "//a", Target::SHARED_LIBRARY); 910 TestTarget a(setup, "//a", Target::SHARED_LIBRARY);
878 ASSERT_TRUE(a.OnResolved(&err)); 911 ASSERT_TRUE(a.OnResolved(&err));
879 912
880 // B depends on A and has an assert_no_deps for a random dir. 913 // B depends on A and has an assert_no_deps for a random dir.
881 TestTarget b(setup, "//b", Target::SHARED_LIBRARY); 914 TestTarget b(setup, "//b", Target::SHARED_LIBRARY);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 ASSERT_EQ(c.bundle_data().file_rules().size(), 1u); 1020 ASSERT_EQ(c.bundle_data().file_rules().size(), 1u);
988 ASSERT_EQ(c.bundle_data().file_rules()[0].sources().size(), 1u); 1021 ASSERT_EQ(c.bundle_data().file_rules()[0].sources().size(), 1u);
989 ASSERT_EQ(c.bundle_data().bundle_deps().size(), 1u); 1022 ASSERT_EQ(c.bundle_data().bundle_deps().size(), 1u);
990 1023
991 // E does not have any bundle_data information but gets a list of 1024 // E does not have any bundle_data information but gets a list of
992 // bundle_deps to propagate them during target resolution. 1025 // bundle_deps to propagate them during target resolution.
993 ASSERT_TRUE(e.bundle_data().file_rules().empty()); 1026 ASSERT_TRUE(e.bundle_data().file_rules().empty());
994 ASSERT_TRUE(e.bundle_data().assets_catalog_sources().empty()); 1027 ASSERT_TRUE(e.bundle_data().assets_catalog_sources().empty());
995 ASSERT_EQ(e.bundle_data().bundle_deps().size(), 2u); 1028 ASSERT_EQ(e.bundle_data().bundle_deps().size(), 2u);
996 } 1029 }
OLDNEW
« no previous file with comments | « tools/gn/target.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698