This is from reference to What is art.go? And why is it considered a way to write conditionals in bp files?. My use case need to segregate some source files based on condition. Is it possible to achieve something similar to ifeq case we add in .mk files
Below is my Sample code
my_sample.go
package config_variant
import (
"android/soong/android"
)
func globalFlags(ctx android.LoadHookContext) []string {
var Srcs []string
if ctx.AConfig().Getenv("SOME_ENV") == "my_env" {
Srcs = append(Srcs, "<path of the file to be included>")
}
return Srcs;
}
func configVariant(ctx android.LoadHookContext) {
type props struct {
Srcs []string
}
p := &props{}
p.Srcs = globalFlags(ctx)
ctx.AppendProperties(p)
}
func init() {
android.RegisterModuleType("config_variant", variantFactory)
}
func variantFactory() android.Module {
module := android.FileGroupFactory()
android.AddLoadHook(module, configVariant)
return module
}
Android.bp
bootstrap_go_package {
name :"soong-config_variant",
pkgPath :"android/soong/my/sample",
deps :[
"soong",
"soong-android",
"soong-cc"
],
srcs:[
"my_sample.go"
],
pluginFor:["soong_build"]
}
config_variant {
name: "variant_configurator",
srcs:["<added local class file to be included based on conditon>"],
}
android_app {
....
**defaults:["variant_configurator"]**,
...
}
Getting build break when trying to add highlighted statement inside android_app {}.. How to inform android_app to say don't compile this set of code