Check missing uncoditionally loaded missing modules at runtime

A potentially inherited (via dynamically calculated path) module may in turn
unconditionally load a module that does no exist in a source tree -- it is
not an error if this potentially inherited module is actually never inherited
because its dynamically calculated path will never reference it. Instead of
emitting an uncoditional `load` for a non-existent file (which is going to fail
in the Starlark parser), emit conditional load and a runtime check.

Fixes: 213922819
Test: internal
Change-Id: I92177878e199a1f00e5f0c4045c0c0daeddd6bdb
This commit is contained in:
Sasha Smundak
2022-01-10 17:02:16 -08:00
parent 6609484961
commit 6bc132aff9
3 changed files with 50 additions and 26 deletions

View File

@@ -121,7 +121,7 @@ $(call inherit-product, part.mk)
ifdef PRODUCT_NAME
$(call inherit-product, part1.mk)
else # Comment
$(call inherit-product, $(LOCAL_PATH)/part1.mk)
$(call inherit-product, $(LOCAL_PATH)/part.mk)
endif
`,
expected: `load("//build/make/core:product_config.rbc", "rblf")
@@ -132,10 +132,12 @@ def init(g, handle):
cfg = rblf.cfg(handle)
rblf.inherit(handle, "part", _part_init)
if g.get("PRODUCT_NAME") != None:
if not _part1_init:
rblf.mkerror("product.mk", "Cannot find %s" % (":part1.star"))
rblf.inherit(handle, "part1", _part1_init)
else:
# Comment
rblf.inherit(handle, "part1", _part1_init)
rblf.inherit(handle, "part", _part_init)
`,
},
{
@@ -173,6 +175,8 @@ def init(g, handle):
cfg = rblf.cfg(handle)
_part_init(g, handle)
if g.get("PRODUCT_NAME") != None:
if not _part1_init:
rblf.mkerror("product.mk", "Cannot find %s" % (":part1.star"))
_part1_init(g, handle)
else:
if _part1_init != None: