thought-machine/please

`get_entry_points` doesn't account for entry points added by post-build functions

chrisnovakovic opened this issue · 0 comments

add_entry_point allows entry points to be added to targets in post-build functions, however these entry points aren't returned by get_entry_points. MWE, based on the test in test/get_entry_points/BUILD:

def add_second_entry_point(name:str, output:list):
    add_entry_point(name, "second", "b")

two = genrule(
    name = "two",
    outs = {
        "a": ["a"],
        "b": ["b"],
    },
    cmd = "for i in $OUTS; do echo x > $i; done",
    entry_points = {
        "first": "a",
    },
    post_build = add_second_entry_point,
)

def assert_dict(l1, l2):
    if l1 != l2:
        fail(f"{l1} != {l2}")

assert_dict(
    {"first": "a", "second": "b"},
    get_entry_points(two),
)
Build stopped after 50ms. 1 target failed:
    //test/get_entry_points:all
test/get_entry_points/BUILD:37:9: error: {"first": a, "second": b} != {"first": a}
    if l1 != l2:
        fail(f"{l1} != {l2}")
        ^


Traceback:
test/get_entry_points/BUILD:37:9:           fail(f"{l1} != {l2}")
test/get_entry_points/BUILD:36:5:       if l1 != l2:
test/get_entry_points/BUILD:49:1:   assert_dict(

I guess this is because the get_entry_points call is evaluated before :two is built.