diff options
author | Sasha Smundak <asmundak@google.com> | 2019-04-01 18:37:36 -0700 |
---|---|---|
committer | Sasha Smundak <asmundak@google.com> | 2019-04-04 11:24:01 -0700 |
commit | b6d230515e3104a2630388d11810d98d440a7943 (patch) | |
tree | 376eb47fa808e65ba9f6b2ab97c700861be144be /phony | |
parent | f3f1467051d8839629ccf0b9aeda3f8a5997c834 (diff) | |
download | build_soong-b6d230515e3104a2630388d11810d98d440a7943.tar.gz build_soong-b6d230515e3104a2630388d11810d98d440a7943.tar.bz2 build_soong-b6d230515e3104a2630388d11810d98d440a7943.zip |
Implement `host_required` and `target_required` properties.
They are counterparts of LOCAL_HOST_REQUIRED_MODULES and
LOCAL_TARGET_REQUIRED_MODULES respectively.
Fixes: 128693436
Test: treehugger, convert cts/hostsidetests/devicepolicy/Android.bp
Change-Id: Id66ffca6edffe18993ac51e8930f1d0e78178249
Diffstat (limited to 'phony')
-rw-r--r-- | phony/phony.go | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/phony/phony.go b/phony/phony.go index ed6a2fef..305a434f 100644 --- a/phony/phony.go +++ b/phony/phony.go @@ -28,7 +28,9 @@ func init() { type phony struct { android.ModuleBase - requiredModuleNames []string + requiredModuleNames []string + hostRequiredModuleNames []string + targetRequiredModuleNames []string } func PhonyFactory() android.Module { @@ -40,8 +42,12 @@ func PhonyFactory() android.Module { func (p *phony) GenerateAndroidBuildActions(ctx android.ModuleContext) { p.requiredModuleNames = ctx.RequiredModuleNames() - if len(p.requiredModuleNames) == 0 { - ctx.PropertyErrorf("required", "phony must not have empty required dependencies in order to be useful(and therefore permitted).") + p.hostRequiredModuleNames = ctx.HostRequiredModuleNames() + p.targetRequiredModuleNames = ctx.TargetRequiredModuleNames() + if len(p.requiredModuleNames) == 0 && + len(p.hostRequiredModuleNames) == 0 && len(p.targetRequiredModuleNames) == 0 { + ctx.PropertyErrorf("required", "phony must not have empty required dependencies "+ + "in order to be useful(and therefore permitted).") } } @@ -54,7 +60,18 @@ func (p *phony) AndroidMk() android.AndroidMkData { if p.Host() { fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true") } - fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES := "+strings.Join(p.requiredModuleNames, " ")) + if len(p.requiredModuleNames) > 0 { + fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", + strings.Join(p.requiredModuleNames, " ")) + } + if len(p.hostRequiredModuleNames) > 0 { + fmt.Fprintln(w, "LOCAL_HOST_REQUIRED_MODULES :=", + strings.Join(p.hostRequiredModuleNames, " ")) + } + if len(p.targetRequiredModuleNames) > 0 { + fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES :=", + strings.Join(p.targetRequiredModuleNames, " ")) + } fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)") }, } |