Calling a python script from a Jamfile

533 views Asked by At

I would like to call a python script from a Jamfile to generate a necessary source file.

In a Makefile, it would look somewhat like this:

sourcefile.c:
    python script.py

What is the most elegant way to archive something like this in a Jamfile?

1

There are 1 answers

1
user686249 On BEST ANSWER

The jam equivalent is this:

actions CallScript
{
    python script.py
}

CallScript sourcefile.c ;

Depending on the context of your application, you might need to do a bit more. E.g. if the script generates the source file and you want to compile that generated source file, the solution would probably look like:

rule GenerateSource
{
    local source = [ FGristFiles $(1) ] ;
    MakeLocate $(source) : $(LOCATE_SOURCE) ;
    Clean clean : $(source) ;
    GenerateSource1 $(source) ;
}

actions GenerateSource1
{
    python script.py $(1)
}

GenerateSource sourcefile.c ;

Main foo : sourcefile.c ;