[PATCH] D148583: [clang-scan-deps] Add clang-scan-deps to llvm-driver build

Alex Brachet via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 18 08:03:08 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc2423a334585: [clang-scan-deps] Add clang-scan-deps to llvm-driver build (authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148583/new/

https://reviews.llvm.org/D148583

Files:
  clang/tools/clang-scan-deps/CMakeLists.txt
  clang/tools/clang-scan-deps/ClangScanDeps.cpp
  llvm/utils/gn/secondary/clang/tools/clang-scan-deps/BUILD.gn
  utils/bazel/llvm-project-overlay/clang/BUILD.bazel


Index: utils/bazel/llvm-project-overlay/clang/BUILD.bazel
===================================================================
--- utils/bazel/llvm-project-overlay/clang/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/clang/BUILD.bazel
@@ -2251,9 +2251,18 @@
     td_srcs = [ "//llvm:include/llvm/Option/OptParser.td" ],
 )
 
+expand_template(
+    name = "clang-scan-deps-main",
+    out = "clang-scan-deps-driver.cpp",
+    substitutions = {
+        "@TOOL_NAME@": "clang_scan_deps",
+    },
+    template = "//llvm:cmake/modules/llvm-driver-template.cpp.in",
+)
+
 cc_binary(
     name = "clang-scan-deps",
-    srcs = glob(["tools/clang-scan-deps/*.cpp"]),
+    srcs = glob(["tools/clang-scan-deps/*.cpp"]) + ["clang-scan-deps-driver.cpp"],
     stamp = 0,
     deps = [
         ":driver",
Index: llvm/utils/gn/secondary/clang/tools/clang-scan-deps/BUILD.gn
===================================================================
--- llvm/utils/gn/secondary/clang/tools/clang-scan-deps/BUILD.gn
+++ llvm/utils/gn/secondary/clang/tools/clang-scan-deps/BUILD.gn
@@ -1,3 +1,4 @@
+import("//llvm/utils/gn/build/driver_executable.gni")
 import("//llvm/utils/TableGen/tablegen.gni")
 
 tablegen("Opts") {
@@ -5,7 +6,7 @@
   args = [ "-gen-opt-parser-defs" ]
 }
 
-executable("clang-scan-deps") {
+driver_executable("clang-scan-deps") {
   configs += [ "//llvm/utils/gn/build:clang_code" ]
   deps = [
     ":Opts",
Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===================================================================
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -21,6 +21,7 @@
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/JSON.h"
+#include "llvm/Support/LLVMDriver.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/ThreadPool.h"
@@ -657,9 +658,9 @@
 // generating P1689 format, trying to generate the compilation database
 // form specified command line after the positional parameter "--".
 static std::unique_ptr<tooling::CompilationDatabase>
-getCompilationDataBase(int argc, const char **argv, std::string &ErrorMessage) {
+getCompilationDataBase(int argc, char **argv, std::string &ErrorMessage) {
   llvm::InitLLVM X(argc, argv);
-  ParseArgs(argc, const_cast<char **>(argv));
+  ParseArgs(argc, argv);
 
   if (!CompilationDB.empty())
     return tooling::JSONCompilationDatabase::loadFromFile(
@@ -674,7 +675,7 @@
 
   // Trying to get the input file, the output file and the command line options
   // from the positional parameter "--".
-  const char **DoubleDash = std::find(argv, argv + argc, StringRef("--"));
+  char **DoubleDash = std::find(argv, argv + argc, StringRef("--"));
   if (DoubleDash == argv + argc) {
     llvm::errs() << "The command line arguments is required after '--' in "
                     "P1689 per file mode.";
@@ -746,7 +747,7 @@
       FEOpts.Inputs[0].getFile(), OutputFile, CommandLine);
 }
 
-int main(int argc, const char **argv) {
+int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) {
   std::string ErrorMessage;
   std::unique_ptr<tooling::CompilationDatabase> Compilations =
       getCompilationDataBase(argc, argv, ErrorMessage);
Index: clang/tools/clang-scan-deps/CMakeLists.txt
===================================================================
--- clang/tools/clang-scan-deps/CMakeLists.txt
+++ clang/tools/clang-scan-deps/CMakeLists.txt
@@ -14,6 +14,7 @@
 
   DEPENDS
   ScanDepsOptsTableGen
+  GENERATE_DRIVER
   )
 
 set(CLANG_SCAN_DEPS_LIB_DEPS


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148583.514645.patch
Type: text/x-patch
Size: 3605 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230418/5dc4a4a7/attachment-0001.bin>


More information about the cfe-commits mailing list