Enable sdk and sdk members in os_arch granularity

This amends Idad7ef138cdbcbd209d390bf6c10ca8365d4619f. With the change,
when there is a member that returns IsHostOsDependent() == true,
the sdk having the member and the member itself are disable for host and
only the os that the member supports is explicitly enabled.

However, that change will cause a problem when we add the support for
the linux_bionic_arm64 target. The target is not enabled when building
sdk snapshots. The only linux_bionic target that is enabled is
'linux_bionic_x86_64'. However, since the granularity is os which is
linux_bionic, the snapshot is generated as follows.

cc_prebuilt_binary {
    target: {
        host: {
	    enabled: false,
	},
	linux_bionic: {
            enabled: true,
        },
	linux_bionic_x86_64: {
            srcs: ["x86_64/bin/..."],
	},
	// no srcs for linux_bionic_arm64
    },
}

Above is a problem for linux_bionic_arm64 target because the target is
enabled (via linux_bionic.enabled: true), but srcs is not provided.

To fix the problem, the enabling of a target is done in a target
(os_arch) granularity, rather than os granularity. For example, above
now becomes ...

cc_prebuilt_binary {
    target: {
        host: {
	    enabled: false,
	},
	linux_bionic_x86_64: {
            enabled: true,
            srcs: ["x86_64/bin/..."],
	},
    },
}

Only the targets that the snapshot actually can provide srcs are enabled
and the rest of the host targets are disabled.

Bug: 159685774
Test: m nothing
Test: build/soong/scripts/build-aml-prebuilts.sh
runtime-module-host-exports

Change-Id: Ibca48c40f6dc4628b5f4bfa4ceb68ebe0973cc81
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index c214e75..c1813ec 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -120,10 +120,8 @@
         android_arm64: {
             srcs: ["android/arm64/lib/sdkmember.so"],
         },
-        linux_glibc: {
-            enabled: true,
-        },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
         },
     },
@@ -143,10 +141,8 @@
         android_arm64: {
             srcs: ["android/arm64/lib/sdkmember.so"],
         },
-        linux_glibc: {
-            enabled: true,
-        },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
         },
     },
@@ -162,7 +158,7 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
+        linux_glibc_x86_64: {
             enabled: true,
         },
     },
@@ -670,20 +666,21 @@
             enabled: false,
         },
         linux_glibc: {
-            enabled: true,
             compile_multilib: "both",
         },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
         },
         linux_glibc_x86: {
+            enabled: true,
             srcs: ["linux_glibc/x86/bin/mynativebinary"],
         },
         windows: {
-            enabled: true,
             compile_multilib: "64",
         },
         windows_x86_64: {
+            enabled: true,
             srcs: ["windows/x86_64/bin/mynativebinary.exe"],
         },
     },
@@ -701,20 +698,21 @@
             enabled: false,
         },
         linux_glibc: {
-            enabled: true,
             compile_multilib: "both",
         },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
         },
         linux_glibc_x86: {
+            enabled: true,
             srcs: ["linux_glibc/x86/bin/mynativebinary"],
         },
         windows: {
-            enabled: true,
             compile_multilib: "64",
         },
         windows_x86_64: {
+            enabled: true,
             srcs: ["windows/x86_64/bin/mynativebinary.exe"],
         },
     },
@@ -727,15 +725,20 @@
     host_supported: true,
     native_binaries: ["myexports_mynativebinary@current"],
     target: {
+        windows: {
+            compile_multilib: "64",
+        },
         host: {
             enabled: false,
         },
-        linux_glibc: {
+        linux_glibc_x86_64: {
             enabled: true,
         },
-        windows: {
+        linux_glibc_x86: {
             enabled: true,
-            compile_multilib: "64",
+        },
+        windows_x86_64: {
+            enabled: true,
         },
     },
 }
@@ -811,10 +814,8 @@
         host: {
             enabled: false,
         },
-        linux_bionic: {
-            enabled: true,
-        },
         linux_bionic_x86_64: {
+            enabled: true,
             srcs: ["x86_64/bin/mynativebinary"],
         },
     },
@@ -832,10 +833,8 @@
         host: {
             enabled: false,
         },
-        linux_bionic: {
-            enabled: true,
-        },
         linux_bionic_x86_64: {
+            enabled: true,
             srcs: ["x86_64/bin/mynativebinary"],
         },
     },
@@ -854,10 +853,8 @@
         host: {
             enabled: false,
         },
-        linux_bionic: {
-            enabled: true,
-        },
         linux_bionic_x86_64: {
+            enabled: true,
             srcs: ["x86_64/lib/mynativelib.so"],
         },
     },
@@ -875,10 +872,8 @@
         host: {
             enabled: false,
         },
