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 15package android 16 17import ( 18 "github.com/google/blueprint" 19 _ "github.com/google/blueprint/bootstrap" 20) 21 22var ( 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.AndroidStaticRule("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.AndroidStaticRule("GeneratedFile", 41 blueprint.RuleParams{ 42 Command: "# generated $out", 43 Description: "generated $out", 44 Generator: true, 45 }) 46 47 // A copy rule. 48 Cp = pctx.AndroidStaticRule("Cp", 49 blueprint.RuleParams{ 50 Command: "cp $cpPreserveSymlinks $cpFlags $in $out", 51 Description: "cp $out", 52 }, 53 "cpFlags") 54 55 // A timestamp touch rule. 56 Touch = pctx.AndroidStaticRule("Touch", 57 blueprint.RuleParams{ 58 Command: "touch $out", 59 Description: "touch $out", 60 }) 61 62 // A symlink rule. 63 Symlink = pctx.AndroidStaticRule("Symlink", 64 blueprint.RuleParams{ 65 Command: "ln -f -s $fromPath $out", 66 Description: "symlink $out", 67 }, 68 "fromPath") 69 70 ErrorRule = pctx.AndroidStaticRule("Error", 71 blueprint.RuleParams{ 72 Command: `echo "$error" && false`, 73 Description: "error building $out", 74 }, 75 "error") 76 77 Cat = pctx.AndroidStaticRule("Cat", 78 blueprint.RuleParams{ 79 Command: "cat $in > $out", 80 Description: "concatenate licenses $out", 81 }) 82 83 // Used only when USE_GOMA=true is set, to restrict non-goma jobs to the local parallelism value 84 localPool = blueprint.NewBuiltinPool("local_pool") 85) 86 87func init() { 88 pctx.Import("github.com/google/blueprint/bootstrap") 89} 90