[Scons-users] sources in zip

Greg Ward greg at gerg.ca
Sun Aug 12 18:01:51 EDT 2012


On 12 August 2012, Kraus Philipp said:

> I use env.Command for downloading a gz file, another env.command for unzipping and than I would like to compile some sources of this extracted data.

> I have got some problems with the dependencies, I'm using Depends for create the connections:

>

> download = env.Command("download", "", download)

> extract = env.Command("extract", "", "tar xfv ....")

> build = env.Program(...)


You might need to make this a little more concrete, e.g. provide real
filenames. For starters, how do you know the URL that you're
downloading: is it hardcoded? or determined when scons runs your build
script? or even later than that?


> Depends(extract, download)

> Depends(build, extract)


If you wire up your sources and targets correctly, this should not be
necessary. E.g. tell SCons that foo.tar.gz is the target (output) of
your download command and source (input) to your tar command, and
SCons will infer the first dependency for free.


> My problem is now, that I know the source file name, but not the directory. If I extract the gz file, I will get an directory mysources-??-??

> were ?? are number of the version. I know that the sources files are stored in mysources-??-??/src/ but in which way can I detect the

> correct directory name with the correct dependency graph, because env.Program must get the correct path.


Is the version number encoded in the filename? E.g. are you
downloading foo-1.0.tar.gz which unpacks to foo-1.0/? If so, just
parse the filename (or URL) in your build script.

But if you always download the same URL (foo.tar.gz), and it unpacks
to an unpredictable directory... that's tricky. I have found that
SCons does not handle that sort of dynamism very well. Or at least I
haven't figured out how to handle it. ;-(

The problem is that you need to inject dependencies into the graph
late, after SCons runs your "tar -xfv" command. Actually, that's the
easy part. The hard part, which I have yet to figure out, is how to
get SCons to write those newly injected dependencies into its database
to usefully influence future runs.

Greg
--
Greg Ward http://www.gerg.ca/
Hold the MAYO & pass the COSMIC AWARENESS ...


More information about the Scons-users mailing list