The platform support wiki page<https://wiki.iotivity.org/platform_support> has
this:
Use of os.path.join in SConscript files
The path separator differs across platforms ('/' vs '\'). There has been some
confusion about when to use os.path.join in SConscript files. In short:
1. Use os.path.join when constructing paths passed as arguments to a
compiler, such as when constructing CPPPATH or LIBS
2. Don't use os.path.join when constructing paths interpreted by Python
itself, such as via an env.SConscript() call
Point 2 is what you're asking about, so no objection that's already the
guidance.
Separately point 1 might need elaboration since the "#..." syntax of a file
relative to the SConstruct file seems to be processed by scons, so the part
about "when constructing CPPPATH" may not be correct, maybe scons pre-processes
it before passing it to the compiler, in which case os.path.join isn't needed
there either.
If someone can explain how "#..." works for CPPPATH, I'm happy to update point
1 above.
But for your question about point 2, please go ahead.
Dave
-----Original Message-----
From: iotivity-dev-bounces at lists.iotivity.org
[mailto:[email protected]] On Behalf Of Mats Wichmann
Sent: Wednesday, May 3, 2017 5:10 PM
To: IoTivity Developer List <iotivity-dev at lists.iotivity.org>
Subject: [dev] sconscript consistency (#1 or potentially several)
There are a number of scripts that do some things the hard way. Here's one
example:
in bridging/SConscript:
SConscript(os.path.join(env.get('SRC_DIR'), 'extlibs', 'rapidjson',
'SConscript'))
I was in support of this kind of change a while back when asked to review a few
gerrit changes, so I'll take a share of the blame.
os.path.join is a good way for python to join path components together in a
portable way.
fetching SRC_DIR is correct for getting the top of the tree.
but neither are needed in this context: the path is not for generic usage,
rather it's a path given to scons, which does the right thing for the host OS
in question without the extra complexity. And there's scons shorthand for top
of the tree: a leading # sign is equivalent to a reference to the directory
where the SConstruct file lives (namely, top of tree).
So the scons-appropriate way to express the above is:
SConscript('#extlibs/rapidjson/SConscript')
Many of the other scripts use this form, and consistency would be easier for
new developers to understand, among other benefits.
Anyone object if I push a changeset aligning the SConscript calls?
_______________________________________________
iotivity-dev mailing list
iotivity-dev at lists.iotivity.org<mailto:iotivity-dev at lists.iotivity.org>
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.iotivity.org%2Fmailman%2Flistinfo%2Fiotivity-dev&data=02%7C01%7Cdthaler%40microsoft.com%7C37d069ca328844f48f9a08d49281e025%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636294533962689719&sdata=QgVJ5H5ePdMu2IBQdgHwpIf9fNjFj1gTlPlJ41dVR1c%3D&reserved=0
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.iotivity.org/pipermail/iotivity-dev/attachments/20170504/de139518/attachment.html>