[sw] Require absolute import paths in software.

This change modifies meson_init.sh so that meson does not emit -I
arguments which are rooted at REPO_TOP. Concretely, any C/C++ file
that wants to use sw/lib/my_cool_difs.h must write

- `#include "sw/lib/my_cool_difs.h"`

This will improve include hygine significantly as the project grows
on the software side.

Meson really, really wants to believe in a Make-like project where
we don't care about this, and where you can include foo.h as foo.h
if your TU is in the same directory. However, Ninja doesn't care,
so we do minor postprocessing to remove precarious -I arguments.

Due to how Meson treats generated headers, though, there really
isn't a good way to make enforce this on generated files. For now,
generated register files are included in the old way, but for
tracking purposes we adopt the following convention:

- `#include "my_cool_peripheral_regs.h"  // Generated.`

"Generated" includes are placed in a separate stanza before normal
includes, but after system library imports.

The existing Makefile flow should have been preserved; I just
restricted the -I arguments to REPO_TOP.
diff --git a/meson_init.sh b/meson_init.sh
index 6f06bc9..34b25b7 100755
--- a/meson_init.sh
+++ b/meson_init.sh
@@ -19,16 +19,19 @@
 
   -f: Remove build directories before running Meson.
   -r: Force reconfiguration of build directories.
+  -K: Keep include search paths as generated by Meson.
 
 USAGE
 }
 
 FLAGS_force=false
 FLAGS_reconfigure=""
-while getopts 'r?:f?' flag; do
+FLAGS_keep_includes=false
+while getopts 'r?:f?:K?' flag; do
   case "${flag}" in
     f) FLAGS_force=true;;
     r) FLAGS_reconfigure="--reconfigure";;
+    K) FLAGS_keep_includes=true;;
     ?) usage && exit 1;;
     *) usage
        error "Unexpected option ${flag}"
@@ -69,8 +72,29 @@
   done
 fi
 
+# purge_includes $target deletes any -I command line arguments that are not
+# - Absolute paths.
+# - Ephemeral build directories.
+#
+# This function is necessary because Meson does not give adequate
+# control over what directories are passed in as -I search directories
+# to the C compiler. While Meson does provide |implicit_include_directories|,
+# support for this option is poor: empirically, Meson ignores this option for
+# some targerts. Doing it as a post-processing step ensures that Meson does
+# not allow improper #includes to compile successfully.
+function purge_includes() {
+  if [[ "${FLAGS_keep_includes}" == "true" ]]; then
+    return
+  fi
+  echo "Purging superfluous -I arguments from $1."
+  local ninja_file="${BUILD_DIR_PREFIX}-$1/build.ninja"
+  perl -pi -e 's#-I[^/][^@ ]+ # #g' -- "$ninja_file"
+}
+
 meson ${FLAGS_reconfigure} "-Dtarget=${TARGET_VERILATOR}" --cross-file=toolchain.txt \
     --buildtype=plain "${BUILD_DIR_PREFIX}-${TARGET_VERILATOR}"
+purge_includes ${TARGET_VERILATOR}
 
 meson ${FLAGS_reconfigure} "-Dtarget=${TARGET_FPGA}" --cross-file=toolchain.txt \
     --buildtype=plain "${BUILD_DIR_PREFIX}-${TARGET_FPGA}"
+purge_includes ${TARGET_FPGA}