-        linux_bionic: {
-            enabled: true,
-        },
         linux_bionic_x86_64: {
+            enabled: true,
             srcs: ["x86_64/lib/mynativelib.so"],
         },
     },
@@ -896,7 +891,7 @@
         host: {
             enabled: false,
         },
-        linux_bionic: {
+        linux_bionic_x86_64: {
             enabled: true,
         },
     },
@@ -952,13 +947,12 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
-            enabled: true,
-        },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["x86_64/bin/linker"],
         },
         linux_glibc_x86: {
+            enabled: true,
             srcs: ["x86/bin/linker"],
         },
     },
@@ -978,13 +972,12 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
-            enabled: true,
-        },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["x86_64/bin/linker"],
         },
         linux_glibc_x86: {
+            enabled: true,
             srcs: ["x86/bin/linker"],
         },
     },
@@ -1000,7 +993,10 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
+        linux_glibc_x86_64: {
+            enabled: true,
+        },
+        linux_glibc_x86: {
             enabled: true,
         },
     },
@@ -1345,14 +1341,13 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
-            enabled: true,
-        },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["x86_64/lib/mynativelib.so"],
             export_include_dirs: ["x86_64/include_gen/mynativelib"],
         },
         linux_glibc_x86: {
+            enabled: true,
             srcs: ["x86/lib/mynativelib.so"],
             export_include_dirs: ["x86/include_gen/mynativelib"],
         },
@@ -1373,14 +1368,13 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
-            enabled: true,
-        },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["x86_64/lib/mynativelib.so"],
             export_include_dirs: ["x86_64/include_gen/mynativelib"],
         },
         linux_glibc_x86: {
+            enabled: true,
             srcs: ["x86/lib/mynativelib.so"],
             export_include_dirs: ["x86/include_gen/mynativelib"],
         },
@@ -1397,7 +1391,10 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
+        linux_glibc_x86_64: {
+            enabled: true,
+        },
+        linux_glibc_x86: {
             enabled: true,
         },
     },
@@ -1464,20 +1461,21 @@
             enabled: false,
         },
         linux_glibc: {
-            enabled: true,
             compile_multilib: "both",
         },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
         },
         linux_glibc_x86: {
+            enabled: true,
             srcs: ["linux_glibc/x86/lib/mynativelib.so"],
         },
         windows: {
-            enabled: true,
             compile_multilib: "64",
         },
         windows_x86_64: {
+            enabled: true,
             srcs: ["windows/x86_64/lib/mynativelib.dll"],
         },
     },
@@ -1495,20 +1493,21 @@
             enabled: false,
         },
         linux_glibc: {
-            enabled: true,
             compile_multilib: "both",
         },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
         },
         linux_glibc_x86: {
+            enabled: true,
             srcs: ["linux_glibc/x86/lib/mynativelib.so"],
         },
         windows: {
-            enabled: true,
             compile_multilib: "64",
         },
         windows_x86_64: {
+            enabled: true,
             srcs: ["windows/x86_64/lib/mynativelib.dll"],
         },
     },
@@ -1521,15 +1520,20 @@
     host_supported: true,
     native_shared_libs: ["mysdk_mynativelib@current"],
     target: {
+        windows: {
+            compile_multilib: "64",
+        },
         host: {
             enabled: false,
         },
-        linux_glibc: {
+        linux_glibc_x86_64: {
             enabled: true,
         },
-        windows: {
+        linux_glibc_x86: {
             enabled: true,
-            compile_multilib: "64",
+        },
+        windows_x86_64: {
+            enabled: true,
         },
     },
 }
@@ -1669,14 +1673,13 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
-            enabled: true,
-        },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["x86_64/lib/mynativelib.a"],
             export_include_dirs: ["x86_64/include_gen/mynativelib"],
         },
         linux_glibc_x86: {
+            enabled: true,
             srcs: ["x86/lib/mynativelib.a"],
             export_include_dirs: ["x86/include_gen/mynativelib"],
         },
@@ -1696,14 +1699,13 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
-            enabled: true,
-        },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["x86_64/lib/mynativelib.a"],
             export_include_dirs: ["x86_64/include_gen/mynativelib"],
         },
         linux_glibc_x86: {
+            enabled: true,
             srcs: ["x86/lib/mynativelib.a"],
             export_include_dirs: ["x86/include_gen/mynativelib"],
         },
@@ -1720,7 +1722,10 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
+        linux_glibc_x86_64: {
+            enabled: true,
+        },
+        linux_glibc_x86: {
             enabled: true,
         },
     },
@@ -1885,10 +1890,8 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
-            enabled: true,
-        },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["x86_64/lib/mynativelib.a"],
             export_include_dirs: ["x86_64/include_gen/mynativelib"],
         },
