2019-08-05 13:26:07 +02:00
|
|
|
// Copyright 2019 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 java
|
|
|
|
|
|
|
|
import (
|
|
|
|
"android/soong/android"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
android.RegisterModuleType("platform_compat_config", platformCompatConfigFactory)
|
|
|
|
}
|
|
|
|
|
|
|
|
type platformCompatConfigProperties struct {
|
2019-08-29 13:48:43 +02:00
|
|
|
Src *string `android:"path"`
|
2019-08-05 13:26:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type platformCompatConfig struct {
|
|
|
|
android.ModuleBase
|
|
|
|
|
|
|
|
properties platformCompatConfigProperties
|
2019-10-02 07:05:35 +02:00
|
|
|
installDirPath android.InstallPath
|
2019-08-05 13:26:07 +02:00
|
|
|
configFile android.OutputPath
|
2019-12-17 12:14:42 +01:00
|
|
|
metadataFile android.OutputPath
|
2019-08-05 13:26:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *platformCompatConfig) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
|
rule := android.NewRuleBuilder()
|
|
|
|
|
2019-08-29 13:48:43 +02:00
|
|
|
configFileName := p.Name() + ".xml"
|
2019-12-17 12:14:42 +01:00
|
|
|
metadataFileName := p.Name() + "_meta.xml"
|
2019-08-05 13:26:07 +02:00
|
|
|
p.configFile = android.PathForModuleOut(ctx, configFileName).OutputPath
|
2019-12-17 12:14:42 +01:00
|
|
|
p.metadataFile = android.PathForModuleOut(ctx, metadataFileName).OutputPath
|
2019-08-05 13:26:07 +02:00
|
|
|
path := android.PathForModuleSrc(ctx, String(p.properties.Src))
|
|
|
|
|
|
|
|
rule.Command().
|
2019-12-16 13:55:26 +01:00
|
|
|
BuiltTool(ctx, "process-compat-config").
|
2019-12-17 12:14:42 +01:00
|
|
|
FlagWithInput("--jar ", path).
|
|
|
|
FlagWithOutput("--device-config ", p.configFile).
|
|
|
|
FlagWithOutput("--merged-config ", p.metadataFile)
|
2019-08-05 13:26:07 +02:00
|
|
|
|
2019-08-29 13:48:43 +02:00
|
|
|
p.installDirPath = android.PathForModuleInstall(ctx, "etc", "compatconfig")
|
2019-08-05 13:26:07 +02:00
|
|
|
rule.Build(pctx, ctx, configFileName, "Extract compat/compat_config.xml and install it")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-12-03 05:24:29 +01:00
|
|
|
func (p *platformCompatConfig) AndroidMkEntries() []android.AndroidMkEntries {
|
|
|
|
return []android.AndroidMkEntries{android.AndroidMkEntries{
|
2019-08-05 13:26:07 +02:00
|
|
|
Class: "ETC",
|
|
|
|
OutputFile: android.OptionalPathForPath(p.configFile),
|
|
|
|
Include: "$(BUILD_PREBUILT)",
|
2019-08-28 02:33:16 +02:00
|
|
|
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
|
|
|
func(entries *android.AndroidMkEntries) {
|
2019-10-03 01:01:35 +02:00
|
|
|
entries.SetString("LOCAL_MODULE_PATH", p.installDirPath.ToMakePath().String())
|
2019-08-28 02:33:16 +02:00
|
|
|
entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.configFile.Base())
|
|
|
|
},
|
2019-08-05 13:26:07 +02:00
|
|
|
},
|
2019-12-03 05:24:29 +01:00
|
|
|
}}
|
2019-08-05 13:26:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func platformCompatConfigFactory() android.Module {
|
|
|
|
module := &platformCompatConfig{}
|
|
|
|
module.AddProperties(&module.properties)
|
|
|
|
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
|
|
|
|
return module
|
|
|
|
}
|