summaryrefslogtreecommitdiffstats
path: root/tools/scan-view
diff options
context:
space:
mode:
Diffstat (limited to 'tools/scan-view')
-rw-r--r--tools/scan-view/CMakeLists.txt41
-rw-r--r--tools/scan-view/Makefile37
-rwxr-xr-xtools/scan-view/bin/scan-view143
-rwxr-xr-xtools/scan-view/scan-view131
-rw-r--r--tools/scan-view/share/FileRadar.scpt (renamed from tools/scan-view/Resources/FileRadar.scpt)bin18418 -> 18418 bytes
-rw-r--r--tools/scan-view/share/GetRadarVersion.scpt (renamed from tools/scan-view/Resources/GetRadarVersion.scpt)0
-rw-r--r--tools/scan-view/share/Reporter.py (renamed from tools/scan-view/Reporter.py)4
-rw-r--r--tools/scan-view/share/ScanView.py (renamed from tools/scan-view/ScanView.py)4
-rw-r--r--tools/scan-view/share/bugcatcher.ico (renamed from tools/scan-view/Resources/bugcatcher.ico)bin318 -> 318 bytes
-rw-r--r--tools/scan-view/share/startfile.py (renamed from tools/scan-view/startfile.py)0
10 files changed, 225 insertions, 135 deletions
diff --git a/tools/scan-view/CMakeLists.txt b/tools/scan-view/CMakeLists.txt
new file mode 100644
index 0000000..b305ca5
--- /dev/null
+++ b/tools/scan-view/CMakeLists.txt
@@ -0,0 +1,41 @@
+option(CLANG_INSTALL_SCANVIEW "Install the scan-view tool" ON)
+
+set(BinFiles
+ scan-view)
+
+set(ShareFiles
+ ScanView.py
+ Reporter.py
+ startfile.py
+ FileRadar.scpt
+ GetRadarVersion.scpt
+ bugcatcher.ico)
+
+if(CLANG_INSTALL_SCANVIEW)
+ foreach(BinFile ${BinFiles})
+ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bin/${BinFile}
+ COMMAND ${CMAKE_COMMAND} -E make_directory
+ ${CMAKE_BINARY_DIR}/bin
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile}
+ ${CMAKE_BINARY_DIR}/bin/
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
+ list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
+ install(PROGRAMS bin/${BinFile} DESTINATION bin)
+ endforeach()
+
+ foreach(ShareFile ${ShareFiles})
+ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/share/scan-view/${ShareFile}
+ COMMAND ${CMAKE_COMMAND} -E make_directory
+ ${CMAKE_BINARY_DIR}/share/scan-view
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_CURRENT_SOURCE_DIR}/share/${ShareFile}
+ ${CMAKE_BINARY_DIR}/share/scan-view/
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/${ShareFile})
+ list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-view/${ShareFile})
+ install(FILES share/${ShareFile} DESTINATION share/scan-view)
+ endforeach()
+
+ add_custom_target(scan-view ALL DEPENDS ${Depends})
+ set_target_properties(scan-view PROPERTIES FOLDER "Misc")
+endif()
diff --git a/tools/scan-view/Makefile b/tools/scan-view/Makefile
new file mode 100644
index 0000000..37e4404
--- /dev/null
+++ b/tools/scan-view/Makefile
@@ -0,0 +1,37 @@
+##===- tools/scan-view/Makefile ----------------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+CLANG_LEVEL := ../..
+
+include $(CLANG_LEVEL)/../../Makefile.config
+include $(CLANG_LEVEL)/Makefile
+
+CLANG_INSTALL_SCANVIEW ?= 1
+
+ifeq ($(CLANG_INSTALL_SCANVIEW), 1)
+ InstallTargets := $(ToolDir)/scan-view \
+ $(ShareDir)/scan-view/Reporter.py \
+ $(ShareDir)/scan-view/ScanView.py \
+ $(ShareDir)/scan-view/startfile.py \
+ $(ShareDir)/scan-view/FileRadar.scpt \
+ $(ShareDir)/scan-view/GetRadarVersion.scpt \
+ $(ShareDir)/scan-view/bugcatcher.ico
+endif
+
+all:: $(InstallTargets)
+
+$(ToolDir)/%: bin/% Makefile $(ToolDir)/.dir
+ $(Echo) "Copying $(notdir $<) to the 'bin' directory..."
+ $(Verb)cp $< $@
+ $(Verb)chmod +x $@
+
+$(ShareDir)/scan-view/%: share/% Makefile $(ShareDir)/scan-view/.dir
+ $(Echo) "Copying $(notdir $<) to the 'share' directory..."
+ $(Verb)cp $< $@
+
diff --git a/tools/scan-view/bin/scan-view b/tools/scan-view/bin/scan-view
new file mode 100755
index 0000000..1b6e8ba
--- /dev/null
+++ b/tools/scan-view/bin/scan-view
@@ -0,0 +1,143 @@
+#!/usr/bin/env python
+
+"""The clang static analyzer results viewer.
+"""
+
+import sys
+import imp
+import os
+import posixpath
+import thread
+import time
+import urllib
+import webbrowser
+
+# How long to wait for server to start.
+kSleepTimeout = .05
+kMaxSleeps = int(60 / kSleepTimeout)
+
+# Default server parameters
+
+kDefaultHost = '127.0.0.1'
+kDefaultPort = 8181
+kMaxPortsToTry = 100
+
+###
+
+
+def url_is_up(url):
+ try:
+ o = urllib.urlopen(url)
+ except IOError:
+ return False
+ o.close()
+ return True
+
+
+def start_browser(port, options):
+ import urllib
+ import webbrowser
+
+ url = 'http://%s:%d' % (options.host, port)
+
+ # Wait for server to start...
+ if options.debug:
+ sys.stderr.write('%s: Waiting for server.' % sys.argv[0])
+ sys.stderr.flush()
+ for i in range(kMaxSleeps):
+ if url_is_up(url):
+ break
+ if options.debug:
+ sys.stderr.write('.')
+ sys.stderr.flush()
+ time.sleep(kSleepTimeout)
+ else:
+ print >> sys.stderr, 'WARNING: Unable to detect that server started.'
+
+ if options.debug:
+ print >> sys.stderr, '%s: Starting webbrowser...' % sys.argv[0]
+ webbrowser.open(url)
+
+
+def run(port, options, root):
+ # Prefer to look relative to the installed binary
+ share = os.path.dirname(__file__) + "/../share/scan-view"
+ if not os.path.isdir(share):
+ # Otherwise look relative to the source
+ share = os.path.dirname(__file__) + "/../../scan-view/share"
+ sys.path.append(share)
+
+ import ScanView
+ try:
+ print 'Starting scan-view at: http://%s:%d' % (options.host,
+ port)
+ print ' Use Ctrl-C to exit.'
+ httpd = ScanView.create_server((options.host, port),
+ options, root)
+ httpd.serve_forever()
+ except KeyboardInterrupt:
+ pass
+
+
+def port_is_open(port):
+ import SocketServer
+ try:
+ t = SocketServer.TCPServer((kDefaultHost, port), None)
+ except:
+ return False
+ t.server_close()
+ return True
+
+
+def main():
+ import argparse
+ parser = argparse.ArgumentParser(description="The clang static analyzer "
+ "results viewer.")
+ parser.add_argument("root", metavar="<results directory>", type=str)
+ parser.add_argument(
+ '--host', dest="host", default=kDefaultHost, type=str,
+ help="Host interface to listen on. (default=%s)" % kDefaultHost)
+ parser.add_argument('--port', dest="port", default=None, type=int,
+ help="Port to listen on. (default=%s)" % kDefaultPort)
+ parser.add_argument("--debug", dest="debug", default=0,
+ action="count",
+ help="Print additional debugging information.")
+ parser.add_argument("--auto-reload", dest="autoReload", default=False,
+ action="store_true",
+ help="Automatically update module for each request.")
+ parser.add_argument("--no-browser", dest="startBrowser", default=True,
+ action="store_false",
+ help="Don't open a webbrowser on startup.")
+ parser.add_argument("--allow-all-hosts", dest="onlyServeLocal",
+ default=True, action="store_false",
+ help='Allow connections from any host (access '
+ 'restricted to "127.0.0.1" by default)')
+ args = parser.parse_args()
+
+ # Make sure this directory is in a reasonable state to view.
+ if not posixpath.exists(posixpath.join(args.root, 'index.html')):
+ parser.error('Invalid directory, analysis results not found!')
+
+ # Find an open port. We aren't particularly worried about race
+ # conditions here. Note that if the user specified a port we only
+ # use that one.
+ if args.port is not None:
+ port = args.port
+ else:
+ for i in range(kMaxPortsToTry):
+ if port_is_open(kDefaultPort + i):
+ port = kDefaultPort + i
+ break
+ else:
+ parser.error('Unable to find usable port in [%d,%d)' %
+ (kDefaultPort, kDefaultPort+kMaxPortsToTry))
+
+ # Kick off thread to wait for server and start web browser, if
+ # requested.
+ if args.startBrowser:
+ t = thread.start_new_thread(start_browser, (port, args))
+
+ run(port, args, args.root)
+
+if __name__ == '__main__':
+ main()
diff --git a/tools/scan-view/scan-view b/tools/scan-view/scan-view
deleted file mode 100755
index fb27da6..0000000
--- a/tools/scan-view/scan-view
+++ /dev/null
@@ -1,131 +0,0 @@
-#!/usr/bin/env python
-
-"""The clang static analyzer results viewer.
-"""
-
-import sys
-import posixpath
-import thread
-import time
-import urllib
-import webbrowser
-
-# How long to wait for server to start.
-kSleepTimeout = .05
-kMaxSleeps = int(60 / kSleepTimeout)
-
-# Default server parameters
-
-kDefaultHost = '127.0.0.1'
-kDefaultPort = 8181
-kMaxPortsToTry = 100
-
-###
-
-def url_is_up(url):
- try:
- o = urllib.urlopen(url)
- except IOError:
- return False
- o.close()
- return True
-
-def start_browser(port, options):
- import urllib, webbrowser
-
- url = 'http://%s:%d'%(options.host, port)
-
- # Wait for server to start...
- if options.debug:
- sys.stderr.write('%s: Waiting for server.' % sys.argv[0])
- sys.stderr.flush()
- for i in range(kMaxSleeps):
- if url_is_up(url):
- break
- if options.debug:
- sys.stderr.write('.')
- sys.stderr.flush()
- time.sleep(kSleepTimeout)
- else:
- print >>sys.stderr,'WARNING: Unable to detect that server started.'
-
- if options.debug:
- print >>sys.stderr,'%s: Starting webbrowser...' % sys.argv[0]
- webbrowser.open(url)
-
-def run(port, options, root):
- import ScanView
- try:
- print 'Starting scan-view at: http://%s:%d'%(options.host,
- port)
- print ' Use Ctrl-C to exit.'
- httpd = ScanView.create_server((options.host, port),
- options, root)
- httpd.serve_forever()
- except KeyboardInterrupt:
- pass
-
-def port_is_open(port):
- import SocketServer
- try:
- t = SocketServer.TCPServer((kDefaultHost,port),None)
- except:
- return False
- t.server_close()
- return True
-
-def main():
- from optparse import OptionParser
- parser = OptionParser('usage: %prog [options] <results directory>')
- parser.set_description(__doc__)
- parser.add_option(
- '--host', dest="host", default=kDefaultHost, type="string",
- help="Host interface to listen on. (default=%s)" % kDefaultHost)
- parser.add_option(
- '--port', dest="port", default=None, type="int",
- help="Port to listen on. (default=%s)" % kDefaultPort)
- parser.add_option("--debug", dest="debug", default=0,
- action="count",
- help="Print additional debugging information.")
- parser.add_option("--auto-reload", dest="autoReload", default=False,
- action="store_true",
- help="Automatically update module for each request.")
- parser.add_option("--no-browser", dest="startBrowser", default=True,
- action="store_false",
- help="Don't open a webbrowser on startup.")
- parser.add_option("--allow-all-hosts", dest="onlyServeLocal", default=True,
- action="store_false",
- help='Allow connections from any host (access restricted to "127.0.0.1" by default)')
- (options, args) = parser.parse_args()
-
- if len(args) != 1:
- parser.error('No results directory specified.')
- root, = args
-
- # Make sure this directory is in a reasonable state to view.
- if not posixpath.exists(posixpath.join(root,'index.html')):
- parser.error('Invalid directory, analysis results not found!')
-
- # Find an open port. We aren't particularly worried about race
- # conditions here. Note that if the user specified a port we only
- # use that one.
- if options.port is not None:
- port = options.port
- else:
- for i in range(kMaxPortsToTry):
- if port_is_open(kDefaultPort + i):
- port = kDefaultPort + i
- break
- else:
- parser.error('Unable to find usable port in [%d,%d)'%(kDefaultPort,
- kDefaultPort+kMaxPortsToTry))
-
- # Kick off thread to wait for server and start web browser, if
- # requested.
- if options.startBrowser:
- t = thread.start_new_thread(start_browser, (port,options))
-
- run(port, options, root)
-
-if __name__ == '__main__':
- main()
diff --git a/tools/scan-view/Resources/FileRadar.scpt b/tools/scan-view/share/FileRadar.scpt
index 1c74552..1c74552 100644
--- a/tools/scan-view/Resources/FileRadar.scpt
+++ b/tools/scan-view/share/FileRadar.scpt
Binary files differ
diff --git a/tools/scan-view/Resources/GetRadarVersion.scpt b/tools/scan-view/share/GetRadarVersion.scpt
index e69de29..e69de29 100644
--- a/tools/scan-view/Resources/GetRadarVersion.scpt
+++ b/tools/scan-view/share/GetRadarVersion.scpt
diff --git a/tools/scan-view/Reporter.py b/tools/scan-view/share/Reporter.py
index 9560fc1..294e05b 100644
--- a/tools/scan-view/Reporter.py
+++ b/tools/scan-view/share/Reporter.py
@@ -175,7 +175,7 @@ class RadarReporter:
@staticmethod
def isAvailable():
# FIXME: Find this .scpt better
- path = os.path.join(os.path.dirname(__file__),'Resources/GetRadarVersion.scpt')
+ path = os.path.join(os.path.dirname(__file__),'../share/scan-view/GetRadarVersion.scpt')
try:
p = subprocess.Popen(['osascript',path],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -206,7 +206,7 @@ class RadarReporter:
if not componentVersion.strip():
componentVersion = 'X'
- script = os.path.join(os.path.dirname(__file__),'Resources/FileRadar.scpt')
+ script = os.path.join(os.path.dirname(__file__),'../share/scan-view/FileRadar.scpt')
args = ['osascript', script, component, componentVersion, classification, personID, report.title,
report.description, diagnosis, config] + map(os.path.abspath, report.files)
# print >>sys.stderr, args
diff --git a/tools/scan-view/ScanView.py b/tools/scan-view/share/ScanView.py
index ee08baa..7dc0351 100644
--- a/tools/scan-view/ScanView.py
+++ b/tools/scan-view/share/ScanView.py
@@ -73,7 +73,7 @@ kReportReplacements.append((re.compile('<!-- REPORTSUMMARYEXTRA -->'),
###
# Other simple parameters
-kResources = posixpath.join(posixpath.dirname(__file__), 'Resources')
+kShare = posixpath.join(posixpath.dirname(__file__), '../share/scan-view')
kConfigPath = os.path.expanduser('~/.scanview.cfg')
###
@@ -680,7 +680,7 @@ File Bug</h3>
overrides['Radar']['Component Version'] = 'X'
return self.send_report(None, overrides)
elif name=='favicon.ico':
- return self.send_path(posixpath.join(kResources,'bugcatcher.ico'))
+ return self.send_path(posixpath.join(kShare,'bugcatcher.ico'))
# Match directory entries.
if components[-1] == '':
diff --git a/tools/scan-view/Resources/bugcatcher.ico b/tools/scan-view/share/bugcatcher.ico
index 22d39b5..22d39b5 100644
--- a/tools/scan-view/Resources/bugcatcher.ico
+++ b/tools/scan-view/share/bugcatcher.ico
Binary files differ
diff --git a/tools/scan-view/startfile.py b/tools/scan-view/share/startfile.py
index e8fbe2d..e8fbe2d 100644
--- a/tools/scan-view/startfile.py
+++ b/tools/scan-view/share/startfile.py
OpenPOWER on IntegriCloud