diff options
author | 2024-08-12 11:15:19 +0900 | |
---|---|---|
committer | 2024-08-14 10:34:41 +0900 | |
commit | faf6af31cdee65cfe4dbc26eafff4e9321c67b93 (patch) | |
tree | 7de70239d8c69111f8ea71b8491fcc055a0f39c0 /android/vintf_fragment.go | |
parent | d0338d3565cf1efcf27d7932e4ed62faa09a6076 (diff) |
Introduce vintf_fragment module type
Introduce a new vintf_fragment module type which handles vintf_fragment
files within Soong. This will help process to move vintf_fragment
handling logic from KATI to Soong. This change also introduces
vintf_fragment_modules property to mark dependency with vintf_fragment
modules.
Bug: 322089980
Test: m nothing --no-skip-soong-tests passed
Change-Id: I49607f42aeee3ded0ba7b078b903dc35f5d61637
Diffstat (limited to 'android/vintf_fragment.go')
-rw-r--r-- | android/vintf_fragment.go | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/android/vintf_fragment.go b/android/vintf_fragment.go new file mode 100644 index 000000000..329eac974 --- /dev/null +++ b/android/vintf_fragment.go @@ -0,0 +1,84 @@ +// Copyright 2024 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 + +type vintfFragmentProperties struct { + // Vintf fragment XML file. + Src string `android:"path"` +} + +type vintfFragmentModule struct { + ModuleBase + + properties vintfFragmentProperties + + installDirPath InstallPath + outputFilePath OutputPath +} + +func init() { + registerVintfFragmentComponents(InitRegistrationContext) +} + +func registerVintfFragmentComponents(ctx RegistrationContext) { + ctx.RegisterModuleType("vintf_fragment", vintfLibraryFactory) +} + +// vintf_fragment module processes vintf fragment file and installs under etc/vintf/manifest. +// Vintf fragment files formerly listed in vintf_fragment property would be transformed into +// this module type. +func vintfLibraryFactory() Module { + m := &vintfFragmentModule{} + m.AddProperties( + &m.properties, + ) + InitAndroidArchModule(m, DeviceSupported, MultilibFirst) + + return m +} + +func (m *vintfFragmentModule) GenerateAndroidBuildActions(ctx ModuleContext) { + builder := NewRuleBuilder(pctx, ctx) + srcVintfFragment := PathForModuleSrc(ctx, m.properties.Src) + processedVintfFragment := PathForModuleOut(ctx, srcVintfFragment.Base()) + + // Process vintf fragment source file with assemble_vintf tool + builder.Command(). + Flag("VINTF_IGNORE_TARGET_FCM_VERSION=true"). + BuiltTool("assemble_vintf"). + FlagWithInput("-i ", srcVintfFragment). + FlagWithOutput("-o ", processedVintfFragment) + + builder.Build("assemble_vintf", "Process vintf fragment "+processedVintfFragment.String()) + + m.installDirPath = PathForModuleInstall(ctx, "etc", "vintf", "manifest") + m.outputFilePath = processedVintfFragment.OutputPath + + ctx.InstallFile(m.installDirPath, processedVintfFragment.Base(), processedVintfFragment) +} + +// Make this module visible to AndroidMK so it can be referenced from modules defined from Android.mk files +func (m *vintfFragmentModule) AndroidMkEntries() []AndroidMkEntries { + return []AndroidMkEntries{{ + Class: "ETC", + OutputFile: OptionalPathForPath(m.outputFilePath), + ExtraEntries: []AndroidMkExtraEntriesFunc{ + func(ctx AndroidMkExtraEntriesContext, entries *AndroidMkEntries) { + entries.SetString("LOCAL_MODULE_PATH", m.installDirPath.String()) + entries.SetString("LOCAL_INSTALLED_MODULE_STEM", m.outputFilePath.Base()) + }, + }, + }} +} |