Make compile_commands.json work for vscode

Use hedron_compile_commands to generate compile_commands.json

Change-Id: I764c4eb7b2f69cf2b233374947275d3f2452d5d9
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/BUILD b/BUILD
index eea9edb..b38e376 100644
--- a/BUILD
+++ b/BUILD
@@ -2,6 +2,7 @@
 load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
 load("@npm//:defs.bzl", "npm_link_all_packages")
 load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
+load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")
 
 # Link npm packages
 npm_link_all_packages(name = "node_modules")
@@ -80,3 +81,19 @@
     name = "gazelle",
     visibility = ["//tools/lint:__subpackages__"],
 )
+
+refresh_compile_commands(
+    name = "refresh_compile_commands",
+
+    # Specify the targets of interest.
+    # For example, specify a dict of targets and any flags required to build.
+    targets = {
+        "//aos/...": "-c opt",
+        "//frc971/...": "-c opt",
+    },
+    # No need to add flags already in .bazelrc. They're automatically picked up.
+    # If you don't need flags, a list of targets is also okay, as is a single target string.
+    # Wildcard patterns, like //... for everything, *are* allowed here, just like a build.
+    # As are additional targets (+) and subtractions (-), like in bazel query https://docs.bazel.build/versions/main/query.html#expressions
+    # And if you're working on a header-only library, specify a test or binary target that compiles it.
+)
diff --git a/WORKSPACE b/WORKSPACE
index 5b3bea3..55fcd6c 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1627,3 +1627,19 @@
     strip_prefix = "cccl-931dc6793482c61edbc97b7a19256874fd264313",
     url = "https://github.com/NVIDIA/cccl/archive/931dc6793482c61edbc97b7a19256874fd264313.zip",
 )
+
+# Hedron's Compile Commands Extractor for Bazel
+# https://github.com/hedronvision/bazel-compile-commands-extractor
+http_archive(
+    name = "hedron_compile_commands",
+    strip_prefix = "bazel-compile-commands-extractor-daae6f40adfa5fdb7c89684cbe4d88b691c63b2d",
+
+    # Replace the commit hash (daae6f40adfa5fdb7c89684cbe4d88b691c63b2d) in both places (below) with the latest (https://github.com/hedronvision/bazel-compile-commands-extractor/commits/main), rather than using the stale one here.
+    # Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README).
+    url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/daae6f40adfa5fdb7c89684cbe4d88b691c63b2d.tar.gz",
+    # When you first run this tool, it'll recommend a sha256 hash to put here with a message like: "DEBUG: Rule 'hedron_compile_commands' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = ..."
+)
+
+load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup")
+
+hedron_compile_commands_setup()
diff --git a/compilers/amd64_debian_rootfs.BUILD b/compilers/amd64_debian_rootfs.BUILD
index 8bec407..57246ae 100644
--- a/compilers/amd64_debian_rootfs.BUILD
+++ b/compilers/amd64_debian_rootfs.BUILD
@@ -14,10 +14,6 @@
         ],
         exclude = [
             "usr/share/**",
-            "usr/include/thrust/**",
-            "usr/include/nv/**",
-            "usr/include/cuda/**",
-            "usr/include/cub/**",
             "usr/bin/X11",
         ],
     ),