From 86e3196c88afaae11c1a3a3ec0fc4713f4b6b562 Mon Sep 17 00:00:00 2001
From: Jonathan Roelofs <jonathan@codesourcery.com>
Date: Fri, 13 Nov 2015 19:56:07 +0000
Subject: [PATCH] [scan-build] Move non user-facing utilities to share

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253068 91177308-0d34-0410-b5e6-96231b3b80d8
---
 tools/scan-build/CMakeLists.txt          | 10 +++++-----
 tools/scan-build/scan-build              |  4 ++--
 tools/scan-view/CMakeLists.txt           |  8 ++++----
 tools/scan-view/Makefile                 |  8 ++++----
 tools/scan-view/scan-view                |  3 +++
 tools/scan-view/{ => share}/Reporter.py  |  0
 tools/scan-view/{ => share}/ScanView.py  |  0
 tools/scan-view/{ => share}/startfile.py |  0
 8 files changed, 18 insertions(+), 15 deletions(-)
 rename tools/scan-view/{ => share}/Reporter.py (100%)
 rename tools/scan-view/{ => share}/ScanView.py (100%)
 rename tools/scan-view/{ => share}/startfile.py (100%)

diff --git a/tools/scan-build/CMakeLists.txt b/tools/scan-build/CMakeLists.txt
index df0688b710b..95ab5f73b58 100644
--- a/tools/scan-build/CMakeLists.txt
+++ b/tools/scan-build/CMakeLists.txt
@@ -64,15 +64,15 @@ if(CLANG_INSTALL_SCANBUILD)
   endforeach()
 
   foreach(ShareFile ${ShareFiles})
-    add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/share/scan-view/${ShareFile}
+    add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile}
                        COMMAND ${CMAKE_COMMAND} -E make_directory
-                         ${CMAKE_BINARY_DIR}/share/scan-view
+                         ${CMAKE_BINARY_DIR}/share/scan-build
                        COMMAND ${CMAKE_COMMAND} -E copy
                          ${CMAKE_CURRENT_SOURCE_DIR}/share/${ShareFile}
-                         ${CMAKE_BINARY_DIR}/share/scan-view/
+                         ${CMAKE_BINARY_DIR}/share/scan-build/
                        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)
+    list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile})
+    install(FILES share/${ShareFile} DESTINATION share/scan-build)
   endforeach()
 
   add_custom_target(scan-build ALL DEPENDS ${Depends})
diff --git a/tools/scan-build/scan-build b/tools/scan-build/scan-build
index be6056ccb9d..f37b412498e 100755
--- a/tools/scan-build/scan-build
+++ b/tools/scan-build/scan-build
@@ -462,7 +462,7 @@ sub CopyFiles {
 
   my $Dir = shift;
 
-  my $JS = Cwd::realpath("$RealBin/sorttable.js");
+  my $JS = Cwd::realpath("$RealBin/../share/scan-build/sorttable.js");
 
   DieDiag("Cannot find 'sorttable.js'.\n")
     if (! -r $JS);
@@ -472,7 +472,7 @@ sub CopyFiles {
   DieDiag("Could not copy 'sorttable.js' to '$Dir'.\n")
     if (! -r "$Dir/sorttable.js");
 
-  my $CSS = Cwd::realpath("$RealBin/scanview.css");
+  my $CSS = Cwd::realpath("$RealBin/../share/scan-build/scanview.css");
 
   DieDiag("Cannot find 'scanview.css'.\n")
     if (! -r $CSS);
diff --git a/tools/scan-view/CMakeLists.txt b/tools/scan-view/CMakeLists.txt
index 5e8eff279d2..969d519d8a2 100644
--- a/tools/scan-view/CMakeLists.txt
+++ b/tools/scan-view/CMakeLists.txt
@@ -1,12 +1,12 @@
 option(CLANG_INSTALL_SCANVIEW "Install the scan-view tool" ON)
 
 set(BinFiles
-      Reporter.py
-      ScanView.py
-      scan-view
-      startfile.py)
+      scan-view)
 
 set(ShareFiles
+      ScanView.py
+      Reporter.py
+      startfile.py
       FileRadar.scpt
       GetRadarVersion.scpt
       bugcatcher.ico)
diff --git a/tools/scan-view/Makefile b/tools/scan-view/Makefile
index 2d4380cac3d..e980b382178 100644
--- a/tools/scan-view/Makefile
+++ b/tools/scan-view/Makefile
@@ -15,10 +15,10 @@ include $(CLANG_LEVEL)/Makefile
 CLANG_INSTALL_SCANVIEW ?= 1
 
 ifeq ($(CLANG_INSTALL_SCANVIEW), 1)
-  InstallTargets := $(ToolDir)/Reporter.py \
-                    $(ToolDir)/ScanView.py \
-                    $(ToolDir)/scan-view \
-                    $(ToolDir)/startfile.py \
+  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
diff --git a/tools/scan-view/scan-view b/tools/scan-view/scan-view
index fb27da69888..797db637ae3 100755
--- a/tools/scan-view/scan-view
+++ b/tools/scan-view/scan-view
@@ -4,6 +4,8 @@
 """
 
 import sys
+import imp
+import os
 import posixpath
 import thread
 import time
@@ -54,6 +56,7 @@ def start_browser(port, options):
     webbrowser.open(url)
 
 def run(port, options, root):
+    sys.path.append(os.path.dirname(__file__) + "/../share/scan-view")
     import ScanView
     try:
         print 'Starting scan-view at: http://%s:%d'%(options.host,
diff --git a/tools/scan-view/Reporter.py b/tools/scan-view/share/Reporter.py
similarity index 100%
rename from tools/scan-view/Reporter.py
rename to tools/scan-view/share/Reporter.py
diff --git a/tools/scan-view/ScanView.py b/tools/scan-view/share/ScanView.py
similarity index 100%
rename from tools/scan-view/ScanView.py
rename to tools/scan-view/share/ScanView.py
diff --git a/tools/scan-view/startfile.py b/tools/scan-view/share/startfile.py
similarity index 100%
rename from tools/scan-view/startfile.py
rename to tools/scan-view/share/startfile.py
-- 
GitLab