Convert to Android.bp

See build/soong/README.md for more information.

gen.mk is currently using build system internals in order to tell the
gen_*.sh scripts how to call the compiler. Soong genrules do not provide
the required information to call a compiler, so use a `cc_object {}` to
do the preprocessing steps, and pass the output from that into the
gen_*.sh scripts (cc_genrule).

It fixes the missing dependencies for the 2nd arch, and uses the correct
libc headers for the _vendor variant.

Bug: 66914194
Test: mmma external/minijail
Test: cd external/minijail; make all tests
Test: out/host/linux-x86/nativetest/system_unittest_gtest/system_unittest_gtest
Test: out/host/linux-x86/nativetest64/system_unittest_gtest/system_unittest_gtest
Test: cd external/minijail; ../../out/host/linux-x86/nativetest/syscall_filter_unittest_gtest/syscall_filter_unittest_gtest
Test: cd external/minijail; ../../out/host/linux-x86/nativetest64/syscall_filter_unittest_gtest/syscall_filter_unittest_gtest
Change-Id: Id116afb24677ea386f1b043c71c59d3b7ffd8696
diff --git a/gen_syscalls.sh b/gen_syscalls.sh
index f31031b..69f8a46 100755
--- a/gen_syscalls.sh
+++ b/gen_syscalls.sh
@@ -14,23 +14,25 @@
 
 if [ $# -ne 1 ] && [ $# -ne 2 ]; then
   echo "Usage: $(basename "$0") OUTFILE"
-  echo "Usage: $(basename "$0") CC OUTFILE"
+  echo "Usage: $(basename "$0") INFILE OUTFILE"
   exit 1
 fi
 
+BUILD="${CC} -dD gen_syscalls.c -E"
+GEN_DEPS=1
+
 if [ $# -eq 2 ]; then
-  CC="$1"
+  BUILD="cat $1"
+  GEN_DEPS=0
   shift
 fi
 OUTFILE="$1"
 
-# Generate a dependency file which helps the build tool to see when it
-# should regenerate ${OUTFILE}.
-echo '#include <asm/unistd.h>' | ${CC} - -E -M -MF "${OUTFILE}.d.tmp"
-# Correct the output filename.
-(echo "${OUTFILE}: \\" ; sed -e 's/^-\.o://' -e 's/^-://' "${OUTFILE}.d.tmp") \
-  > "${OUTFILE}.d"
-rm "${OUTFILE}.d.tmp"
+if [ ${GEN_DEPS} -eq 1 ]; then
+  # Generate a dependency file which helps the build tool to see when it
+  # should regenerate ${OUTFILE}.
+  ${BUILD} -M -MF "${OUTFILE}.d"
+fi
 
 # sed expression which extracts system calls that are
 # defined via asm/unistd.h.  It converts them from:
@@ -49,8 +51,7 @@
 #include <asm/unistd.h>
 #include "libsyscalls.h"
 const struct syscall_entry syscall_table[] = {
-$(echo '#include <asm/unistd.h>' | \
-  ${CC} -dD - -E | sed -Ene "${SED_MULTILINE}")
+$(${BUILD} | sed -Ene "${SED_MULTILINE}")
   { NULL, -1 },
 };
 EOF