Emit unconditional module load only when inherit/include is on the top level.
That is, when a makefile contains
```
ifneq (,$(foo))
$(call inherit-product,module.mk)
endif
```
module.mk has to be present only if `foo` is set.
Fixes: 200163602
Test: internal
Change-Id: Ic5f10ce8d49d6b87162bfe77922bba5e2cce228b
diff --git a/mk2rbc/node.go b/mk2rbc/node.go
index 8efe207..3fe1a17 100644
--- a/mk2rbc/node.go
+++ b/mk2rbc/node.go
@@ -57,7 +57,7 @@
name() string
entryName() string
emitSelect(gctx *generationContext)
- isLoadAlways() bool
+ shouldExist() bool
}
type inheritedStaticModule struct {
@@ -72,7 +72,7 @@
func (im inheritedStaticModule) emitSelect(_ *generationContext) {
}
-func (im inheritedStaticModule) isLoadAlways() bool {
+func (im inheritedStaticModule) shouldExist() bool {
return im.loadAlways
}
@@ -115,12 +115,13 @@
}
}
-func (i inheritedDynamicModule) isLoadAlways() bool {
+func (i inheritedDynamicModule) shouldExist() bool {
return i.loadAlways
}
type inheritNode struct {
- module inheritedModule
+ module inheritedModule
+ loadAlways bool
}
func (inn *inheritNode) emit(gctx *generationContext) {
@@ -134,7 +135,7 @@
name := inn.module.name()
entry := inn.module.entryName()
gctx.newLine()
- if inn.module.isLoadAlways() {
+ if inn.loadAlways {
gctx.writef("%s(handle, %s, %s)", cfnInherit, name, entry)
return
}
@@ -147,14 +148,15 @@
}
type includeNode struct {
- module inheritedModule
+ module inheritedModule
+ loadAlways bool
}
func (inn *includeNode) emit(gctx *generationContext) {
inn.module.emitSelect(gctx)
entry := inn.module.entryName()
gctx.newLine()
- if inn.module.isLoadAlways() {
+ if inn.loadAlways {
gctx.writef("%s(g, handle)", entry)
return
}