Skip to content

Commit

Permalink
Merge branch 'master' into 11706_color_map_vsi_link_color_map_editor_…
Browse files Browse the repository at this point in the history
…to_color_selection_widget_lineedits

Conflicts:
	Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp

Sort out merge conflict from when we moved setBackgroundColor to the bottom of switchViews, re #11706
  • Loading branch information
FedeMPouzols committed May 29, 2015
2 parents d4deac8 + 10b4c13 commit d489cf7
Show file tree
Hide file tree
Showing 798 changed files with 11,737 additions and 28,355 deletions.
125 changes: 125 additions & 0 deletions Code/Mantid/Build/CMake/Coveralls.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Copyright (C) 2014 Joakim Söderberg <joakim.soderberg@gmail.com>
#


#
# Param _COVERAGE_SRCS A list of source files that coverage should be collected for.
# Param _COVERALLS_UPLOAD Upload the result to coveralls?
#
function(coveralls_setup _COVERAGE_SRCS _COVERALLS_UPLOAD)

if (ARGC GREATER 2)
set(_CMAKE_SCRIPT_PATH ${ARGN})
message("Coveralls: Using alternate CMake script dir: ${_CMAKE_SCRIPT_PATH}")
else()
set(_CMAKE_SCRIPT_PATH ${PROJECT_SOURCE_DIR}/cmake)
endif()

if (NOT EXISTS "${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake")
message(FATAL_ERROR "Coveralls: Missing ${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake")
endif()

if (NOT EXISTS "${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.py")
message(FATAL_ERROR "Coveralls: Missing ${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.py")
endif()

#pass name to a file instead of a list of every source.
set(COVERAGE_SRCS ${_COVERAGE_SRCS})

set(COVERALLS_FILE ${PROJECT_BINARY_DIR}/coveralls.json)

find_package(Git)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --show-toplevel
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE PROJECT_ROOT
OUTPUT_STRIP_TRAILING_WHITESPACE
)

