blob: 7aa909eef70d2b3f38a1e61b0086efa817e75107 [file] [log] [blame]
Colin Cross2fe66872015-03-30 17:20:39 -07001// Copyright 2015 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 java
16
17import (
18 "path/filepath"
19
20 "android/soong/common"
21)
22
23var resourceExcludes = []string{
Colin Cross3d7678f2015-04-24 15:16:39 -070024 "**/*.java",
25 "**/package.html",
26 "**/overview.html",
27 "**/.*.swp",
28 "**/.DS_Store",
29 "**/*~",
Colin Cross2fe66872015-03-30 17:20:39 -070030}
31
Colin Cross3d7678f2015-04-24 15:16:39 -070032func ResourceDirsToJarSpecs(ctx common.AndroidModuleContext, resourceDirs []string) []jarSpec {
33 var excludes []string
Colin Cross2fe66872015-03-30 17:20:39 -070034
Colin Cross3d7678f2015-04-24 15:16:39 -070035 for _, resourceDir := range resourceDirs {
36 if resourceDir[0] == '-' {
37 excludes = append(excludes, filepath.Join(common.ModuleSrcDir(ctx), resourceDir[1:], "**/*"))
38 }
39 }
40
41 excludes = append(excludes, resourceExcludes...)
42
43 var jarSpecs []jarSpec
44
45 for _, resourceDir := range resourceDirs {
46 if resourceDir[0] == '-' {
47 continue
48 }
49 resourceDir := filepath.Join(common.ModuleSrcDir(ctx), resourceDir)
50 dirs := common.Glob(ctx, resourceDir, nil)
51 for _, dir := range dirs {
52 fileListFile := filepath.Join(common.ModuleOutDir(ctx), "res", dir, "resources.list")
53 depFile := fileListFile + ".d"
54
55 glob := filepath.Join(dir, "**/*")
56 common.GlobRule(ctx, glob, excludes, fileListFile, depFile)
57 jarSpecs = append(jarSpecs, jarSpec{fileListFile, dir})
58 }
Colin Cross2fe66872015-03-30 17:20:39 -070059 }
60
61 return jarSpecs
62}