blob: bf67795a7040640d29cc63d738d658c3d514f133 [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) {
Cole Faust65cb40a2024-10-21 15:41:42 -070026 // Test that a genrule can depend on an sdk if using common_os_srcs
Cole Faust8fc38f32023-12-12 17:14:22 -080027 bp := `
28 sdk {
29 name: "my_sdk",
30 }
Cole Faust8fc38f32023-12-12 17:14:22 -080031 genrule {
32 name: "my_regular_genrule",
Cole Faust65cb40a2024-10-21 15:41:42 -070033 common_os_srcs: [":my_sdk"],
Cole Faust8fc38f32023-12-12 17:14:22 -080034 out: ["out"],
35 cmd: "cp $(in) $(out)",
36 }
37 `
38 android.GroupFixturePreparers(
39 // if java components aren't registered, the sdk module doesn't create a snapshot for some reason.
40 java.PrepareForTestWithJavaBuildComponents,
41 genrule.PrepareForTestWithGenRuleBuildComponents,
42 PrepareForTestWithSdkBuildComponents,
43 android.FixtureRegisterWithContext(registerGenRuleBuildComponents),
44 ).RunTestWithBp(t, bp)
45}