target.apex.exclude_[shared|static]_libs to cc_* modules

The property is used to exclude some shared and static libs when the
module is built for an APEX.

Bug: 166468760
Test: m
Change-Id: I0dcaa4ae94c01aa00dc5539c60d3054c57fd8824
diff --git a/apex/apex.go b/apex/apex.go
index 7ab7454..986246f 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1681,6 +1681,19 @@
 							// Don't track further
 							return false
 						}
+
+						// If the dep is not considered to be in the same
+						// apex, don't add it to filesInfo so that it is not
+						// included in this APEX.
+						// TODO(jiyong): move this to at the top of the
+						// else-if clause for the indirect dependencies.
+						// Currently, that's impossible because we would
+						// like to record requiredNativeLibs even when
+						// DepIsInSameAPex is false.
+						if !am.DepIsInSameApex(ctx, am) {
+							return false
+						}
+
 						filesInfo = append(filesInfo, af)
 						return true // track transitive dependencies
 					}