diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-06-01 08:48:42 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-06-01 09:24:28 (GMT) |
commit | 2812bddd81f8a1b804c7460f4e14cd0aa393d129 (patch) | |
tree | d46294f35150c4f0f43deaf2d31fceaf945ae715 /tools | |
download | swift-2812bddd81f8a1b804c7460f4e14cd0aa393d129.zip swift-2812bddd81f8a1b804c7460f4e14cd0aa393d129.tar.bz2 |
Import.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/Copyrighter.py | 19 | ||||
-rwxr-xr-x | tools/ThemeQRC.py | 17 | ||||
-rwxr-xr-x | tools/coverage/FilterLCovData.py | 23 | ||||
-rwxr-xr-x | tools/coverage/GenerateCoverageResults.sh | 30 | ||||
-rwxr-xr-x | tools/coverage/GenerateOverview.py | 63 | ||||
-rwxr-xr-x | tools/coverage/GenerateSummary.py | 35 | ||||
-rw-r--r-- | tools/coverage/descriptions.txt | 2 | ||||
-rw-r--r-- | tools/nsis/swift.nsi | 72 | ||||
-rwxr-xr-x | tools/qmakeish.py | 107 | ||||
-rwxr-xr-x | tools/syntax/CheckTabs.sh | 8 |
10 files changed, 376 insertions, 0 deletions
diff --git a/tools/Copyrighter.py b/tools/Copyrighter.py new file mode 100755 index 0000000..9726f03 --- /dev/null +++ b/tools/Copyrighter.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +import os + +TEMPLATE = """/* + * Copyright (c) %(year)s %(author)s + * %(license)s + */""" + +for (path, dirs, files) in os.walk("src") : + if "3rdParty" in path : + continue + for filename in files : + if not filename.endswith(".cpp") and not filename.endswith(".h") : + continue + if filename.startswith("moc_") : + continue + fullFilename = path + "/" + filename + print fullFilename diff --git a/tools/ThemeQRC.py b/tools/ThemeQRC.py new file mode 100755 index 0000000..63de8c3 --- /dev/null +++ b/tools/ThemeQRC.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +import os, sys, os.path + +print "<RCC version =\"1.0\">" +print "<qresource prefix=\"/themes/Default\">" +for (path, dirs, files) in os.walk(sys.argv[1]) : + for file in files : + filePath = os.path.join(path,file) + print "<file alias=\"%(alias)s\">%(path)s</file>" % { + "alias": filePath[len(sys.argv[1])+1:], + "path": filePath + } + +print "</qresource>" +print "</RCC>" + diff --git a/tools/coverage/FilterLCovData.py b/tools/coverage/FilterLCovData.py new file mode 100755 index 0000000..b0d180f --- /dev/null +++ b/tools/coverage/FilterLCovData.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +import sys, re + +assert(len(sys.argv) == 2) + +output = [] +inputFile = open(sys.argv[1]) +inIgnoredFile = False +for line in inputFile.readlines() : + if inIgnoredFile : + if line == "end_of_record\n" : + inIgnoredFile = False + else : + if line.startswith("SF:") and (line.find("/Swift/") == -1 or line.find("/UnitTest/") != -1 or line.find("/QA/") != -1 or line.find("/3rdParty/") != -1): + inIgnoredFile = True + else : + output.append(line) +inputFile.close() + +outputFile = open(sys.argv[1], 'w') +outputFile.write(''.join(output)) +outputFile.close() diff --git a/tools/coverage/GenerateCoverageResults.sh b/tools/coverage/GenerateCoverageResults.sh new file mode 100755 index 0000000..9e32da4 --- /dev/null +++ b/tools/coverage/GenerateCoverageResults.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +# This script assumes that it is run from the toplevel directory, that +# the 'configure' script has been called with '--enable-coverage' + +SOURCE_DIR=src/Swift +SCRIPT_DIR=tools/coverage + +RESULTS_DIR=tools/coverage/results +OUTPUT_DIR=$RESULTS_DIR/coverage-`git log --pretty=format:%ct-%h | head -n 1` + +make -C $SOURCE_DIR +if [ ! -f $OUTPUT_DIR ]; then + mkdir -p $OUTPUT_DIR +fi + +# Reset counters +lcov --zerocounters --directory $SOURCE_DIR + +# All tests +make -C $SOURCE_DIR test +lcov --capture --directory $SOURCE_DIR -b $SOURCE_DIR --output-file $OUTPUT_DIR/all.info --test-name all +$SCRIPT_DIR/FilterLCovData.py $OUTPUT_DIR/all.info + +# Generate HTML +gendesc -o $OUTPUT_DIR/descriptions $SCRIPT_DIR/descriptions.txt +genhtml --title "Swift Coverage" --output-directory $OUTPUT_DIR $OUTPUT_DIR/all.info + +# Generate summary +$SCRIPT_DIR/GenerateSummary.py $OUTPUT_DIR/all.info $OUTPUT_DIR/summary diff --git a/tools/coverage/GenerateOverview.py b/tools/coverage/GenerateOverview.py new file mode 100755 index 0000000..8928afd --- /dev/null +++ b/tools/coverage/GenerateOverview.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python + +import sys, os.path + +assert(len(sys.argv) == 4) + +resultsDir = sys.argv[1] +summaryFile = sys.argv[2] +overviewFile = sys.argv[3] + +results = [] +for dir in os.listdir(resultsDir) : + summary = os.path.join(resultsDir, dir, summaryFile) + if os.path.exists(summary) : + file = open(summary) + lines = file.readlines() + if len(lines) == 0 or len(lines[0].split("/")) != 2 : + continue + coveredCount = int(lines[0].split("/")[0]) + totalCount = int(lines[0].split("/")[1]) + results.append((dir,coveredCount,totalCount)) + +# Compute coverage chart URL +chartparams = ["chs=320x240", "cht=lc", "chtt=Coverage (Relative)", "chxt=y", "chxl=0:|50%|80%|100%|", "chxp=0,50,80,100"] +chartdata = [] +for (url,covered,total) in results : + chartdata.append(str(100*covered/total)) +chartparams.append("chd=t:" + ",".join(chartdata)) +coverageChartURL = "http://chart.apis.google.com/chart?" + '&'.join(chartparams) + +# Compute the maximum of lines over time +maximumNumberOfLines = 0 +for (url,covered,total) in results : + maximumNumberOfLines = max(maximumNumberOfLines,total) + +# Compute code chart URL +chartparams = ["chs=320x240", "cht=lc", "chtt=Coverage (Absolute)", "chxt=y", "chxl=0:|" + str(maximumNumberOfLines) + "|", "chxp=0,100", "chm=b,FF0000,0,1,0|b,80C65A,1,2,0", "chco=00000000,00000000,00000000"] +coveredLinesData = [] +totalLinesData = [] +nullLinesData = [] +for (url,covered,total) in results : + coveredLinesData.append(str(100*covered/maximumNumberOfLines)) + totalLinesData.append(str(100*total/maximumNumberOfLines)) + nullLinesData.append("0") +chartparams.append("chd=t:" + ",".join(totalLinesData) + "|" + ",".join(coveredLinesData) + "|" + ",".join(nullLinesData)) +codeChartURL = "http://chart.apis.google.com/chart?" + '&'.join(chartparams) + + +# Output page +output = open(os.path.join(resultsDir,overviewFile), 'w') +output.write("<img src=\"%(url)s\"s/>" % {'url' : coverageChartURL}) +output.write("<img src=\"%(url)s\"s/>" % {'url' : codeChartURL}) +output.write("<ul>\n") +for (url,covered,total) in results : + output.write("<li><a href='%(url)s/index.html'>%(url)s</a> %(percentage)s%% (%(covered)s/%(total)s)</li>\n" % { + 'url' : url, + 'percentage' : 100*covered / total, + 'covered' : covered, + 'total' : total + }) +output.write("</ul>") +output.close() + diff --git a/tools/coverage/GenerateSummary.py b/tools/coverage/GenerateSummary.py new file mode 100755 index 0000000..ec94a4f --- /dev/null +++ b/tools/coverage/GenerateSummary.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +import sys, re + +assert(len(sys.argv) == 3) + +inputFile = open(sys.argv[1]) +currentFile = "" +coverage = {} +for line in inputFile.readlines() : + line = line.strip() + m = re.match("^SF:(.*)", line) + if m : + currentFile = m.group(1) + else : + m = re.match("^DA:(\d+),(\d+)", line) + if m : + currentFileCoverage = coverage.get(currentFile, {}) + line = int(m.group(1)) + count = int(m.group(2)) + currentFileCoverage[line] = currentFileCoverage.get(line, 0) + count + coverage[currentFile] = currentFileCoverage +inputFile.close() + +totalLines = 0 +coveredLines = 0 +for c in coverage.values() : + totalLines += len(c) + for l in c.values() : + if l > 0 : + coveredLines += 1 + +outputFile = open(sys.argv[2], 'w') +outputFile.write(str(coveredLines) + "/" + str(totalLines)) +outputFile.close() diff --git a/tools/coverage/descriptions.txt b/tools/coverage/descriptions.txt new file mode 100644 index 0000000..5b07e04 --- /dev/null +++ b/tools/coverage/descriptions.txt @@ -0,0 +1,2 @@ +all + All tests diff --git a/tools/nsis/swift.nsi b/tools/nsis/swift.nsi new file mode 100644 index 0000000..577becb --- /dev/null +++ b/tools/nsis/swift.nsi @@ -0,0 +1,72 @@ +# define installer name +outFile "Swift-installer-win32.exe" + +# set desktop as install directory +installDir "$PROGRAMFILES\Swift" + +SetCompressor lzma + +# default section start +section "Main install" + +# define output path +setOutPath $INSTDIR + +# specify files to go in output path +file ..\..\src\UI\Qt\release\* + +# create start menu item +createShortCut "$SMPROGRAMS\Swift\Swift.lnk" "$INSTDIR\Swift.exe" +createShortCut "$SMPROGRAMS\Swift\Unistall Swift.lnk" "$INSTDIR\unistall.exe" + +# We /could/ start on login: +# WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Run" "Swift" "$INSTDIR\Swift.exe" + +# Add the information to Add/Remove +WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Swift" "DisplayName" "Swift" +WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Swift" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" +WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Swift" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\"" + + +# define uninstaller name +writeUninstaller $INSTDIR\uninstaller.exe + +# default section end +sectionEnd + +Section -Prerequisites +# http://nsis.sourceforge.net/Embedding_other_installers + SetOutPath $INSTDIR\Prerequisites + MessageBox MB_YESNO "Install C++ Runtime?" /SD IDYES IDNO endRuntime + File ..\..\vcredist_x86.exe + ExecWait "$INSTDIR\Prerequisites\vcredist_x86.exe" + delete $INSTDIR\Prerequisites\vcredist_x86.exe + delete $INSTDIR\Prerequisites + Goto endRuntime + endRuntime: +SectionEnd + +section "autostart" + MessageBox MB_YESNO "Run at startup?" /SD IDYES IDNO endAutostart + WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Run" "Swift" "$INSTDIR\Swift.exe" + Goto endAutostart + endAutostart: +sectionEnd + +# create a section to define what the uninstaller does. +# the section will always be named "Uninstall" +section "Uninstall" + MessageBox MB_YESNO "The uninstaller will delete the entire Swift folder, including any user-created files. Are you sure?" /SD IDYES IDNO endUninstall + # Always delete uninstaller first + delete $INSTDIR\uninstaller.exe + + # now delete installed files + delete $INSTDIR\* + Goto endUninstall + endUninstall: +sectionEnd + + +# TODO http://nsis.sourceforge.net/Check_whether_your_application_is_running_during_uninstallation +# http://nsis.sourceforge.net/Date_and_time_in_installer_or_application_name +# http://nsis.sourceforge.net/Removing_'Nullsoft_Install_System_vX.XX'_String_from_installer diff --git a/tools/qmakeish.py b/tools/qmakeish.py new file mode 100755 index 0000000..34a3b79 --- /dev/null +++ b/tools/qmakeish.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python +# Run this from the toplevel with: +# tools/qmakeish.py src/Swift/Makefile > src/Swift/Swift.pri + +import sys, re, os.path + +def processSourcesLine(line) : + strippedLine = line.rstrip("\n") + sourceFile = re.sub("\\\\$", "", strippedLine).strip() + if len(sourceFile) > 0 : + print "SOURCES += $$PWD/" + sourceFile + return strippedLine.endswith("\\") + +def processFlags(name, flags) : + flags = flags.replace("-isystem ", "-I") + for flag in flags.split(" ") : + if flag.startswith("-D") : + print "DEFINES += " + flag[2:] + elif flag.startswith("-I") : + print "INCLUDEPATH += $$PWD/" + flag[2:] + elif len(flag) > 0 : + print name + " += " + flag + + +assert(len(sys.argv) == 2) + +basedir = os.path.dirname(sys.argv[1]) + +# Flatten the makefile +makefile = [] +files = [open(sys.argv[1])] +while len(files) > 0 : + file = files[-1] + line = file.readline() + if line : + match = re.match("include (.*)", line) + if match and match.group(1) != "Makefile.config" : + files.append(open(os.path.join(basedir, match.group(1)))) + makefile.append("## Begin File: " + match.group(1)) + else : + makefile.append(line) + else : + makefile.append("## End file") + file.close() + files.pop() + +# Process makefile +inSources = False +for line in makefile : + if inSources : + inSources = processSourcesLine(line) + else : + # Conditional + match = re.match("if(n?)eq \(\$\((.*)\),(.*)\)", line) + if match : + conditional = match.group(2) + if conditional == "WIN32" : + conditional = "win32" + elif conditional == "MACOSX" : + conditional = "mac" + elif match.group(2).startswith("HAVE_") : + conditional = "!isEmpty(" + match.group(2) + ")" + else : + conditional = "DUMMY" + if (match.group(1) == "n") ^ (match.group(3) not in ["1", "yes"]) : + conditional = "!" + conditional + print conditional + " {" + continue + if re.match("^if(n?)def", line) : + print "DUMMY {" + continue + elif re.match("^if(n?)eq", line) : + print "DUMMY {" + continue + if re.match("^else$", line) : + print "} else {" + continue + if re.match("^endif$", line) : + print "}" + continue + + match = re.match("(\w+)_SOURCES (\+?)= (.*)", line) + if match and match.group(1) in ["SWIFT", "ZLIB", "LIBIDN", "BOOST"] : + inSources = processSourcesLine(match.group(3)) + continue + + match = re.match("(LIBS|CXXFLAGS|CPPFLAGS|CFLAGS) \+= (.*)", line) + if match : + processFlags(match.group(1), match.group(2)) + + if line.startswith("## ") : + print line + +""" +#print sourceFiles +sys.exit(0) + +print files +pro = open ('swiftall.pri', 'w') +for sourceType in files.keys(): + pro.write("%s += \\\n" % sourceType) + for sourceFile in files[sourceType]: + pro.write("$$PWD/Swift/%s \\\n" % sourceFile) + pro.write("\n") +pro.close() + +""" diff --git a/tools/syntax/CheckTabs.sh b/tools/syntax/CheckTabs.sh new file mode 100755 index 0000000..0c11c49 --- /dev/null +++ b/tools/syntax/CheckTabs.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +FAILING_FILES=`grep -r "^ " * | grep -E "^(\w|/)+\.(cpp|h):" | grep -E -v "^(src/(Swift/)?)?3rdParty" | grep -v "^.*moc_" | sed -e "s/:.*//" | uniq` + +if [ "$FAILING_FILES" ]; then + echo "ERROR: Found whitespace instead of tabs in the following files:" + echo "$FAILING_FILES" +fi |