Use the package feature to build cairo as a shared library

Build the cairo 2d drawing package as a shared library
for use by Rust until Rust Skia bindings are available.

Change-Id: I1de92c2fe7594ac7ea65564f1d28a209c71b583b
diff --git a/BUILD.gn b/BUILD.gn
index 8126f94..ebbffef 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -26,6 +26,8 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+import("//packages/package.gni")
+
 config("cairo_config") {
   include_dirs = [ "$target_gen_dir" ]
   defines = [ "CAIRO_HAS_FC_FONT=0" ]
@@ -35,7 +37,7 @@
   public_configs = [ ":cairo_config" ]
   public_deps = [
     ":cairo_install_headers",
-    ":cairo_lib",
+    ":cairo_lib(//build/toolchain/fuchsia:${target_cpu}-shared)",
   ]
 }
 
@@ -113,9 +115,11 @@
   ]
 }
 
-source_set("cairo_lib") {
+shared_library("cairo_lib") {
   visibility = [ ":*" ]
 
+  output_name = "libcairo"
+
   sources = [
     "src/cairo-analysis-surface.c",
     "src/cairo-arc.c",
@@ -238,6 +242,11 @@
 
   configs += [ ":cairo_private_config" ]
 
+  # The Cairo library authors are careful to hide private symbols explicitly,
+  # so default symbol visiblity is correct and neccesary for this library
+  # to work correct.
+  configs -= [ "//build/config:symbol_visibility_hidden" ]
+
   defines = [
     "HAVE_CONFIG_H",
     "_REENTRANT",
@@ -249,3 +258,15 @@
     "//third_party/pixman",
   ]
 }
+
+package("package") {
+  package_name = "cairo"
+
+  deps = [
+    ":cairo_lib"
+  ]
+
+  libraries = [ {
+        name = "libcairo.so"
+      } ]
+}