doit icon indicating copy to clipboard operation
doit copied to clipboard

Trying to understand the behavior of targets and action execution

Open sandeep-gh opened this issue 1 year ago • 0 comments

In this simple code picked from tutorials:

def task_hello():
    """hello py """

    def python_hello(times, text, targets):
        with open(targets[0], "w") as output:
            output.write(times * text)

    return {'actions': [(python_hello, [3, "py!\n"])],
            'targets': ["hello.txt"],
            }

def task_compile():
    return {'actions': ["cc -c main.c"],
            'file_dep': ["main.c", "defs.h"],
            'targets': ["main.o"]
            }

when I run this code multiple times I get following output:

.  hello
-- compile

my question is why is the task_hello getting executed if though its targets are clearly present for last execution. For task_compile, I get the expected behavior. It doesn't run again after the first invocation. What is so special about the open command.

sandeep-gh avatar Aug 01 '22 14:08 sandeep-gh