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 ( 18 "github.com/google/blueprint" 19 _ "github.com/google/blueprint/bootstrap" 20 ) 21 22 var ( 23 pctx = NewPackageContext("android/soong/common") 24 25 cpPreserveSymlinks = pctx.VariableConfigMethod("cpPreserveSymlinks", 26 Config.CpPreserveSymlinksFlags) 27 28 // A phony rule that is not the built-in Ninja phony rule. The built-in 29 // phony rule has special behavior that is sometimes not desired. See the 30 // Ninja docs for more details. 31 Phony = pctx.StaticRule("Phony", 32 blueprint.RuleParams{ 33 Command: "# phony $out", 34 Description: "phony $out", 35 }) 36 37 // GeneratedFile is a rule for indicating that a given file was generated 38 // while running soong. This allows the file to be cleaned up if it ever 39 // stops being generated by soong. 40 GeneratedFile = pctx.StaticRule("GeneratedFile", 41 blueprint.RuleParams{ 42 Command: "# generated $out", 43 Description: "generated $out", 44 Generator: true, 45 }) 46 47 // A copy rule. 48 Cp = pctx.StaticRule("Cp", 49 blueprint.RuleParams{ 50 Command: "cp $cpPreserveSymlinks $cpFlags $in $out", 51 Description: "cp $out", 52 }, 53 "cpFlags") 54 55 // A symlink rule. 56 Symlink = pctx.StaticRule("Symlink", 57 blueprint.RuleParams{ 58 Command: "ln -f -s $fromPath $out", 59 Description: "symlink $out", 60 }, 61 "fromPath") 62 63 ErrorRule = pctx.StaticRule("Error", 64 blueprint.RuleParams{ 65 Command: `echo "$error" && false`, 66 Description: "error building $out", 67 }, 68 "error") 69 ) 70 71 func init() { 72 pctx.Import("github.com/google/blueprint/bootstrap") 73 } 74