[Scons-dev] Question regarding variant_dirs and custom builders

Bastian Reitemeier lists at brtmr.de
Fri Jul 17 05:56:18 EDT 2020


Hi,

I am trying to make a custom builder (with a custom emitter) that plays well when building in a variant_dir. 
I am having trouble understanding how a custom emitter deals with variant paths (or if it has to deal with it). 
Here is what I am trying to do: I have a source dir, and a separate variant_dir for building in. 
Let’s call them src/ and build/. I want to make a custom builder that given a source tarball at a path in src (lets say src/a/b/c.tar) extracts the archive to the same relative path in the variant_dir (build/a/b/). Currently I am simply using the tarfile.extractall standard library function. 
My questions are now:
How do I make my builder “aware” of the variant dir? That is, how do I construct the path within the variant_dir to pass to extract_all(path=...)? How do the built-in Builders deal with this?
When emitting the contents of the tarball as new_targets, what paths do I have to emit (relative to src. relative to build, absolute paths)? 
I managed to get a solution that extracts to the correct path (by (ab-)using the alter_targets method), but fails at deciding if the tarball needs re-extracting. Instead it just re-extracts it every time.
Does the answer to these questions change when the variant dir is duplicate=0?

Best Regards,
Bastian


More information about the Scons-dev mailing list