[Scons-users] sources in zip

Philipp Kraus philipp.kraus at flashpixx.de
Sun Aug 12 18:55:05 EDT 2012


On 2012-08-13 00:01:51 +0200, Greg Ward said:


> 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?


No the URL is not hardcoded, I call a HTML document and can parse it with
a short set of regular expressions for getting the download URL.


>

>> 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.


okay,I have forgot this. Can I handle the URL parsing also?
I read a fixed URL => use regular expression to get the download URL, this
URL can be a source of the download target, the download targets stores a
tar.gz file which is the source of the tar-command.


>

>> 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.


No sorry, the correct dir name is first known after extracting. In some
cases I can parse the filename, but in another case I have got a fixed URL
and a fixed filename

Can you show me an excerpt with parsing the data?


> 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. ;-(


I can't do this because some tar.gz have this structur:
/
/ sources-??-??
/ include
/ src
....

and the names are fixed.


> 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.


IMHO I need only pass a parameter from one graph node to the next node.
The source of a graphnode are the targets of the previous node, so I must only
expand this "vector". In theory I have got transfer function in the Scons
way the function is the "builder" and the inputs the sources of one
state and the
targets the outputs of this state. I try to store this information in
the env-object
but that does not work. I need a global place, where I can save some
information

Thanks

Phil




More information about the Scons-users mailing list