5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 __revision__
= "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
30 test
= TestSCons
.TestSCons()
32 # Right now, due to interaction with external quoting conventions,
33 # we do NOT actually support arbitrary characters in file names.
34 # (For example, double-quotes in a file name on POSIX break due
35 # to interaction with the "sh -c" quoting conventions.)
37 # This is a tough nut to crack, though. Right now, we use the
38 # external command interpreters so we don't have to roll our own
39 # parsing and interpretation of redirection and piping. But that
40 # means we have to find ways to work with *all* of their quoting
44 return "|" + c
+ "|\n"
48 if sys
.platform
== 'win32':
49 invalid_chars
= set(invalid_chars
)
51 # See the 'naming conventions' section of
52 # https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
53 invalid_chars
.update([ chr(c
) for c
in range(32) ])
54 invalid_chars
.update(r
'\/:*?"<>|')
55 invalid_chars
.update(chr(127))
57 # Win32 filesystems are case insensitive so don't do half the alphabet.
59 invalid_chars
.update(string
.ascii_lowercase
)
61 # See the 'naming conventions' section of
62 # https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
64 return c
in invalid_chars
65 def invalid_leading_char(c
):
66 # the hash character as a leading character is interpreted to mean the project root
68 def invalid_trailing_char(c
):
70 commandString
= "copy $SOURCE $TARGET"
72 invalid_chars
= set(invalid_chars
)
73 invalid_chars
.add(chr(10))
74 invalid_chars
.add(chr(13))
75 invalid_chars
.add(chr(92)) # forward slash (dirsep)
76 invalid_chars
.add(chr(96)) # backtick
80 return c
in invalid_chars
81 def invalid_leading_char(c
):
82 # the hash character as a leading character is interpreted to mean the project root
84 def invalid_trailing_char(c
):
86 commandString
= "cp $SOURCE $TARGET"
88 goodChars
= [ chr(c
) for c
in range(1, 128) if not bad_char(chr(c
)) ]
90 def get_filename(ftype
,c
):
91 return ftype
+"%d"%ord(c
[-1])+c
+ftype
94 test
.write(get_filename("in",c
), contents(c
))
96 def create_command(a
, b
, c
):
99 return 'env.Command("' + a
+ get_filename('',c
) + b
+ '", "'+get_filename("in",c
)+ '","' + commandString
+ '")'
101 sconstruct
= [ 'import sys', 'env = Environment(tools=[])' ]
107 infile
= get_filename("in",c
)
108 if not invalid_leading_char(c
):
109 sconstruct
.append(create_command(False, True, c
))
110 sconstruct
.append(create_command(True, True, c
))
111 if not invalid_trailing_char(c
):
112 sconstruct
.append(create_command(True, False, c
))
113 test
.write('SConstruct', '\n'.join(sconstruct
))
115 test
.run(arguments
= '.')
118 # print "Checking %d "%ord(c)
120 c_str
= ("%d"%ord(c
[-1]))+c
121 if not invalid_leading_char(c
):
122 test
.must_match(c_str
+ "out", contents(c
))
123 test
.must_match("out" + c_str
+ "out", contents(c
))
124 if not invalid_trailing_char(c
):
125 test
.must_match("out" + c_str
, contents(c
))
131 # indent-tabs-mode:nil
133 # vim: set expandtab tabstop=4 shiftwidth=4: