Simplify the external Bazel build.

Now that all assembly files are conditionalized, we no longer need to
detect platforms at the build level. This is convenient because
detecting platforms in Bazel is a bit of a mess.

In particular, this reduces how much we depend on @platforms being
correct. gRPC's build appears to still be using some legacy modes which
seem cause it to, on cross-compiles, report the host's platforms rather
than the target. See https://github.com/grpc/grpc/pull/31938

gRPC should eventually fix this, but it is apparently challenging due
to complexities in migrating from Bazel's legacy system the new
"platforms" mechanism. Instead, try to sidestep this problem by not
relying on the build to do this.

Now, we primarily rely on os:windows being accurate, and cross-compiling
to/from Windows is uncommon. We do also need os:linux to be accurate
when Linux is the target OS, but if Linux is the host and gRPC mislabels
the target as os:linux, this is fine as long as the target is not
FreeBSD, Apple, or another platform that cares about _XOPEN_SOURCE. (In
particular, Android is ambivalent.)

I've also renamed a few things based on what they were actually
selecting. posix_copts was really copts for toolchains with GCC-style
flags. Unfortunately, it's not clear how to condition on the compiler,
rather than the platform in Bazel, so we'll do the wrong thing on
non-MSVC Windows toolchains, but that was true before.

Bug: 542
Change-Id: I7330d8961145ae5714d4cad01259044230d96bcd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56465
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/util/generate_build_files.py b/util/generate_build_files.py
index 383de02..0cabe9c 100644
--- a/util/generate_build_files.py
+++ b/util/generate_build_files.py
@@ -255,6 +255,23 @@
         self.PrintVariableSection(
             out, 'crypto_sources_%s_%s' % (osname, arch), asm_files)
 
+      # Generate combined source lists for gas and nasm. Consumers have a choice
+      # of using the per-platform ones or the combined ones. In the combined
+      # mode, Windows x86 and Windows x86_64 must still be special-cased, but
+      # otherwise all assembly files can be linked together.
+      out.write('\n')
+      out.write('crypto_sources_asm = []\n')
+      for (osname, arch, _, _, asm_ext) in OS_ARCH_COMBOS:
+        if asm_ext == 'S':
+          out.write('crypto_sources_asm.extend(crypto_sources_%s_%s)\n' %
+                    (osname, arch))
+      out.write('\n')
+      out.write('crypto_sources_nasm = []\n')
+      for (osname, arch, _, _, asm_ext) in OS_ARCH_COMBOS:
+        if asm_ext == 'asm':
+          out.write('crypto_sources_nasm.extend(crypto_sources_%s_%s)\n' %
+                    (osname, arch))
+
     with open('BUILD.generated_tests.bzl', 'w+') as out:
       out.write(self.header)