diff options
author | Sundong Ahn <sundongahn@google.com> | 2018-06-21 13:47:17 +0900 |
---|---|---|
committer | Sundong Ahn <sundongahn@google.com> | 2018-06-25 10:30:30 +0900 |
commit | 27eecb99d22b7d8aa1e345f0bbcd37f839c8a92f (patch) | |
tree | c863352baaccc1d1ee66ad6ffc9285f5c78ee68c /java/prebuilt_apis.go | |
parent | 297d9bcedaa14670a84c3dc4d4bf90b9ea033bea (diff) | |
download | android_build_soong-27eecb99d22b7d8aa1e345f0bbcd37f839c8a92f.tar.gz android_build_soong-27eecb99d22b7d8aa1e345f0bbcd37f839c8a92f.tar.bz2 android_build_soong-27eecb99d22b7d8aa1e345f0bbcd37f839c8a92f.zip |
Add api_dirs property and use module name as prefix
The soong connect the prebuilt library according to LOCAL_SDK_VERSION.
But some sdk libraries has diffrent version policy with
LOCAL_SDK_VERSION. For this, we need to support direct link to the
prebuilt library instead of creating a new LOCAL_XXX_SDK_VERSION. So,
The base module name is used as the prefix for the prebuilt module name.
Remove the empty file check to support the absence of a prebuilt
library and add api_dirs property
Bug:77577799
Test: make -j
Change-Id: I1086977d26e4ddfd62e290637126d44e1b248bac
Diffstat (limited to 'java/prebuilt_apis.go')
-rw-r--r-- | java/prebuilt_apis.go | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/java/prebuilt_apis.go b/java/prebuilt_apis.go index 3f4b076b..59b2092d 100644 --- a/java/prebuilt_apis.go +++ b/java/prebuilt_apis.go @@ -38,8 +38,14 @@ func init() { }) } +type prebuiltApisProperties struct { + // list of api version directories + Api_dirs []string +} + type prebuiltApis struct { android.ModuleBase + properties prebuiltApisProperties } func (module *prebuiltApis) DepsMutator(ctx android.BottomUpMutatorContext) { @@ -55,10 +61,6 @@ func parseJarPath(ctx android.BaseModuleContext, path string) (module string, ap apiver = elements[0] scope = elements[1] - if scope != "public" && scope != "system" && scope != "test" && scope != "core" { - // scope must be public, system or test - return - } module = strings.TrimSuffix(elements[2], ".jar") return @@ -91,7 +93,7 @@ func createImport(mctx android.TopDownMutatorContext, module string, scope strin Sdk_version *string Installable *bool }{} - props.Name = proptools.StringPtr("sdk_" + scope + "_" + apiver + "_" + module) + props.Name = proptools.StringPtr(mctx.ModuleName() + "_" + scope + "_" + apiver + "_" + module) props.Jars = append(props.Jars, path) // TODO(hansson): change to scope after migration is done. props.Sdk_version = proptools.StringPtr("current") @@ -114,22 +116,22 @@ func createFilegroup(mctx android.TopDownMutatorContext, module string, scope st func prebuiltSdkStubs(mctx android.TopDownMutatorContext) { mydir := mctx.ModuleDir() + "/" // <apiver>/<scope>/<module>.jar - files, err := mctx.GlobWithDeps(mydir+"*/*/*.jar", nil) - if err != nil { - mctx.ModuleErrorf("failed to glob jar files under %q: %s", mydir, err) - } - if len(files) == 0 { - mctx.ModuleErrorf("no jar file found under %q", mydir) + var files []string + for _, apiver := range mctx.Module().(*prebuiltApis).properties.Api_dirs { + for _, scope := range []string{"public", "system", "test", "core"} { + vfiles, err := mctx.GlobWithDeps(mydir+apiver+"/"+scope+"*/*.jar", nil) + if err != nil { + mctx.ModuleErrorf("failed to glob jar files under %q: %s", mydir+apiver+"/"+scope, err) + } + files = append(files, vfiles...) + } } for _, f := range files { // create a Import module for each jar file localPath := strings.TrimPrefix(f, mydir) module, apiver, scope := parseJarPath(mctx, localPath) - - if len(module) != 0 { - createImport(mctx, module, scope, apiver, localPath) - } + createImport(mctx, module, scope, apiver, localPath) } } @@ -192,6 +194,7 @@ func prebuiltApisMutator(mctx android.TopDownMutatorContext) { func prebuiltApisFactory() android.Module { module := &prebuiltApis{} + module.AddProperties(&module.properties) android.InitAndroidModule(module) return module } |