Re: File / Dir relative paths and SConscriptChdir

Bill Deegan <[email protected]>
Newsgroups gmane.comp.programming.tools.scons.user
Message-ID <CAEyG4CHmmLpkzBa06WsgpwDKKFo3YARLtmdEAxSA1K0d9vxBTg@mail.gmail.com>
Perhaps you can explain what you're actually trying to do, rather than
providing a toy example?
That will help provide more context correct help.

On Thu, Sep 6, 2018 at 4:23 PM RW via Scons-users <[email protected]>
wrote:

> Hi,
> I've got another question, this is over the use of SConscriptChdir
> such as env.SConscriptChdir(0)
> from what I can gather when specifying a File or Dir object or making a
> call to a Command builder at least which will automatically convert a
> string target to a File object.
>
> The File / Dir object will always be relative to the current SConstruct
> file.
> Not relative to the originating SConstruct file (which is what I'm trying
> to do)
>
> To give an example
>
> src1\test1.txt - empty test file
> src1\test2.txt - empty test file
>
> src1\SConstruct
> ```
> import os
>
> EnsureSConsVersion(3, 0, 0)
>
> # Setup the construction env
> env = Environment(ENV={'PATH': os.environ['PATH']})
>
> # Set working directory to not change
> env.SConscriptChdir(0)
>
> # Load in an external script
> SConscript('../src2/testsubscript.py', {'env': env})
> ```
>
> src2\SConstruct
> ```
> # Import the scons environment from the calling script
> Import('env')
>
> def build_test(target, source, env):
>     # At this point the 'testfile.txt' will be automatically changed to a
> File class by SCons
>
>     # print the path scons thinks this file is located at
>     print(target[0].path)
>
> tgt = env.Command(File('testfile.txt'), [], build_test)
> env.Default(tgt)
>
> tgt2 = env.Command('testfile2.txt', [], build_test)
> env.Default(tgt2)
>
> # Even though SConscriptChdir is set to 0 in the originating env, File
> uses the current script as it's reference point
> # D:\Temp\testproject\src2\testfile.txt
> # D:\Temp\testproject\src2\testfile2.txt
> ```
>
> Is this expected behaviour?
> perhaps SConscriptChdir only influences when calling exe's rather than the
> use of File or Dir
> is there some public API way of setting the current directory for File /
> Dir calls?
> thats not the directory of the current SConsscript
> since builders wrap everything in a File automatically, it might mean I
> have to make sure all file paths are absolute before hand.
>
> Many Thanks
> Richard
>
> _______________________________________________
> Scons-users mailing list
> [email protected]
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>

_______________________________________________
Scons-users mailing list
[email protected]
https://pairlist4.pair.net/mailman/listinfo/scons-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.