summaryrefslogtreecommitdiffstats
path: root/tools/gn/command_check.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-07 22:17:35 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-07 22:17:35 +0000
commit126d8b5e3a7efa3e2584de4c1bc31c6460233ca6 (patch)
tree91c7311d1161422ffdf91b9ce0a222a345c03ffe /tools/gn/command_check.cc
parent44b4f0e59d30953db7cd89dd95266f0f5973e1da (diff)
downloadchromium_src-126d8b5e3a7efa3e2584de4c1bc31c6460233ca6.zip
chromium_src-126d8b5e3a7efa3e2584de4c1bc31c6460233ca6.tar.gz
chromium_src-126d8b5e3a7efa3e2584de4c1bc31c6460233ca6.tar.bz2
Add optional public header checking to GN build
You can invoke this either using the "--check" argument to the gen command (for use on buildbots) or by running "gn check" (for developer on-demand use). This adds support for "public" headers for a target, and an optional "--check" flag to the gen command that implements checkdeps-like include checking. Basically if you include a file that's declared in the build, it has to be in the public section of one of your dependents (or that dependent doesn't have a public section, which implies everything is public). This roughly maps to Blaze's behavior around the public headers. Moves modp_b64 build file to main tree. Remove modp_b64 hack for older versions of VC missing stdint (this included basictypes which caused a header check failure). I also added some base dependencies and some other minor build changes to solve some other issues identified by the check. The remaining one is that a file in base/metrics depends on ipc (!) BUG= R=scottmg@chromium.org Review URL: https://codereview.chromium.org/216903004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262216 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gn/command_check.cc')
-rw-r--r--tools/gn/command_check.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/tools/gn/command_check.cc b/tools/gn/command_check.cc
new file mode 100644
index 0000000..a84bdf3
--- /dev/null
+++ b/tools/gn/command_check.cc
@@ -0,0 +1,40 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "tools/gn/commands.h"
+#include "tools/gn/setup.h"
+#include "tools/gn/standard_out.h"
+
+namespace commands {
+
+const char kCheck[] = "check";
+const char kCheck_HelpShort[] =
+ "check: Check header dependencies.";
+const char kCheck_Help[] =
+ "gn check: Check header dependencies.\n"
+ "\n"
+ " \"gn check\" is the same thing as \"gn gen\" with the \"--check\" flag\n"
+ " except that this command does not write out any build files. It's\n"
+ " intended to be an easy way to manually trigger include file checking.\n"
+ "\n"
+ " See \"gn help\" for the common command-line switches.\n";
+
+// Note: partially duplicated in command_gyp.cc.
+int RunCheck(const std::vector<std::string>& args) {
+ // Deliberately leaked to avoid expensive process teardown.
+ Setup* setup = new Setup();
+ // TODO(brettw) bug 343726: Use a temporary directory instead of this
+ // default one to avoid messing up any build that's in there.
+ if (!setup->DoSetup("//out/Default"))
+ return 1;
+ setup->set_check_public_headers(true);
+
+ if (!setup->Run())
+ return 1;
+
+ OutputString("Header dependency check OK\n", DECORATION_GREEN);
+ return 0;
+}
+
+} // namespace commands