From 62707f79abd966e1ffee317ae274d64f71752b7a Mon Sep 17 00:00:00 2001 From: Jaewoong Jung Date: Fri, 16 Nov 2018 13:26:43 -0800 Subject: [PATCH] Add filegroup support to notice property. Also, replace all notice file references with the parent directory pattern(../) with filegroups. This new version has ALLOW_MISSING_DEPENDENCIES support, so shouldn't break branches that don't contain the libwinpthread project. Bug: 118899640 Test: Manual build + forrest runs on previously failed branches. Change-Id: I13e70e8dab547f82c1c8f15eccc7ae116e480ad5 --- Android.bp | 2 +- android/androidmk.go | 4 ++-- android/module.go | 13 +++++++++++++ android/mutator.go | 5 +++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Android.bp b/Android.bp index be9cf2a05..9711c1165 100644 --- a/Android.bp +++ b/Android.bp @@ -436,7 +436,7 @@ toolchain_library { src: "prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/lib/libwinpthread.a", }, }, - notice: "../../prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/licenses/mingw-w64-svn-r5861/mingw-w64-libraries/winpthreads/COPYING", + notice: ":mingw-libwinpthread-notice", } toolchain_library { diff --git a/android/androidmk.go b/android/androidmk.go index 62243618d..18b26d907 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -317,8 +317,8 @@ func translateAndroidModule(ctx SingletonContext, w io.Writer, mod blueprint.Mod } } - if amod.commonProperties.Notice != nil { - fmt.Fprintln(&data.preamble, "LOCAL_NOTICE_FILE :=", "$(LOCAL_PATH)/"+*amod.commonProperties.Notice) + if amod.noticeFile != nil { + fmt.Fprintln(&data.preamble, "LOCAL_NOTICE_FILE :=", amod.noticeFile.String()) } if host { diff --git a/android/module.go b/android/module.go index bbe7d3646..dc0c85603 100644 --- a/android/module.go +++ b/android/module.go @@ -459,6 +459,7 @@ type ModuleBase struct { noAddressSanitizer bool installFiles Paths checkbuildFiles Paths + noticeFile Path // Used by buildTargetSingleton to create checkbuild and per-directory build targets // Only set on the final variant of each module @@ -826,6 +827,11 @@ func (a *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) a.installFiles = append(a.installFiles, ctx.installFiles...) a.checkbuildFiles = append(a.checkbuildFiles, ctx.checkbuildFiles...) + + if a.commonProperties.Notice != nil { + // For filegroup-based notice file references. + a.noticeFile = ctx.ExpandSource(*a.commonProperties.Notice, "notice") + } } if a == ctx.FinalModule().(Module).base() { @@ -1347,6 +1353,13 @@ func (ctx *androidModuleContext) ExpandSource(srcFile, prop string) Path { srcFiles := ctx.ExpandSourcesSubDir([]string{srcFile}, nil, "") if len(srcFiles) == 1 { return srcFiles[0] + } else if len(srcFiles) == 0 { + if ctx.Config().AllowMissingDependencies() { + ctx.AddMissingDependencies([]string{srcFile}) + } else { + ctx.PropertyErrorf(prop, "%s path %s does not exist", prop, srcFile) + } + return nil } else { ctx.PropertyErrorf(prop, "module providing %s must produce exactly one file", prop) return nil diff --git a/android/mutator.go b/android/mutator.go index b9c44e83a..b77c2f091 100644 --- a/android/mutator.go +++ b/android/mutator.go @@ -207,6 +207,11 @@ func (mutator *mutator) Parallel() MutatorHandle { func depsMutator(ctx BottomUpMutatorContext) { if m, ok := ctx.Module().(Module); ok && m.Enabled() { m.DepsMutator(ctx) + + // For filegroup-based notice file references. + if m.base().commonProperties.Notice != nil { + ExtractSourceDeps(ctx, m.base().commonProperties.Notice) + } } }