blob: 67b93ffe8b34483f4a84aeb8d5f487d1e8272f30 [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"
Colin Cross3f40fa42015-01-30 17:27:36 -080019)
20
21var (
22 pctx = blueprint.NewPackageContext("android/soong/common")
23
24 cpPreserveSymlinks = pctx.VariableConfigMethod("cpPreserveSymlinks",
25 Config.CpPreserveSymlinksFlags)
26
27 // A phony rule that is not the built-in Ninja phony rule. The built-in
28 // phony rule has special behavior that is sometimes not desired. See the
29 // Ninja docs for more details.
30 Phony = pctx.StaticRule("Phony",
31 blueprint.RuleParams{
32 Command: "# phony $out",
33 Description: "phony $out",
34 })
35
36 // GeneratedFile is a rule for indicating that a given file was generated
37 // while running soong. This allows the file to be cleaned up if it ever
38 // stops being generated by soong.
39 GeneratedFile = pctx.StaticRule("GeneratedFile",
40 blueprint.RuleParams{
41 Command: "# generated $out",
42 Description: "generated $out",
43 Generator: true,
44 })
45
46 // A copy rule.
47 Cp = pctx.StaticRule("Cp",
48 blueprint.RuleParams{
49 Command: "cp $cpPreserveSymlinks $cpFlags $in $out",
50 Description: "cp $out",
51 },
52 "cpFlags")
53
54 // A symlink rule.
55 Symlink = pctx.StaticRule("Symlink",
56 blueprint.RuleParams{
57 Command: "ln -f -s $fromPath $out",
58 Description: "symlink $out",
59 },
60 "fromPath")
61)