[Scons-users] Scons-users Digest, Vol 133, Issue 9

Mats Wichmann mats at wichmann.us
Sun Sep 11 09:50:18 EDT 2022


On 9/11/22 07:36, Lan Yang wrote:
> 
> Hi Bill:
> The Scons version I used was v3.1.0. Thank you.
> 
> Hi Mats
> Thank you for your notation. I've learned a lot from your words.
> I've changed the code " srcs = Glob(PATTERN) "  in my project to  "srcs 
> = sorted(Glob(PATTERN, key=lambda t: t.name <http://t.name/>)) " and 
> tested it.
> The test result is ... the change won't make the link order stable.
> I think it's because there are several " srcs = Glob(PATTERN) "  in 
> different Sconscript files of my project.
> Would you please offer a demo project, in which this change 
> (sorted(Glob....) works well.?
> 
> Thank you all.
> 
> Best regards
> Lan

Well... it turns out after I did some further research, I was wrong: 
results from Glob() are sorted already, so it's not a surprise this does 
not help.  However, results from Python's glob.glob() are not sorted.  I 
don't know enough about the project yet to know if they are a factor 
here, but I see from some grepping in rt-thread that

tools/kconfiglib.py uses iglob, but sorts it.
tools/eclipse.py and tools/building.py use glob, and do not appear to 
sort the results.

Perhaps the problem stems from something generated in the latter two?

 From kconfiglib we can see this telling comment:

     # - glob() doesn't support globbing relative to a directory, so
     #   we need to prepend $srctree to 'pattern'. Use join()
     #   instead of '+' so that an absolute path in 'pattern' is
     #   preserved.
     #
     # - Sort the glob results to ensure a consistent ordering of
     #   Kconfig symbols, which indirectly ensures a consistent
     #   ordering in e.g. .config files
     filenames = sorted(iglob(join(self._srctree_prefix, pattern)))

Hope this is of some use....





More information about the Scons-users mailing list