Give cc_library a version_script attribute.

This corresponds to the version_script property of Soong's cc_library.

Bug: 186650430
Test: Presubmits.
Change-Id: Id582f8d54ca31f9d0553c5f86aeff9c5e77e36a2
diff --git a/rules/full_cc_library.bzl b/rules/full_cc_library.bzl
index 04b812d..4e4965a 100644
--- a/rules/full_cc_library.bzl
+++ b/rules/full_cc_library.bzl
@@ -13,6 +13,7 @@
         # attributes for the shared target
         static_deps_for_shared = [],
         user_link_flags = [],
+        version_script = None,
         **kwargs):
     static_name = name + "_bp2build_cc_library_static"
     shared_name = name + "_bp2build_cc_library_shared"
@@ -32,6 +33,11 @@
         deps = deps,
     )
 
+    additional_linker_inputs = []
+    if version_script != None:
+        user_link_flags = user_link_flags + ["-Wl,--version-script,$(location " + version_script + ")"]
+        additional_linker_inputs += [version_script]
+
     cc_shared_library(
         name = shared_name,
         user_link_flags = user_link_flags,
@@ -40,6 +46,7 @@
         # if a shared library could declare a transitive exported static dep
         # instead of needing to declare each target transitively.
         static_deps = ["//:__subpackages__"] + static_deps_for_shared,
+        additional_linker_inputs = additional_linker_inputs,
         roots = [static_name + "_mainlib"],
     )