@@ -2881,6 +2881,112 @@ strings of white-space characters as the delimiter
2881
2881
(similar to the &Python; string <function >split</function >
2882
2882
method, but succeeds even if the input isn't a string).</para >
2883
2883
2884
+ <para >
2885
+ &SCons; can resolve paths to sources and targets
2886
+ specified in several different forms.
2887
+ The <parameter >target</parameter > and
2888
+ <parameter >source</parameter > arguments
2889
+ can be scalar (string or Node) or a collection (of strings or Nodes).
2890
+ </para >
2891
+ <itemizedlist >
2892
+ <listitem >
2893
+ <para >
2894
+ Nodes always work,
2895
+ as they are the result of a previous successful path resolution;
2896
+ if a path string is resolved correctly it is stored
2897
+ internally as a Node in the dependency graph.
2898
+ </para >
2899
+ </listitem >
2900
+ <listitem >
2901
+ <para >
2902
+ Plain file names (no pathname separators)
2903
+ are searched for in the current directory.
2904
+ </para >
2905
+ </listitem >
2906
+ <listitem >
2907
+ <para >
2908
+ Absolute paths (begin with a pathname separator)
2909
+ are resolved by walking the path components
2910
+ starting from root of the filesystem or current volume.
2911
+ </para >
2912
+ </listitem >
2913
+ <listitem >
2914
+ <para >
2915
+ Relative paths (no leading pathname separator)
2916
+ are resolved by walking the path components
2917
+ starting from the current directory.
2918
+ </para >
2919
+ </listitem >
2920
+ <listitem >
2921
+ <para >
2922
+ Top-relative paths are relative paths whose first character
2923
+ is <emphasis role =" bold" >#</emphasis >.
2924
+ They are walked starting from the project top-level directory
2925
+ (usually, the directory where the &SConstruct; file is found).
2926
+ Top-relative paths are always relative paths,
2927
+ so the initial character can be followed by a pathname separator,
2928
+ which is ignored and does not affect resolution.
2929
+ </para >
2930
+ </listitem >
2931
+ <listitem >
2932
+ <para >
2933
+ UNC paths (Windows) start with exactly two pathname separators.
2934
+ They take the form <literal >\\server_name\share_name\file_path</literal >.
2935
+ The <varname >file_path</varname > portion is looked up as an
2936
+ absolute path starting from the root of the
2937
+ resource described by <literal >\\server_name\share_name</literal >.
2938
+ Since UNC paths are never relative,
2939
+ the top-relative path form does not apply.
2940
+ </para >
2941
+ </listitem >
2942
+ <listitem >
2943
+ <para >
2944
+ URL-style strings and &Python; <systemitem >pathlib</systemitem >
2945
+ objects are not recognized.
2946
+ </para >
2947
+ </listitem >
2948
+ </itemizedlist >
2949
+
2950
+ <para >
2951
+ The "current directory" for relative path resolution has options.
2952
+ &SCons; by default changes to the directory containing the
2953
+ &SConscript; file (including &SConstruct; ) it is currently processing.
2954
+ Use of the &f-link-SConscriptChdir; function toggles the
2955
+ default behavior off/on.
2956
+ The <parameter >srcdir</parameter > builder argument
2957
+ affects where source file paths are looked for
2958
+ (see details below).
2959
+ Specifying one or more source code repositories via
2960
+ the &f-link-Repository; function or the
2961
+ <link linkend =" opt-repository" ><option >-Y/--repository</option ></link >
2962
+ option tells &SCons; to look additional places
2963
+ after the actual current directory.
2964
+ The concept of current directory changes for targets
2965
+ (and in some cases sources) if a variant directory is set up using
2966
+ the &f-link-VariantDir; function or the <parameter >variant_dir=</parameter >
2967
+ parameter to the &f-link-SConscript; function.
2968
+ These options do not affect top-relative paths.
2969
+ </para >
2970
+
2971
+ <note >
2972
+ <para >
2973
+ On Windows, DOS paths may beging with a volume or drive letter
2974
+ followed by the volume separator (<literal >:</literal >).
2975
+ The remainder of the path is absolute or relative;
2976
+ if the volume specifier is present,
2977
+ resolution starts at the root of the specified drive for absolute paths
2978
+ and the current directory on the specified drive for relative paths.
2979
+ The combination of a drive letter different from the
2980
+ current drive and a relative path is ambiguous:
2981
+ depending on context the current directory on
2982
+ that drive may have been saved from outside the &SCons; process,
2983
+ and is unknown to the &Python; interpreter,
2984
+ so that form should be avoided.
2985
+ Use of a drive letter in the path also precludes
2986
+ the use of the top-relative form.
2987
+ </para >
2988
+ </note >
2989
+
2884
2990
<para >
2885
2991
The following are equivalent examples of calling the
2886
2992
&Program; builder method:
@@ -2896,41 +3002,18 @@ env.Program(target='bar', source=env.Split('bar.c foo.c'))
2896
3002
env.Program('bar', source='bar.c foo.c'.split())
2897
3003
</programlisting >
2898
3004
3005
+ <para >Additional examples of source and target paths:</para >
3006
+
3007
+ <note >
2899
3008
<para >
2900
- Sources and targets can be specified as a scalar or as a list,
2901
- composed of either strings or nodes (more on nodes below).
2902
- When specifying path strings,
2903
- &Python; follows the POSIX pathname convention:
2904
- if a string begins with the operating system pathname separator
2905
- (on Windows both the slash and backslash separator are accepted,
2906
- and any leading drive specifier is ignored for
2907
- the determination) it is considered an absolute path,
2908
- otherwise it is a relative path.
2909
- If the path string contains no separator characters,
2910
- it is searched for as a file in the current directory. If it
2911
- contains separator characters, the search follows down
2912
- from the starting point, which is the top of the directory tree for
2913
- an absolute path and the current directory for a relative path.
2914
- The "current directory" in this context is the directory
2915
- of the &SConscript; file currently being processed.
2916
- </para >
2917
-
2918
- <para >
2919
- &SCons; also recognizes a third way to specify
2920
- path strings: if the string begins with
2921
- the <emphasis role =" bold" >#</emphasis > character it is
2922
- <firstterm >top-relative</firstterm > - it works like a relative path, but the
2923
- search follows down from the project top directory rather than
2924
- from the current directory. The <emphasis role =" bold" >#</emphasis >
2925
- can optionally be followed by a pathname separator,
2926
- which is ignored if found in that position.
2927
- Top-relative paths only work in places where &scons; will
2928
- interpret the path (see some examples below). To be
2929
- used in other contexts the string will need to be converted
2930
- to a relative or absolute path first.
3009
+ Top-relative paths <emphasis role =" bold" >only</emphasis > work
3010
+ where &SCons; will interpret the path (see examples).
3011
+ To be used in other contexts the string must first be converted
3012
+ to a relative or absolute path.
3013
+ A suitable string can be extracted from the Node
3014
+ created from the top-relative path.
2931
3015
</para >
2932
-
2933
- <para >Examples:</para >
3016
+ </note >
2934
3017
2935
3018
<programlisting language =" python" >
2936
3019
# The comments describing the targets that will be built
0 commit comments