[Scons-users] Is there a way to ensure that actions have SConscript-relative paths ?

Jason Kenny dragon512 at live.com
Wed Jun 21 23:32:04 EDT 2017


In Part I added a function for file node call ID which gave me a consistent value.

The code looks like this:

def _get_FSID(self):
    try:
        return self.attributes.__FSID
    except AttributeError:
        result = SCons.Node.FS.get_default_fs().Dir('#').rel_path(self)
        if os.path.isabs(result) or result.startswith('..'):
            result = self.abspath
        result = result.replace('\\', '/')
        self.attributes.__FSID = result
        return result

SCons.Node.FS.Base.ID=property(_get_FSID)

This would return a Sconstruct based path, except for cases in which the path made to be absolute

Hope this might help.

Jason

From: Scons-users [mailto:scons-users-bounces at scons.org] On Behalf Of Bill Deegan
Sent: Wednesday, June 21, 2017 5:50 PM
To: SCons users mailing list <scons-users at scons.org>
Subject: Re: [Scons-users] Is there a way to ensure that actions have SConscript-relative paths ?

Why do you need to do that?
(Perhaps there's another way to do what you want)
-Bill

On Wed, Jun 21, 2017 at 2:52 PM, Paweł Tomulik <ptomulik at meil.pw.edu.pl<mailto:ptomulik at meil.pw.edu.pl>> wrote:
W dniu 31.05.2017 o 05:20, Zarko Berberski (Aditi Staffing LLC) via
Scons-users pisze:
> Say a /foo/src/place_1/SConscript
>
> Registers env.Command('FStar_Parser_Parse.ml', File('parse.mly'), generate_fstar_parser_parse_ml)
>
> The paths used for registration are SConscript-relative but when the action (meaning a Python function in this context) runs it "sees" SConstuct-relative path, say  /foo/src/.
>
> Is there a systematic way keep such action (and transitively everything registered by a given SConscript) in the folder where that SConscript is?
>
> I know that an action could do something like target[0].get_path() but then it has to parse which is error prone.
>
> Would adding ... ,chdir=1) be the way to achieve that? Would the same hold for env.Builder ? Some other builders/pseudo-builders ? Some other command-arg that would be for SConscript-relativ path (if chdir=1 means target-relative path) ?
>
> Is there something like a list of additional args that are actually commands? Is there a way to pass additional key=val args that would reach the action at the time of its running?
>

I remember, I was struggling with similar problems in one of my tools.
Maybe looking through the following code will help?

https://github.com/ptomulik/scons-tool-gnuplot/blob/master/gnuplot/__init__.py

Just look for _GplotRelTo (how it's implemented and used).

Regards!


--
Pawel Tomulik
_______________________________________________
Scons-users mailing list
Scons-users at scons.org<mailto:Scons-users at scons.org>
https://pairlist4.pair.net/mailman/listinfo/scons-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20170622/08ec3501/attachment-0001.html>


More information about the Scons-users mailing list