1// Copyright 2016 Google Inc. All rights reserved. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package genrule 16 17import ( 18 "github.com/google/blueprint" 19 20 "android/soong/android" 21) 22 23func init() { 24 android.RegisterModuleType("filegroup", FileGroupFactory) 25} 26 27type fileGroupProperties struct { 28 // srcs lists files that will be included in this filegroup 29 Srcs []string 30 31 Exclude_srcs []string 32 33 // The base path to the files. May be used by other modules to determine which portion 34 // of the path to use. For example, when a filegroup is used as data in a cc_test rule, 35 // the base path is stripped off the path and the remaining path is used as the 36 // installation directory. 37 Path string 38} 39 40type fileGroup struct { 41 android.ModuleBase 42 properties fileGroupProperties 43 srcs android.Paths 44} 45 46var _ android.SourceFileProducer = (*fileGroup)(nil) 47 48// filegroup modules contain a list of files, and can be used to export files across package 49// boundaries. filegroups (and genrules) can be referenced from srcs properties of other modules 50// using the syntax ":module". 51func FileGroupFactory() (blueprint.Module, []interface{}) { 52 module := &fileGroup{} 53 54 return android.InitAndroidModule(module, &module.properties) 55} 56 57func (fg *fileGroup) DepsMutator(ctx android.BottomUpMutatorContext) { 58 android.ExtractSourcesDeps(ctx, fg.properties.Srcs) 59} 60 61func (fg *fileGroup) GenerateAndroidBuildActions(ctx android.ModuleContext) { 62 fg.srcs = ctx.ExpandSourcesSubDir(fg.properties.Srcs, fg.properties.Exclude_srcs, fg.properties.Path) 63} 64 65func (fg *fileGroup) Srcs() android.Paths { 66 return fg.srcs 67} 68