Rename java_prebuilt_library to java_import

And make it work like bazel's java_import, using a "jars" property
instead of "srcs", and allowing multiple jars to be listed.

Test: soong tests
Change-Id: Ida2ace6412bd77b4feb423646000a1401004e0ea
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index 976c711..089ce28 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -31,12 +31,19 @@
 
 type prebuiltLinker struct {
 	android.Prebuilt
+	properties struct {
+		Srcs []string `android:"arch_variant"`
+	}
 }
 
 func (p *prebuiltLinker) prebuilt() *android.Prebuilt {
 	return &p.Prebuilt
 }
 
+func (p *prebuiltLinker) PrebuiltSrcs() []string {
+	return p.properties.Srcs
+}
+
 type prebuiltLibraryLinker struct {
 	*libraryDecorator
 	prebuiltLinker
@@ -44,20 +51,15 @@
 
 var _ prebuiltLinkerInterface = (*prebuiltLibraryLinker)(nil)
 
-func (p *prebuiltLibraryLinker) linkerProps() []interface{} {
-	props := p.libraryDecorator.linkerProps()
-	return append(props, &p.Prebuilt.Properties)
-}
-
 func (p *prebuiltLibraryLinker) link(ctx ModuleContext,
 	flags Flags, deps PathDeps, objs Objects) android.Path {
 	// TODO(ccross): verify shared library dependencies
-	if len(p.Prebuilt.Properties.Srcs) > 0 {
+	if len(p.properties.Srcs) > 0 {
 		p.libraryDecorator.exportIncludes(ctx, "-I")
 		p.libraryDecorator.reexportFlags(deps.ReexportedFlags)
 		p.libraryDecorator.reexportDeps(deps.ReexportedFlagsDeps)
 		// TODO(ccross): .toc optimization, stripping, packing
-		return p.Prebuilt.Path(ctx)
+		return p.Prebuilt.SingleSourcePath(ctx)
 	}
 
 	return nil
@@ -78,6 +80,9 @@
 	}
 	module.linker = prebuilt
 
+	module.AddProperties(&prebuilt.properties)
+
+	android.InitPrebuiltModule(module, &prebuilt.properties.Srcs)
 	return module, library
 }
 
@@ -96,6 +101,9 @@
 	}
 	module.linker = prebuilt
 
+	module.AddProperties(&prebuilt.properties)
+
+	android.InitPrebuiltModule(module, &prebuilt.properties.Srcs)
 	return module, library
 }
 
@@ -106,15 +114,10 @@
 
 var _ prebuiltLinkerInterface = (*prebuiltBinaryLinker)(nil)
 
-func (p *prebuiltBinaryLinker) linkerProps() []interface{} {
-	props := p.binaryDecorator.linkerProps()
-	return append(props, &p.Prebuilt.Properties)
-}
-
 func (p *prebuiltBinaryLinker) link(ctx ModuleContext,
 	flags Flags, deps PathDeps, objs Objects) android.Path {
 	// TODO(ccross): verify shared library dependencies
-	if len(p.Prebuilt.Properties.Srcs) > 0 {
+	if len(p.properties.Srcs) > 0 {
 		// TODO(ccross): .toc optimization, stripping, packing
 
 		// Copy binaries to a name matching the final installed name
@@ -125,7 +128,7 @@
 			Rule:        android.Cp,
 			Description: "prebuilt",
 			Output:      outputFile,
-			Input:       p.Prebuilt.Path(ctx),
+			Input:       p.Prebuilt.SingleSourcePath(ctx),
 		})
 
 		return outputFile
@@ -148,5 +151,8 @@
 	}
 	module.linker = prebuilt
 
+	module.AddProperties(&prebuilt.properties)
+
+	android.InitPrebuiltModule(module, &prebuilt.properties.Srcs)
 	return module, binary
 }