blob: 9b53c9f7bb3b9b1f56d2344516cf6b683e144749 [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
32}
33
34type fileGroup struct {
35 android.ModuleBase
36 properties fileGroupProperties
37 srcs android.Paths
38}
39
40var _ android.SourceFileProducer = (*fileGroup)(nil)
41
42// filegroup modules contain a list of files, and can be used to export files across package
43// boundaries. filegroups (and genrules) can be referenced from srcs properties of other modules
44// using the syntax ":module".
45func fileGroupFactory() (blueprint.Module, []interface{}) {
46 module := &fileGroup{}
47
48 return android.InitAndroidModule(module, &module.properties)
49}
50
51func (fg *fileGroup) DepsMutator(ctx android.BottomUpMutatorContext) {
52 android.ExtractSourcesDeps(ctx, fg.properties.Srcs)
53}
54
55func (fg *fileGroup) GenerateAndroidBuildActions(ctx android.ModuleContext) {
56 fg.srcs = ctx.ExpandSources(fg.properties.Srcs, fg.properties.Exclude_srcs)
57}
58
59func (fg *fileGroup) Srcs() android.Paths {
60 return fg.srcs
61}