INCLUDE(FindPythonInterp)
add_custom_target(coveralls_generate

# Zero the coverage counters.
COMMAND ${CMAKE_COMMAND}
-P "${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake"

# Run regression tests. Continue even if tests fail.
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure || true

# Generate Gcov and translate it into coveralls JSON.
# We do this by executing an external CMake script.
# (We don't want this to run at CMake generation time, but after compilation and everything has run).
COMMAND ${PYTHON_EXECUTABLE}
${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.py
--COVERAGE_SRCS_FILE="${COVERAGE_SRCS}"
--COVERALLS_OUTPUT_FILE="${COVERALLS_FILE}"
--COV_PATH="${PROJECT_BINARY_DIR}"
--PROJECT_ROOT="${PROJECT_ROOT}"

WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Generating coveralls output..."
)

if (_COVERALLS_UPLOAD)
message("COVERALLS UPLOAD: ON")

find_program(CURL_EXECUTABLE curl)

if (NOT CURL_EXECUTABLE)
message(FATAL_ERROR "Coveralls: curl not found! Aborting")
endif()

add_custom_target(coveralls_upload
# Upload the JSON to coveralls.
COMMAND ${CURL_EXECUTABLE}
-S -F json_file=@${COVERALLS_FILE}
https://coveralls.io/api/v1/jobs

DEPENDS coveralls_generate

WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Uploading coveralls output...")

add_custom_target(coveralls DEPENDS coveralls_upload)
else()
message("COVERALLS UPLOAD: OFF")
add_custom_target(coveralls DEPENDS coveralls_generate)
endif()

endfunction()

macro(coveralls_turn_on_coverage)
if(NOT (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
AND (NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang"))
message(FATAL_ERROR "Coveralls: Compiler ${CMAKE_C_COMPILER_ID} is not GNU gcc! Aborting... You can set this on the command line using CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake <options> ..")
endif()

if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(FATAL_ERROR "Coveralls: Code coverage results with an optimised (non-Debug) build may be misleading! Add -DCMAKE_BUILD_TYPE=Debug")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
endmacro()



24 changes: 24 additions & 0 deletions Code/Mantid/Build/CMake/CoverallsClear.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Copyright (C) 2014 Joakim Söderberg <joakim.soderberg@gmail.com>
#

file(REMOVE_RECURSE ${PROJECT_BINARY_DIR}/*.gcda)

145 changes: 145 additions & 0 deletions Code/Mantid/Build/CMake/CoverallsGenerateGcov.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import json
import os
import sys
import getopt
import subprocess
import re
import copy
import hashlib

def getBranchName(directory):
"""Returns the name of the current git branch"""
return subprocess.check_output(["git","rev-parse","--abbrev-ref","HEAD"],cwd=directory).strip()

def getRemotes(directory):
"""Returns list of remote git repositories"""
gitRemoteOutput = subprocess.check_output(['git','remote','-v'],cwd=directory)
remotes = []
for line in gitRemoteOutput.splitlines():
if '(fetch)' in line:
splitLine = line.split();
remotes.append({'name': splitLine[0].strip(), 'url': splitLine[1].strip()})
return remotes

def gitLogValue(format,directory):
"""Returns git log value specified by format"""
return subprocess.check_output(["git","log","-1","--pretty=format:%"+format],cwd=directory).strip()

def getAllFilesWithExtension(directory,extension):
"""Recursively return a list of all files in directory with specified extension"""
filesWithExtension = []
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith(extension):
filesWithExtension.append(os.path.realpath(os.path.join(root, file)))
return filesWithExtension

def getSourcePathFromGcovFile(gcovFilename):
"""Return the source path corresponding to a .gcov file"""
gcovPath,gcovFilenameWithExtension = os.path.split(gcovFilename)
srcFilename = re.sub(".gcov$","",gcovFilenameWithExtension)
return re.sub("#","/",srcFilename)

def main(argv):
arguments = ['COVERAGE_SRCS_FILE=','COVERALLS_OUTPUT_FILE=','COV_PATH=','PROJECT_ROOT=']
COVERAGE_SRCS_FILE=None
COVERALLS_OUTPUT_FILE=None
COV_PATH=None
PROJECT_ROOT=None
optlist, args = getopt.getopt(argv,'',arguments)

for o, a in optlist:
if o == "--COVERAGE_SRCS_FILE":
COVERAGE_SRCS_FILE=a
elif o == "--COVERALLS_OUTPUT_FILE":
COVERALLS_OUTPUT_FILE=a
elif o == "--COV_PATH":
COV_PATH=a
elif o == "--PROJECT_ROOT":
PROJECT_ROOT=a
else:
assert False, "unhandled option"

if COVERAGE_SRCS_FILE == None:
assert False, "COVERAGE_SRCS_FILE is not defined"
if COVERALLS_OUTPUT_FILE==None:
assert False, "COVERALLS_OUTPUT_FILE is not defined"
if COV_PATH==None:
assert False, "COV_PATH is not defined"
if PROJECT_ROOT==None:
assert False, "PROJECT_ROOT is not defined"

gcdaAllFiles = getAllFilesWithExtension(COV_PATH,".gcda")
for gcdaFile in gcdaAllFiles:
gcdaDirectory = os.path.dirname(gcdaFile)
subprocess.check_call(["gcov","-p","-o",gcdaDirectory,gcdaFile],cwd=COV_PATH)

gcovAllFiles = getAllFilesWithExtension(COV_PATH,".gcov")

sourcesToCheck = [line.strip() for line in open(COVERAGE_SRCS_FILE, 'r')]

gcovCheckedFiles = []
uncheckedSources = sourcesToCheck
for gcovFile in gcovAllFiles:
sourceWithPath = getSourcePathFromGcovFile(gcovFile)
if sourceWithPath in sourcesToCheck:
print "YES: ",sourceWithPath.strip()," WAS FOUND"
gcovCheckedFiles.append(gcovFile)
uncheckedSources.remove(sourceWithPath)
else:
print "NO: ",sourceWithPath.strip()," WAS NOT FOUND"

coverageList = []
for gcovFilename in gcovCheckedFiles:
fileCoverage = {}
#get name for json file
sourceWithPath = getSourcePathFromGcovFile(gcovFilename)
fileCoverage['name'] = os.path.relpath(sourceWithPath,PROJECT_ROOT)
print "Generating JSON file for "+fileCoverage['name']
fileCoverage['source_digest'] = hashlib.md5(open(sourceWithPath, 'rb').read()).hexdigest()
lineCoverage = []
gcovFile = open(gcovFilename,'r')
for line in gcovFile:
line = [i.strip() for i in line.split(':')]
lineNumber = int(line[1])
if lineNumber != 0:
if line[0] == '#####':
lineCoverage.append(0)
elif line[0] == '-':
lineCoverage.append(None)
else:
lineCoverage.append(int(line[0]))
if lineNumber != len(lineCoverage):
raise RuntimeError['line_number does not match len(array)']
gcovFile.close()
fileCoverage['coverage'] = lineCoverage
coverageList.append(copy.deepcopy(fileCoverage))

for uncheckedFilename in uncheckedSources:
fileCoverage = {}
fileCoverage['name'] = os.path.relpath(uncheckedFilename,PROJECT_ROOT)
fileCoverage['source_digest'] = hashlib.md5(open(uncheckedFilename, 'rb').read()).hexdigest()
lineCoverage = []
uncheckedFile = open(uncheckedFilename,'r')
for line in uncheckedFile:
lineCoverage.append(0)
uncheckedFile.close()
fileCoverage['coverage'] = lineCoverage
coverageList.append(copy.deepcopy(fileCoverage))

coverallsOutput = {}
coverallsOutput['repo_token'] = os.environ.get('COVERALLS_REPO_TOKEN')
coverallsOutput['source_files'] = coverageList

head = {'id':gitLogValue('H',PROJECT_ROOT),'author_name':gitLogValue('an',PROJECT_ROOT), \
'author_email':gitLogValue('ae',PROJECT_ROOT),'committer_name':gitLogValue('cn',PROJECT_ROOT), \
'committer_email':gitLogValue('ce',PROJECT_ROOT), 'message':gitLogValue('B',PROJECT_ROOT)}

gitDict = {'head':head,'branch':getBranchName(PROJECT_ROOT),'remotes':getRemotes(COV_PATH)}
coverallsOutput['git'] = gitDict

with open(COVERALLS_OUTPUT_FILE, 'w') as outfile:
json.dump(coverallsOutput,outfile,indent=4)

if __name__ == "__main__":
main(sys.argv[1:])
6 changes: 6 additions & 0 deletions Code/Mantid/Build/CMake/FindPyQt.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def get_qt4_tag(sip_flags):
else:
in_t = False
raise ValueError('Cannot find Qt\'s tag in PyQt4\'s SIP flags.')

def get_pyuic():
pyqt4_dir = os.path.dirname(PyQt4.__file__)
return os.path.join(pyqt4_dir, 'uic', 'pyuic.py')

if __name__ == '__main__':
try:
Expand All @@ -40,9 +44,11 @@ def get_qt4_tag(sip_flags):
# configure.py, so pyqtconfig.py is not installed.
sip_dir = get_default_sip_dir()
sip_flags = PyQt4.QtCore.PYQT_CONFIGURATION['sip_flags']
pyqt_pyuic = get_pyuic()

print('pyqt_version:%06.x' % PyQt4.QtCore.PYQT_VERSION)
print('pyqt_version_str:%s' % PyQt4.QtCore.PYQT_VERSION_STR)
print('pyqt_version_tag:%s' % get_qt4_tag(sip_flags))
print('pyqt_sip_dir:%s' % sip_dir)
print('pyqt_sip_flags:%s' % sip_flags)
print('pyqt_pyuic:%s' % pyqt_pyuic)
4 changes: 4 additions & 0 deletions Code/Mantid/Build/CMake/FindPyQt4.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ ELSE(EXISTS PYQT4_VERSION)

STRING(REGEX MATCH ".*\npyqt_sip_flags:([^\n]+).*$" _dummy ${pyqt_config})
SET(PYQT4_SIP_FLAGS "${CMAKE_MATCH_1}" CACHE STRING "The SIP flags used to build PyQt4")

STRING(REGEX MATCH ".*\npyqt_pyuic:([^\n]+).*$" _dummy ${pyqt_config})
SET(PYQT4_PYUIC "${CMAKE_MATCH_1}" CACHE STRING "Location of the pyuic script")


IF(NOT IS_DIRECTORY "${PYQT4_SIP_DIR}")
MESSAGE(WARNING "The base directory where PyQt4's SIP files are installed could not be determined. This usually means PyQt4 was built with its new build system and pyqtconfig.py is not present.\n"
Expand Down
29 changes: 29 additions & 0 deletions Code/Mantid/Build/CMake/UiToPy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
###########################################################################
# Function to convert ui files into PyQt4 python files
###########################################################################


function(UiToPy ui_files target_name)

set(py_exec ${PYTHON_EXECUTABLE})
set(py_uic_py ${PYQT4_PYUIC} ) # From FindPyQt4
set(ui_dir ${CMAKE_CURRENT_SOURCE_DIR})
set(_outputs "")
foreach(ui_file ${${ui_files}})
# Get the filename
get_filename_component(ui_name ${ui_file} NAME_WE)
# Generated file to create
set( generated_file ${ui_dir}/ui_${ui_name}.py )
# Source file to generate from
set( source_file ${ui_dir}/${ui_name}.ui )
# Command to run the translation
add_custom_command(OUTPUT ${generated_file} COMMAND ${py_exec} ${py_uic_py} ${source_file} -o ${generated_file} COMMAND ${py_exec} ${CMAKE_SOURCE_DIR}/Build/wrap_pyui.py ${generated_file} DEPENDS ${source_file})
# Record all generated files
list(APPEND _outputs ${generated_file})

endforeach(ui_file)
# Create a custom target
add_custom_target(${target_name} DEPENDS ${_outputs})

endfunction(UiToPy)

2 changes: 1 addition & 1 deletion Code/Mantid/Build/CMake/VersionNumber.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Set the version number here for MantidVersion and the package filenames

set ( VERSION_MAJOR 3 )
set ( VERSION_MINOR 3 )
set ( VERSION_MINOR 4 )

# UNCOMMENT the next 'set' line to 'force' the patch version number to
# a value (instead of using the count coming out of 'git describe')
Expand Down

0 comments on commit d489cf7

Please sign in to comment.