On 05/04/2017 11:13 AM, Nash, George wrote:
> I have been using scons for years and I have seen very few instances that
> using '/' for path has caused issues.
>
> Also you can get the root file for a path anytime using env.Dir("#"). This
> returns a scons node if you need the string a string you can
> Call str(env.Dir('#')).
>
> In general I am happy to use linux style '/' paths for all paths unless an
> issue is discovered and in those cases use os.path.join.
>
> Every time I have seen an issue using '/' in scons was in a builder for a 3rd
> party tool. I just fixed the builder.
>
> George
My question was whether the hash syntax applied to only paths
specifically passed to an SCons method, like SConscript() calls. It
seems it applies more widely. The scons manual page hints at it though
it's not quite as explicit as I might like - flags which are going to be
passed to compilers seem to be expanded too.
===
Target and source file names that are not absolute path names (that is,
do not begin with / on POSIX systems or \ on Windows systems, with or
without an optional drive letter) are interpreted relative to the
directory containing the SConscript file being read. An initial # (hash
mark) on a path name means that the rest of the file name is interpreted
relative to the directory containing the top-level SConstruct file, even
if the # is followed by a directory separator character (slash or
backslash).
===
there are plenty of examples in our codebase of using the shortcut in
setting things like setting CPPPATH, so I think it's pretty clear that
works:
resource/csdk/security/SConscript, for example:
libocsrm_env.PrependUnique(CPPPATH = [
'#/extlibs/mbedtls/mbedtls/include',
'#/resource/csdk/logger/include',
'#/resource/c_common/ocrandom/include',
...
As a first step I do have a change that aligns only the calls to
SConscript, but it looks like plenty more could be done on this.