3 # Copyright (c) 2010 Martin Decky
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
10 # - Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # - Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 # - The name of the author may not be used to endorse or promote products
16 # derived from this software without specific prior written permission.
18 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 Wrapper for Stanse static checker
40 "uspace/srv/clip/clip.job"
45 print(prname
+ " <ROOT>")
47 def stanse(root
, job
):
48 "Run Stanse on a jobfile"
50 # Convert generic jobfile to Stanse-specific jobfile format
52 inname
= os
.path
.join(root
, job
)
53 outname
= os
.path
.join(root
, "_%s" % os
.path
.basename(job
))
55 if (not os
.path
.isfile(inname
)):
56 print("Unable to open %s" % inname
)
57 print("Did you run \"make precheck\" on the source tree?")
60 inf
= open(inname
, "r")
61 records
= inf
.read().splitlines()
65 for record
in records
:
66 arg
= jobfile
.parse_arg(record
)
71 print("Not enough jobfile record arguments")
81 srcfqname
= os
.path
.join(base
, srcfname
)
82 if (not os
.path
.isfile(srcfqname
)):
83 print("Source %s not found" % srcfqname
)
86 # Only C files are interesting for us
90 output
.append([srcfname
, tgtfname
, base
, options
])
92 outf
= open(outname
, "w")
94 outf
.write("{%s},{%s},{%s},{%s}\n" % (record
[0], record
[1], record
[2], record
[3]))
99 retval
= subprocess
.Popen(['stanse', '--checker', 'ReachabilityChecker', '--jobfile', outname
]).wait()
104 for record
in output
:
105 tmpfile
= os
.path
.join(record
[2], "%s.preproc" % record
[1])
106 if (os
.path
.isfile(tmpfile
)):
115 if (len(sys
.argv
) < 2):
119 rootdir
= os
.path
.abspath(sys
.argv
[1])
120 config
= os
.path
.join(rootdir
, "HelenOS.config")
122 if (not os
.path
.isfile(config
)):
123 print("%s not found." % config
)
124 print("Please specify the path to HelenOS build tree root as the first argument.")
128 if (not stanse(rootdir
, job
)):
130 print("Failed job: %s" % job
)
134 print("All jobs passed")
136 if __name__
== '__main__':