From 0d53dd289e4668e827c4b5f5925c2889c3099d02 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Tue, 24 Oct 2023 18:55:12 +0000 Subject: [PATCH] Create an apex_contributions module type This module type does not any build actions, but provides metadata about the contributions of the mainline module to other mainline modules/ platform. One immediate use case for this metadata is source vs prebuilts selection Each mainline module can have more than 1 metadata modules. Static build flags will be used to select the right one in trunk.bzl, next.bzl, ... Bug: 308174923 Test: go build ./android Change-Id: I5ead0c38fe64b78de08db1736d97a8ab7374d6d9 --- android/Android.bp | 1 + android/apex_contributions.go | 67 +++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 android/apex_contributions.go diff --git a/android/Android.bp b/android/Android.bp index f5bb785ff..7fbba4362 100644 --- a/android/Android.bp +++ b/android/Android.bp @@ -32,6 +32,7 @@ bootstrap_go_package { srcs: [ "androidmk.go", "apex.go", + "apex_contributions.go", "api_domain.go", "api_levels.go", "arch.go", diff --git a/android/apex_contributions.go b/android/apex_contributions.go new file mode 100644 index 000000000..a28ac31bf --- /dev/null +++ b/android/apex_contributions.go @@ -0,0 +1,67 @@ +// Copyright 2023 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package android + +import ( + "github.com/google/blueprint/proptools" +) + +func init() { + RegisterApexContributionsBuildComponents(InitRegistrationContext) +} + +func RegisterApexContributionsBuildComponents(ctx RegistrationContext) { + ctx.RegisterModuleType("apex_contributions", apexContributionsFactory) +} + +type apexContributions struct { + ModuleBase + properties contributionProps +} + +type contributionProps struct { + // Name of the mainline module + Api_domain *string + // A list of module names that should be used when this contribution + // is selected via product_config + // The name should be explicit (foo or prebuilt_foo) + Contents []string +} + +func (m *apexContributions) ApiDomain() string { + return proptools.String(m.properties.Api_domain) +} + +func (m *apexContributions) Contents() []string { + return m.properties.Contents +} + +// apex_contributions contains a list of module names (source or +// prebuilt) belonging to the mainline module +// An apex can have multiple apex_contributions modules +// with different combinations of source or prebuilts, but only one can be +// selected via product_config. +func apexContributionsFactory() Module { + module := &apexContributions{} + module.AddProperties(&module.properties) + InitAndroidModule(module) + return module +} + +// This module type does not have any build actions. +// It provides metadata that is used in post-deps mutator phase for source vs +// prebuilts selection. +func (m *apexContributions) GenerateAndroidBuildActions(ctx ModuleContext) { +}