blob: 98464fef31a14bc50ea19c80d3ed5823a06872e2 [file] [log] [blame]
Colin Cross3f40fa42015-01-30 17:27:36 -08001// 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 common
16
17import (
Dan Willemsenbf9207a2015-06-17 15:17:12 -070018 "path/filepath"
19
Colin Cross70b40592015-03-23 12:57:34 -070020 "github.com/google/blueprint"
Dan Willemsenbf9207a2015-06-17 15:17:12 -070021 "github.com/google/blueprint/bootstrap"
Colin Cross3f40fa42015-01-30 17:27:36 -080022)
23
24var (
25 pctx = blueprint.NewPackageContext("android/soong/common")
26
27 cpPreserveSymlinks = pctx.VariableConfigMethod("cpPreserveSymlinks",
28 Config.CpPreserveSymlinksFlags)
29
Dan Willemsenbf9207a2015-06-17 15:17:12 -070030 androidbpCmd = filepath.Join(bootstrap.BinDir, "androidbp")
31 androidbp = pctx.StaticRule("androidbp",
32 blueprint.RuleParams{
33 Command: androidbpCmd + " $in $out",
34 Description: "androidbp $out",
35 })
36
Colin Cross3f40fa42015-01-30 17:27:36 -080037 // A phony rule that is not the built-in Ninja phony rule. The built-in
38 // phony rule has special behavior that is sometimes not desired. See the
39 // Ninja docs for more details.
40 Phony = pctx.StaticRule("Phony",
41 blueprint.RuleParams{
42 Command: "# phony $out",
43 Description: "phony $out",
44 })
45
46 // GeneratedFile is a rule for indicating that a given file was generated
47 // while running soong. This allows the file to be cleaned up if it ever
48 // stops being generated by soong.
49 GeneratedFile = pctx.StaticRule("GeneratedFile",
50 blueprint.RuleParams{
51 Command: "# generated $out",
52 Description: "generated $out",
53 Generator: true,
54 })
55
56 // A copy rule.
57 Cp = pctx.StaticRule("Cp",
58 blueprint.RuleParams{
59 Command: "cp $cpPreserveSymlinks $cpFlags $in $out",
60 Description: "cp $out",
61 },
62 "cpFlags")
63
64 // A symlink rule.
65 Symlink = pctx.StaticRule("Symlink",
66 blueprint.RuleParams{
67 Command: "ln -f -s $fromPath $out",
68 Description: "symlink $out",
69 },
70 "fromPath")
71)