Disable compile sandboxing, add global incl const

These two changes facilitate more soong-like include handling in cc
libraries, which will help us sprint towards building bionic in mixed
builds.

Test: mixed_libc.sh and bp2build.sh ci scripts
Change-Id: If2d08f9a20f9d6faa405ae73cb8d28469891643f
diff --git a/bazel.BUILD b/bazel.BUILD
index c23ac90..5fdaa1b 100644
--- a/bazel.BUILD
+++ b/bazel.BUILD
@@ -1,56 +1 @@
-load(
-  "@lunch//:env.bzl",
-  "TARGET_PRODUCT",
-  "TARGET_BUILD_VARIANT",
-  "COMBINED_NINJA",
-  "KATI_NINJA",
-  "PACKAGE_NINJA",
-  "SOONG_NINJA"
-)
-
-ninja_graph(
-    name = "combined_graph",
-    main = COMBINED_NINJA,
-    # This assumes that --skip-make is *not* used, so the Kati and Package files exists.
-    ninja_srcs = [
-        KATI_NINJA,
-        PACKAGE_NINJA,
-        SOONG_NINJA,
-    ],
-    # TODO(b/171012031): Stop hardcoding "out/".
-    output_root = "out",
-    # These files are created externally of the Ninja action graph, for
-    # example, when Kati parses the product configuration Make files to
-    # create soong/soong.variables.
-    #
-    # Since these aren't created by actions in the ninja_graph .ninja
-    # inputs, Bazel will fail with missing inputs while executing
-    # ninja_build. output_root_inputs allowlists these files for Bazel to
-    # symlink them into the execution root, treating them as source files
-    # in the output directory (toplevel_output_directories).
-    output_root_inputs = [
-        "build_date.txt",
-        "empty",
-        "soong/build_number.txt",
-        "soong/dexpreopt.config",
-        "soong/soong.variables",
-    ],
-    output_root_input_dirs = [
-        "bazel/output/execroot/sourceroot",
-        "bazel/output/execroot/bazel_tools",
-        ".module_paths",
-        "soong/.bootstrap",
-        "soong/.minibootstrap",
-    ],
-)
-
-ninja_build(
-    name = "%s-%s" % (TARGET_PRODUCT, TARGET_BUILD_VARIANT),
-    ninja_graph = ":combined_graph",
-    output_groups = {
-        "droid": ["droid"],
-        # TODO(b/160568333): Stop hardcoding output groups statically for Ninja targets.
-        # libc is declared here to support CI builds running USE_BAZEL=1 USE_BAZEL_ANALYSIS=1 m libc
-        "libc": ["libc"],
-    },
-)
+filegroup(name="empty", visibility=["//visibility:public"])
diff --git a/common.bazelrc b/common.bazelrc
index d0091c6..07e3053 100644
--- a/common.bazelrc
+++ b/common.bazelrc
@@ -24,6 +24,11 @@
 # Disable local cpp toolchain detection, as it is explicitly declared in AOSP.
 build --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
 
+# Disable sandboxing for CppCompile actions, as headers are not fully specified.
+# TODO(b/186116353): This is a temporary fix, as appropriately-sandboxed actions
+# are a long term goal.
+build --strategy=CppCompile=standalone
+
 # Enable building targets in //external:__subpackages__.
 common --experimental_sibling_repository_layout
 common --experimental_disable_external_package
diff --git a/rules/cc_constants.bzl b/rules/cc_constants.bzl
index 4de3959..7a51244 100644
--- a/rules/cc_constants.bzl
+++ b/rules/cc_constants.bzl
@@ -2,16 +2,27 @@
 # To use, load the constants struct:
 #
 #   load("//build/bazel/rules:cc_constants.bzl", "constants")
-
 # Supported hdr extensions in Soong. Keep this consistent with hdrExts in build/soong/cc/snapshot_utils.go
 _HDR_EXTS = ["h", "hh", "hpp", "hxx", "h++", "inl", "inc", "ipp", "h.generic"]
 _SRC_EXTS = ["c", "cc", "cpp", "S"]
 _ALL_EXTS = _SRC_EXTS + _HDR_EXTS
-
 _HDR_EXTS_WITH_DOT = ["." + ext for ext in _HDR_EXTS]
 _SRC_EXTS_WITH_DOT = ["." + ext for ext in _SRC_EXTS]
 _ALL_EXTS_WITH_DOT = ["." + ext for ext in _ALL_EXTS]
-
+# These are root-relative.
+_GLOBAL_INCLUDE_DIRS_COPTS_ONLY_USED_FOR_SOONG_COMPATIBILITY_DO_NOT_ADD_MORE = [
+    "/",
+    "system/core/include",
+    "system/logging/liblog/include",
+    "system/core/libcutils/include",
+    "system/media/audio/include",
+    "hardware/libhardware/include",
+    "hardware/libhardware_legacy/include",
+    "hardware/ril/include",
+    "frameworks/native/include",
+    "frameworks/native/opengl/include",
+    "frameworks/av/include",
+]
 constants = struct(
     hdr_exts = _HDR_EXTS,
     src_exts = _SRC_EXTS,
@@ -19,4 +30,5 @@
     hdr_dot_exts = _HDR_EXTS_WITH_DOT,
     src_dot_exts = _SRC_EXTS_WITH_DOT,
     all_dot_exts = _ALL_EXTS_WITH_DOT,
+    GLOBAL_INCLUDE_DIRS_COPTS_ONLY_USED_FOR_SOONG_COMPATIBILITY_DO_NOT_ADD_MORE = _GLOBAL_INCLUDE_DIRS_COPTS_ONLY_USED_FOR_SOONG_COMPATIBILITY_DO_NOT_ADD_MORE,
 )