[scan-build] Make scan-build work whether it's installed or not

llvm-svn: 253074
This commit is contained in:
Jonathan Roelofs 2015-11-13 20:34:15 +00:00
parent 1f1c5a7b44
commit 814aa25a92
15 changed files with 28 additions and 21 deletions

View File

@ -32,11 +32,11 @@ if(CLANG_INSTALL_SCANBUILD)
COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_BINARY_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/${BinFile}
${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile}
${CMAKE_BINARY_DIR}/bin/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${BinFile})
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
install(PROGRAMS ${BinFile} DESTINATION bin)
install(PROGRAMS bin/${BinFile} DESTINATION bin)
endforeach()
foreach(LibexecFile ${LibexecFiles})
@ -44,11 +44,11 @@ if(CLANG_INSTALL_SCANBUILD)
COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_BINARY_DIR}/libexec
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/${LibexecFile}
${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile}
${CMAKE_BINARY_DIR}/libexec/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${LibexecFile})
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile})
list(APPEND Depends ${CMAKE_BINARY_DIR}/libexec/${LibexecFile})
install(PROGRAMS ${LibexecFile} DESTINATION libexec)
install(PROGRAMS libexec/${LibexecFile} DESTINATION libexec)
endforeach()
foreach(ManPage ${ManPages})
@ -56,11 +56,11 @@ if(CLANG_INSTALL_SCANBUILD)
COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_BINARY_DIR}/share/man/man1
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/${ManPage}
${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}
${CMAKE_BINARY_DIR}/share/man/man1/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${ManPage})
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage})
list(APPEND Depends ${CMAKE_BINARY_DIR}/share/man/man1/${ManPage})
install(PROGRAMS ${ManPage} DESTINATION share/man/man1)
install(PROGRAMS man/${ManPage} DESTINATION share/man/man1)
endforeach()
foreach(ShareFile ${ShareFiles})
@ -68,11 +68,11 @@ if(CLANG_INSTALL_SCANBUILD)
COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_BINARY_DIR}/share/scan-build
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/share/${ShareFile}
${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile}
${CMAKE_BINARY_DIR}/share/scan-build/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/${ShareFile})
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile})
list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile})
install(FILES share/${ShareFile} DESTINATION share/scan-build)
install(FILES share/scan-build/${ShareFile} DESTINATION share/scan-build)
endforeach()
add_custom_target(scan-build ALL DEPENDS ${Depends})

View File

@ -33,18 +33,18 @@ endif
all:: $(InstallTargets)
$(ToolDir)/%: % Makefile $(ToolDir)/.dir
$(ToolDir)/%: bin/% Makefile $(ToolDir)/.dir
$(Echo) "Copying $(notdir $<) to the 'bin' directory..."
$(Verb)cp $< $@
$(Verb)chmod +x $@
$(LibexecDir)/%: % Makefile $(LibexecDir)/.dir
$(LibexecDir)/%: libexec/% Makefile $(LibexecDir)/.dir
$(Echo) "Copying $(notdir $<) to the 'libexec' directory..."
$(Verb)cp $< $@
$(Verb)chmod +x $@
$(ShareDir)/man/man1/%: % Makefile $(ShareDir)/man/man1/.dir
$(Echo) "Copying $(notdir $<) to the 'share' directory..."
$(ShareDir)/man/man1/%: man/% Makefile $(ShareDir)/man/man1/.dir
$(Echo) "Copying $(notdir $<) to the 'man' directory..."
$(Verb)cp $< $@
$(ShareDir)/scan-build/%: share/% Makefile $(ShareDir)/scan-build/.dir

View File

@ -1818,6 +1818,7 @@ if (defined $Options{OutputFormat}) {
Diag "Viewing analysis results in '$Options{OutputDir}' using scan-view.\n";
my $ScanView = Cwd::realpath("$RealBin/scan-view");
if (! -x $ScanView) { $ScanView = "scan-view"; }
if (! -x $ScanView) { $ScanView = Cwd::realpath("$RealBin/../../scan-view/bin/scan-view"); }
exec $ScanView, "$Options{OutputDir}";
}

View File

@ -17,11 +17,11 @@ if(CLANG_INSTALL_SCANVIEW)
COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_BINARY_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/${BinFile}
${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile}
${CMAKE_BINARY_DIR}/bin/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${BinFile})
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
install(PROGRAMS ${BinFile} DESTINATION bin)
install(PROGRAMS bin/${BinFile} DESTINATION bin)
endforeach()
foreach(ShareFile ${ShareFiles})

View File

@ -26,7 +26,7 @@ endif
all:: $(InstallTargets)
$(ToolDir)/%: % Makefile $(ToolDir)/.dir
$(ToolDir)/%: bin/% Makefile $(ToolDir)/.dir
$(Echo) "Copying $(notdir $<) to the 'bin' directory..."
$(Verb)cp $< $@
$(Verb)chmod +x $@

View File

@ -56,7 +56,13 @@ def start_browser(port, options):
webbrowser.open(url)
def run(port, options, root):
sys.path.append(os.path.dirname(__file__) + "/../share/scan-view")
# 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,