1// Copyright 2023 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. 14package sdk 15 16import ( 17 "android/soong/android" 18 "android/soong/genrule" 19) 20 21func init() { 22 registerGenRuleBuildComponents(android.InitRegistrationContext) 23} 24 25func registerGenRuleBuildComponents(ctx android.RegistrationContext) { 26 ctx.RegisterModuleType("sdk_genrule", SdkGenruleFactory) 27} 28 29// sdk_genrule_host is a genrule that can depend on sdk and sdk_snapshot module types 30// 31// What this means is that it's a genrule with only the "common_os" variant. 32// sdk modules have 3 variants: host, android, and common_os. The common_os one depends 33// on the host/device ones and packages their result into a final snapshot zip. 34// Genrules probably want access to this snapshot zip when they depend on an sdk module, 35// which means they want to depend on the common_os variant and not the host/android 36// variants. 37func SdkGenruleFactory() android.Module { 38 module := genrule.NewGenRule() 39 40 android.InitCommonOSAndroidMultiTargetsArchModule(module, android.NeitherHostNorDeviceSupported, android.MultilibCommon) 41 android.InitDefaultableModule(module) 42 43 return module 44} 45