blob: 6e52a3db02b5b34743e64d7198f55fb570a7067b [file] [log] [blame]
Cole Faust8fc38f32023-12-12 17:14:22 -08001// Copyright 2018 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 sdk
16
17import (
18 "testing"
19
20 "android/soong/android"
21 "android/soong/genrule"
22 "android/soong/java"
23)
24
25func TestSdkGenrule(t *testing.T) {
26 // Test that an sdk_genrule can depend on an sdk, and that a genrule can depend on an sdk_genrule
27 bp := `
28 sdk {
29 name: "my_sdk",
30 }
31 sdk_genrule {
32 name: "my_sdk_genrule",
33 tool_files: ["tool"],
34 cmd: "$(location tool) $(in) $(out)",
35 srcs: [":my_sdk"],
36 out: ["out"],
37 }
38 genrule {
39 name: "my_regular_genrule",
40 srcs: [":my_sdk_genrule"],
41 out: ["out"],
42 cmd: "cp $(in) $(out)",
43 }
44 `
45 android.GroupFixturePreparers(
46 // if java components aren't registered, the sdk module doesn't create a snapshot for some reason.
47 java.PrepareForTestWithJavaBuildComponents,
48 genrule.PrepareForTestWithGenRuleBuildComponents,
49 PrepareForTestWithSdkBuildComponents,
50 android.FixtureRegisterWithContext(registerGenRuleBuildComponents),
51 ).RunTestWithBp(t, bp)
52}