blob: 9e185e44df11e99d9a9f430b5cdb71c990282b64 [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 (
Dan Willemsen34cc69e2015-09-23 15:26:20 -070023 pctx = NewPackageContext("android/soong/common")
Colin Cross3f40fa42015-01-30 17:27:36 -080024
25 cpPreserveSymlinks = pctx.VariableConfigMethod("cpPreserveSymlinks",
26 Config.CpPreserveSymlinksFlags)
27
Colin Cross3f40fa42015-01-30 17:27:36 -080028 // 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)
Dan Willemsen24f2f8d2015-07-15 14:34:02 -070063
64func init() {
65 pctx.Import("github.com/google/blueprint/bootstrap")
66}