Merge "Swap error before setting to prevent nil error"
This commit is contained in:
@@ -382,15 +382,15 @@ func loadSoongConfigModuleTypeDefinition(ctx LoadHookContext, from string) map[s
|
|||||||
defer r.Close()
|
defer r.Close()
|
||||||
|
|
||||||
mtDef, errs := soongconfig.Parse(r, from)
|
mtDef, errs := soongconfig.Parse(r, from)
|
||||||
if ctx.Config().BuildMode == Bp2build {
|
|
||||||
ctx.Config().Bp2buildSoongConfigDefinitions.AddVars(*mtDef)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
reportErrors(ctx, from, errs...)
|
reportErrors(ctx, from, errs...)
|
||||||
return (map[string]blueprint.ModuleFactory)(nil)
|
return (map[string]blueprint.ModuleFactory)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.Config().BuildMode == Bp2build {
|
||||||
|
ctx.Config().Bp2buildSoongConfigDefinitions.AddVars(*mtDef)
|
||||||
|
}
|
||||||
|
|
||||||
globalModuleTypes := ctx.moduleFactories()
|
globalModuleTypes := ctx.moduleFactories()
|
||||||
|
|
||||||
factories := make(map[string]blueprint.ModuleFactory)
|
factories := make(map[string]blueprint.ModuleFactory)
|
||||||
|
@@ -17,6 +17,7 @@ package bp2build
|
|||||||
import (
|
import (
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
"android/soong/cc"
|
"android/soong/cc"
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -36,6 +37,29 @@ func registerSoongConfigModuleTypes(ctx android.RegistrationContext) {
|
|||||||
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
|
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestErrorInBpFileDoesNotPanic(t *testing.T) {
|
||||||
|
bp := `
|
||||||
|
soong_config_module_type {
|
||||||
|
name: "library_linking_strategy_cc_defaults",
|
||||||
|
module_type: "cc_defaults",
|
||||||
|
config_namespace: "ANDROID",
|
||||||
|
variables: ["library_linking_strategy"],
|
||||||
|
properties: [
|
||||||
|
"shared_libs",
|
||||||
|
"static_libs",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
|
||||||
|
Description: "soong config variables - generates selects for library_linking_strategy",
|
||||||
|
ModuleTypeUnderTest: "cc_binary",
|
||||||
|
ModuleTypeUnderTestFactory: cc.BinaryFactory,
|
||||||
|
Blueprint: bp,
|
||||||
|
ExpectedErr: fmt.Errorf(`unknown variable "library_linking_strategy" in module type "library_linking_strategy_cc_defaults`),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestSoongConfigModuleType(t *testing.T) {
|
func TestSoongConfigModuleType(t *testing.T) {
|
||||||
bp := `
|
bp := `
|
||||||
soong_config_module_type {
|
soong_config_module_type {
|
||||||
|
Reference in New Issue
Block a user