blob: c1d08a8234e19ae13a3977570d52c915912c61ef [file] [log] [blame]
Colin Cross068e0fe2016-12-13 15:23:47 -08001// 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
Colin Crossfaeb7aa2017-02-01 14:12:44 -080032
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
Colin Cross068e0fe2016-12-13 15:23:47 -080038}
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) {
Colin Crossfaeb7aa2017-02-01 14:12:44 -080062 fg.srcs = ctx.ExpandSourcesSubDir(fg.properties.Srcs, fg.properties.Exclude_srcs, fg.properties.Path)
Colin Cross068e0fe2016-12-13 15:23:47 -080063}
64
65func (fg *fileGroup) Srcs() android.Paths {
66 return fg.srcs
67}