@@ -1908,10 +1911,8 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
-            enabled: true,
-        },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["x86_64/lib/mynativelib.a"],
             export_include_dirs: ["x86_64/include_gen/mynativelib"],
         },
@@ -1929,7 +1930,7 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
+        linux_glibc_x86_64: {
             enabled: true,
         },
     },
@@ -2027,7 +2028,10 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
+        linux_glibc_x86_64: {
+            enabled: true,
+        },
+        linux_glibc_x86: {
             enabled: true,
         },
     },
@@ -2046,7 +2050,10 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
+        linux_glibc_x86_64: {
+            enabled: true,
+        },
+        linux_glibc_x86: {
             enabled: true,
         },
     },
@@ -2062,7 +2069,10 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
+        linux_glibc_x86_64: {
+            enabled: true,
+        },
+        linux_glibc_x86: {
             enabled: true,
         },
     },
@@ -2118,9 +2128,14 @@
             export_include_dirs: ["android/include/include-android"],
         },
         linux_glibc: {
-            enabled: true,
             export_include_dirs: ["linux_glibc/include/include-host"],
         },
+        linux_glibc_x86_64: {
+            enabled: true,
+        },
+        linux_glibc_x86: {
+            enabled: true,
+        },
     },
 }
 
@@ -2140,9 +2155,14 @@
             export_include_dirs: ["android/include/include-android"],
         },
         linux_glibc: {
-            enabled: true,
             export_include_dirs: ["linux_glibc/include/include-host"],
         },
+        linux_glibc_x86_64: {
+            enabled: true,
+        },
+        linux_glibc_x86: {
+            enabled: true,
+        },
     },
 }
 
@@ -2155,7 +2175,10 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
+        linux_glibc_x86_64: {
+            enabled: true,
+        },
+        linux_glibc_x86: {
             enabled: true,
         },
     },
@@ -2346,13 +2369,12 @@
         android_arm: {
             srcs: ["android/arm/lib/sslvariants.so"],
         },
-        linux_glibc: {
-            enabled: true,
-        },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
         },
         linux_glibc_x86: {
+            enabled: true,
             srcs: ["linux_glibc/x86/lib/sslvariants.so"],
         },
     },
@@ -2377,13 +2399,12 @@
         android_arm: {
             srcs: ["android/arm/lib/sslvariants.so"],
         },
-        linux_glibc: {
-            enabled: true,
-        },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
         },
         linux_glibc_x86: {
+            enabled: true,
             srcs: ["linux_glibc/x86/lib/sslvariants.so"],
         },
     },
@@ -2398,7 +2419,10 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
+        linux_glibc_x86_64: {
+            enabled: true,
+        },
+        linux_glibc_x86: {
             enabled: true,
         },
     },
@@ -2536,13 +2560,12 @@
         android_arm: {
             srcs: ["android/arm/lib/stubslib.so"],
         },
-        linux_glibc: {
-            enabled: true,
-        },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
         },
         linux_glibc_x86: {
+            enabled: true,
             srcs: ["linux_glibc/x86/lib/stubslib.so"],
         },
     },
@@ -2571,13 +2594,12 @@
         android_arm: {
             srcs: ["android/arm/lib/stubslib.so"],
         },
-        linux_glibc: {
-            enabled: true,
-        },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
         },
         linux_glibc_x86: {
+            enabled: true,
             srcs: ["linux_glibc/x86/lib/stubslib.so"],
         },
     },
@@ -2592,7 +2614,10 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
+        linux_glibc_x86_64: {
+            enabled: true,
+        },
+        linux_glibc_x86: {
             enabled: true,
         },
     },
@@ -2637,13 +2662,12 @@
         android_arm: {
             srcs: ["android/arm/lib/mylib.so"],
         },
-        linux_glibc: {
-            enabled: true,
-        },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
         },
         linux_glibc_x86: {
+            enabled: true,
             srcs: ["linux_glibc/x86/lib/mylib-host.so"],
         },
     },
@@ -2666,13 +2690,12 @@
         android_arm: {
             srcs: ["android/arm/lib/mylib.so"],
         },
-        linux_glibc: {
-            enabled: true,
-        },
         linux_glibc_x86_64: {
+            enabled: true,
             srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
         },
         linux_glibc_x86: {
+            enabled: true,
             srcs: ["linux_glibc/x86/lib/mylib-host.so"],
         },
     },
@@ -2687,7 +2710,10 @@
         host: {
             enabled: false,
         },
-        linux_glibc: {
+        linux_glibc_x86_64: {
+            enabled: true,
+        },
+        linux_glibc_x86: {
             enabled: true,
         },
     },