blob: 0001ce1bbb5b6249f84a6e61f48d1f6e3b293f68 [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 Willemsen24f2f8d2015-07-15 14:34:02 -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
Colin Crossb3245e92015-06-30 16:27:57 -070030 srcDir = pctx.VariableConfigMethod("srcDir", Config.SrcDir)
31
Dan Willemsen24f2f8d2015-07-15 14:34:02 -070032 androidbpCmd = filepath.Join("${bootstrap.BinDir}", "androidbp")
Dan Willemsenbf9207a2015-06-17 15:17:12 -070033 androidbp = pctx.StaticRule("androidbp",
34 blueprint.RuleParams{
Colin Crossb3245e92015-06-30 16:27:57 -070035 Command: androidbpCmd + " ${srcDir}/Android.bp $in $out",
Dan Willemsenbf9207a2015-06-17 15:17:12 -070036 Description: "androidbp $out",
37 })
38
Colin Cross3f40fa42015-01-30 17:27:36 -080039 // 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 Willemsen24f2f8d2015-07-15 14:34:02 -070074
75func init() {
76 pctx.Import("github.com/google/blueprint/bootstrap")
77}