FilesΒΆ
Targets based on files and modified timestamps as in Make. File targets
evaluate to the pathlib.Path of their target.
Consider a simple Makefile that builds an executable from a C source file:
hello : hello.o
$(CC) $(LDFLAGS) -o hello hello.o $(LDLIBS)
hello.o : hello.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c hello.c
Here is the same example in Picard using picard.file(). One notable
difference is that, due to Python scope rules, you must declare prerequisites
before the targets that depend on them.
import picard
@picard.file('hello.o', 'hello.c')
async def hello_o(target, context, hello_c):
cc = context.config.get('CC', 'cc')
cpp_flags = context.config.get('CPPFLAGS', None)
c_flags = context.config.get('CFLAGS', None)
await picard.sh(cc, cpp_flags, c_flags, '-c', hello_c)
@picard.file('hello', hello_o)
async def hello(target, context, hello_o):
cc = context.config.get('CC', 'cc')
ld_flags = context.config.get('LDFLAGS', None)
ld_libs = context.config.get('LDLIBS', None)
await picard.sh(cc, ld_flags, '-o', 'hello', hello_o, ld_libs)
if __name__ == '__main__':
picard.make(hello)
Note
If you are compiling C or C++, these patterns in this example have already
been encapsulated in picard.clang.