blob: 7b2a70674fa7ae66ceaef808fb963f7db424c0bc [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 (
Colin Cross70b40592015-03-23 12:57:34 -070018 "github.com/google/blueprint"
Dan Willemsen24f2f8d2015-07-15 14:34:02 -070019 _ "github.com/google/blueprint/bootstrap"
Colin Cross3f40fa42015-01-30 17:27:36 -080020)
21
22var (
23 pctx = blueprint.NewPackageContext("android/soong/common")
24
25 cpPreserveSymlinks = pctx.VariableConfigMethod("cpPreserveSymlinks",
26 Config.CpPreserveSymlinksFlags)
27
Colin Crossb3245e92015-06-30 16:27:57 -070028 srcDir = pctx.VariableConfigMethod("srcDir", Config.SrcDir)
29
Colin Cross3f40fa42015-01-30 17:27:36 -080030 // A phony rule that is not the built-in Ninja phony rule. The built-in
31 // phony rule has special behavior that is sometimes not desired. See the
32 // Ninja docs for more details.
33 Phony = pctx.StaticRule("Phony",
34 blueprint.RuleParams{
35 Command: "# phony $out",
36 Description: "phony $out",
37 })
38
39 // GeneratedFile is a rule for indicating that a given file was generated
40 // while running soong. This allows the file to be cleaned up if it ever
41 // stops being generated by soong.
42 GeneratedFile = pctx.StaticRule("GeneratedFile",
43 blueprint.RuleParams{
44 Command: "# generated $out",
45 Description: "generated $out",
46 Generator: true,
47 })
48
49 // A copy rule.
50 Cp = pctx.StaticRule("Cp",
51 blueprint.RuleParams{
52 Command: "cp $cpPreserveSymlinks $cpFlags $in $out",
53 Description: "cp $out",
54 },
55 "cpFlags")
56
57 // A symlink rule.
58 Symlink = pctx.StaticRule("Symlink",
59 blueprint.RuleParams{
60 Command: "ln -f -s $fromPath $out",
61 Description: "symlink $out",
62 },
63 "fromPath")
64)
Dan Willemsen24f2f8d2015-07-15 14:34:02 -070065
66func init() {
67 pctx.Import("github.com/google/blueprint/bootstrap")
68}