I need to dynamically append new flags to aaptflags
property from android_app
from Android.bp, based in some conditions. I am trying something similar to this answer, the Go script is executed (I can see it when I add some prints), but the flags are not added.
This is my code, any idea what I'm missing?
my_defaults.go
package my_defaults
import (
"android/soong/android"
"android/soong/cc"
)
func aaptFlags(ctx android.BaseContext) []string {
// I will replace this with some logic.
// Returning a fixed value just for sake of simplicity
var cflags []string
cflags = append(cflags, "my_flag_here")
return cflags
}
func myDefaults(ctx android.LoadHookContext) {
type props struct {
aaptflags []string
}
p := &props{}
p.aaptflags = aaptFlags(ctx)
ctx.AppendProperties(p)
}
func init() {
android.RegisterModuleType("my_defaults", myDefaultsFactory)
}
func myDefaultsFactory() android.Module {
module := cc.DefaultsFactory()
android.AddLoadHook(module, myDefaults)
return module
}
Android.bp
bootstrap_go_package {
name: "soong-my_defaults",
pkgPath: "android/soong/my/defaults",
deps: [
"soong",
"soong-android",
"soong-cc"
],
srcs: [
"my_defaults.go"
],
pluginFor: ["soong_build"]
}
my_defaults {
name: "my_defaults",
}
android_app {
name: "MyApp",
defaults: [
"my_defaults",
],
srcs: ["src/**/*.java"],
// I need dinamically append new flags here
aaptflags: [
"some_flags",
],
// ...
}
// ...
Thanks
from How to append aapt flags to Android.bp dynamically
No comments:
Post a Comment