Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1 | // 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 | |
| 15 | package java |
| 16 | |
| 17 | import ( |
| 18 | "path/filepath" |
| 19 | |
| 20 | "android/soong/common" |
| 21 | ) |
| 22 | |
| 23 | var resourceExcludes = []string{ |
Colin Cross | 3d7678f | 2015-04-24 15:16:39 -0700 | [diff] [blame^] | 24 | "**/*.java", |
| 25 | "**/package.html", |
| 26 | "**/overview.html", |
| 27 | "**/.*.swp", |
| 28 | "**/.DS_Store", |
| 29 | "**/*~", |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 30 | } |
| 31 | |
Colin Cross | 3d7678f | 2015-04-24 15:16:39 -0700 | [diff] [blame^] | 32 | func ResourceDirsToJarSpecs(ctx common.AndroidModuleContext, resourceDirs []string) []jarSpec { |
| 33 | var excludes []string |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 34 | |
Colin Cross | 3d7678f | 2015-04-24 15:16:39 -0700 | [diff] [blame^] | 35 | 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 Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | return jarSpecs |
| 62 | } |