1

I have a waf rule that does not create a file, so I don't have a target. I'd like another waf rule to be run strictly after the first rule. Below is a contrived example of this type of situation.

In Make syntax, I'm trying to do something like the following:

kill_server:
     myserver --kill

install_server: kill_server
     cp $(SRC)/myserver $(BLD)/myserver

In waf, I'm here:

 def install_server(bld):
      killer = bld(name='kill_server', rule='myserver --kill')
      bld(name='install_server', rule='cp ${SRC} ${TGT}', 
          source=os.path.join(src, 'myserver'), 
          target=os.path.join(bld, 'myserver'), deps=[killer])

Obviously this doesn't work, because killer is TaskGen, not a target node. What could I put in deps? Can a step depend on another step that doesn't create a target?

dbn
  • 13,144
  • 3
  • 60
  • 86

1 Answers1

1

For rule based task generator, you can use the after keyword:

def build(bld):

    bld(
        name = 'kill_server',
        rule = 'echo killing ...;sleep 5',
    )

    bld(
        name = 'install_server',
        rule = 'cp ${SRC} ${TGT}', 
        source = 'myserver', 
        target = 'myserver2',
        after = ["kill_server"]
    )

It works as rule based TG generate only one task with the TG name, and the after keyword is used for the task.

Another solution for other TG is to generate an output file and use it as a source for the dependant TG.

If source and target are the same, use waf Node API:

server = bld.path.find_node('myserver')
target_server = server.get_bld()

waf automatically manage the source tree vs the build tree.

neuro
  • 14,948
  • 3
  • 36
  • 59