Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [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 common |
| 16 | |
| 17 | import ( |
Dan Willemsen | bf9207a | 2015-06-17 15:17:12 -0700 | [diff] [blame] | 18 | "path/filepath" |
| 19 | |
Colin Cross | 70b4059 | 2015-03-23 12:57:34 -0700 | [diff] [blame] | 20 | "github.com/google/blueprint" |
Dan Willemsen | 24f2f8d | 2015-07-15 14:34:02 -0700 | [diff] [blame^] | 21 | _ "github.com/google/blueprint/bootstrap" |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 22 | ) |
| 23 | |
| 24 | var ( |
| 25 | pctx = blueprint.NewPackageContext("android/soong/common") |
| 26 | |
| 27 | cpPreserveSymlinks = pctx.VariableConfigMethod("cpPreserveSymlinks", |
| 28 | Config.CpPreserveSymlinksFlags) |
| 29 | |
Colin Cross | b3245e9 | 2015-06-30 16:27:57 -0700 | [diff] [blame] | 30 | srcDir = pctx.VariableConfigMethod("srcDir", Config.SrcDir) |
| 31 | |
Dan Willemsen | 24f2f8d | 2015-07-15 14:34:02 -0700 | [diff] [blame^] | 32 | androidbpCmd = filepath.Join("${bootstrap.BinDir}", "androidbp") |
Dan Willemsen | bf9207a | 2015-06-17 15:17:12 -0700 | [diff] [blame] | 33 | androidbp = pctx.StaticRule("androidbp", |
| 34 | blueprint.RuleParams{ |
Colin Cross | b3245e9 | 2015-06-30 16:27:57 -0700 | [diff] [blame] | 35 | Command: androidbpCmd + " ${srcDir}/Android.bp $in $out", |
Dan Willemsen | bf9207a | 2015-06-17 15:17:12 -0700 | [diff] [blame] | 36 | Description: "androidbp $out", |
| 37 | }) |
| 38 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 39 | // A phony rule that is not the built-in Ninja phony rule. The built-in |
| 40 | // phony rule has special behavior that is sometimes not desired. See the |
| 41 | // Ninja docs for more details. |
| 42 | Phony = pctx.StaticRule("Phony", |
| 43 | blueprint.RuleParams{ |
| 44 | Command: "# phony $out", |
| 45 | Description: "phony $out", |
| 46 | }) |
| 47 | |
| 48 | // GeneratedFile is a rule for indicating that a given file was generated |
| 49 | // while running soong. This allows the file to be cleaned up if it ever |
| 50 | // stops being generated by soong. |
| 51 | GeneratedFile = pctx.StaticRule("GeneratedFile", |
| 52 | blueprint.RuleParams{ |
| 53 | Command: "# generated $out", |
| 54 | Description: "generated $out", |
| 55 | Generator: true, |
| 56 | }) |
| 57 | |
| 58 | // A copy rule. |
| 59 | Cp = pctx.StaticRule("Cp", |
| 60 | blueprint.RuleParams{ |
| 61 | Command: "cp $cpPreserveSymlinks $cpFlags $in $out", |
| 62 | Description: "cp $out", |
| 63 | }, |
| 64 | "cpFlags") |
| 65 | |
| 66 | // A symlink rule. |
| 67 | Symlink = pctx.StaticRule("Symlink", |
| 68 | blueprint.RuleParams{ |
| 69 | Command: "ln -f -s $fromPath $out", |
| 70 | Description: "symlink $out", |
| 71 | }, |
| 72 | "fromPath") |
| 73 | ) |
Dan Willemsen | 24f2f8d | 2015-07-15 14:34:02 -0700 | [diff] [blame^] | 74 | |
| 75 | func init() { |
| 76 | pctx.Import("github.com/google/blueprint/bootstrap") |
| 77 | } |