From 9d857959743f4df58d97411526b935f5a797699f 2015-10-20 09:21:51 From: Titta Heikkala Date: 2015-10-20 09:21:51 Subject: [PATCH] Updated tools folder Removed old build scripts, etc. Updated the demoLauncher. Change-Id: I64cee9c2b7c8e33ccee8310407bc28ae1001976d Reviewed-by: Miikka Heikkinen --- diff --git a/tools/Jobs.pm b/tools/Jobs.pm deleted file mode 100644 index 58ed990..0000000 --- a/tools/Jobs.pm +++ /dev/null @@ -1,33 +0,0 @@ -package Jobs; -use File::Basename; -use Tiny; - -sub get { - my $inifile = shift; - my $jobname = shift; - - # Strip the prefix from job name when using ${bamboo.buildPlanName} - my $prefix = "Qt Charts component"; - $jobname =~ s/$prefix//; - - # read ini file - my $cfg = Config::Tiny->read( $inifile ); - - # get section from ini by jobname - my %job = %{$cfg->{$jobname}}; - if (!%job) { - die ("Unknown jobname! Check $inifile and bamboo job name."); - } - - # print out the ini settings - print "\n\nini file: $inifile\n"; - print "[$jobname]\n"; - foreach (keys %job) { - print $_ . "=" . $job{$_} . "\n"; - } - print "\n"; - - return %job; -} - -1; diff --git a/tools/Tiny.pm b/tools/Tiny.pm deleted file mode 100644 index 2496129..0000000 --- a/tools/Tiny.pm +++ /dev/null @@ -1,280 +0,0 @@ -package Config::Tiny; - -# If you thought Config::Simple was small... - -use strict; -BEGIN { - require 5.004; - $Config::Tiny::VERSION = '2.14'; - $Config::Tiny::errstr = ''; -} - -# Create an empty object -sub new { bless {}, shift } - -# Create an object from a file -sub read { - my $class = ref $_[0] ? ref shift : shift; - - # Check the file - my $file = shift or return $class->_error( 'You did not specify a file name' ); - return $class->_error( "File '$file' does not exist" ) unless -e $file; - return $class->_error( "'$file' is a directory, not a file" ) unless -f _; - return $class->_error( "Insufficient permissions to read '$file'" ) unless -r _; - - # Slurp in the file - local $/ = undef; - open( CFG, $file ) or return $class->_error( "Failed to open file '$file': $!" ); - my $contents = ; - close( CFG ); - - $class->read_string( $contents ); -} - -# Create an object from a string -sub read_string { - my $class = ref $_[0] ? ref shift : shift; - my $self = bless {}, $class; - return undef unless defined $_[0]; - - # Parse the file - my $ns = '_'; - my $counter = 0; - foreach ( split /(?:\015{1,2}\012|\015|\012)/, shift ) { - $counter++; - - # Skip comments and empty lines - next if /^\s*(?:\#|\;|$)/; - - # Remove inline comments - s/\s\;\s.+$//g; - - # Handle section headers - if ( /^\s*\[\s*(.+?)\s*\]\s*$/ ) { - # Create the sub-hash if it doesn't exist. - # Without this sections without keys will not - # appear at all in the completed struct. - $self->{$ns = $1} ||= {}; - next; - } - - # Handle properties - if ( /^\s*([^=]+?)\s*=\s*(.*?)\s*$/ ) { - $self->{$ns}->{$1} = $2; - next; - } - - return $self->_error( "Syntax error at line $counter: '$_'" ); - } - - $self; -} - -# Save an object to a file -sub write { - my $self = shift; - my $file = shift or return $self->_error( - 'No file name provided' - ); - - # Write it to the file - my $string = $self->write_string; - return undef unless defined $string; - open( CFG, '>' . $file ) or return $self->_error( - "Failed to open file '$file' for writing: $!" - ); - print CFG $string; - close CFG; -} - -# Save an object to a string -sub write_string { - my $self = shift; - - my $contents = ''; - foreach my $section ( sort { (($b eq '_') <=> ($a eq '_')) || ($a cmp $b) } keys %$self ) { - # Check for several known-bad situations with the section - # 1. Leading whitespace - # 2. Trailing whitespace - # 3. Newlines in section name - return $self->_error( - "Illegal whitespace in section name '$section'" - ) if $section =~ /(?:^\s|\n|\s$)/s; - my $block = $self->{$section}; - $contents .= "\n" if length $contents; - $contents .= "[$section]\n" unless $section eq '_'; - foreach my $property ( sort keys %$block ) { - return $self->_error( - "Illegal newlines in property '$section.$property'" - ) if $block->{$property} =~ /(?:\012|\015)/s; - $contents .= "$property=$block->{$property}\n"; - } - } - - $contents; -} - -# Error handling -sub errstr { $Config::Tiny::errstr } -sub _error { $Config::Tiny::errstr = $_[1]; undef } - -1; - -__END__ - -=pod - -=head1 NAME - -Config::Tiny - Read/Write .ini style files with as little code as possible - -=head1 SYNOPSIS - - # In your configuration file - rootproperty=blah - - [section] - one=twp - three= four - Foo =Bar - empty= - - # In your program - use Config::Tiny; - - # Create a config - my $Config = Config::Tiny->new; - - # Open the config - $Config = Config::Tiny->read( 'file.conf' ); - - # Reading properties - my $rootproperty = $Config->{_}->{rootproperty}; - my $one = $Config->{section}->{one}; - my $Foo = $Config->{section}->{Foo}; - - # Changing data - $Config->{newsection} = { this => 'that' }; # Add a section - $Config->{section}->{Foo} = 'Not Bar!'; # Change a value - delete $Config->{_}; # Delete a value or section - - # Save a config - $Config->write( 'file.conf' ); - -=head1 DESCRIPTION - -C is a perl class to read and write .ini style configuration -files with as little code as possible, reducing load time and memory -overhead. Most of the time it is accepted that Perl applications use a lot -of memory and modules. The C<::Tiny> family of modules is specifically -intended to provide an ultralight alternative to the standard modules. - -This module is primarily for reading human written files, and anything we -write shouldn't need to have documentation/comments. If you need something -with more power move up to L, L or one of -the many other C modules. To rephrase, L does B -preserve your comments, whitespace, or the order of your config file. - -=head1 CONFIGURATION FILE SYNTAX - -Files are the same format as for windows .ini files. For example: - - [section] - var1=value1 - var2=value2 - -If a property is outside of a section at the beginning of a file, it will -be assigned to the C<"root section">, available at C<$Config-E{_}>. - -Lines starting with C<'#'> or C<';'> are considered comments and ignored, -as are blank lines. - -When writing back to the config file, all comments, custom whitespace, -and the ordering of your config file elements is discarded. If you need -to keep the human elements of a config when writing back, upgrade to -something better, this module is not for you. - -=head1 METHODS - -=head2 new - -The constructor C creates and returns an empty C object. - -=head2 read $filename - -The C constructor reads a config file, and returns a new -C object containing the properties in the file. - -Returns the object on success, or C on error. - -When C fails, C sets an error message internally -you can recover via Cerrstr>. Although in B -cases a failed C will also set the operating system error -variable C<$!>, not all errors do and you should not rely on using -the C<$!> variable. - -=head2 read_string $string; - -The C method takes as argument the contents of a config file -as a string and returns the C object for it. - -=head2 write $filename - -The C method generates the file content for the properties, and -writes it to disk to the filename specified. - -Returns true on success or C on error. - -=head2 write_string - -Generates the file content for the object and returns it as a string. - -=head2 errstr - -When an error occurs, you can retrieve the error message either from the -C<$Config::Tiny::errstr> variable, or using the C method. - -=head1 CAVEATS - -=head2 Unsupported Section Headers - -Some edge cases in section headers are not support, and additionally may not -be detected when writing the config file. - -Specifically, section headers with leading whitespace, trailing whitespace, -or newlines anywhere in the section header, will not be written correctly -to the file and may cause file corruption. - -=head1 SUPPORT - -Bugs should be reported via the CPAN bug tracker at - -L - -For other issues, or commercial enhancement or support, contact the author. - -=head1 AUTHOR - -Adam Kennedy Eadamk@cpan.orgE - -=head1 ACKNOWLEGEMENTS - -Thanks to Sherzod Ruzmetov Esherzodr@cpan.orgE for -L, which inspired this module by being not quite -"simple" enough for me :) - -=head1 SEE ALSO - -L, L, L - -=head1 COPYRIGHT - -Copyright 2002 - 2011 Adam Kennedy. - -This program is free software; you can redistribute -it and/or modify it under the same terms as Perl itself. - -The full text of the license can be found in the -LICENSE file included with this module. - -=cut diff --git a/tools/build.pl b/tools/build.pl deleted file mode 100644 index 3379db7..0000000 --- a/tools/build.pl +++ /dev/null @@ -1,97 +0,0 @@ -use File::Basename; -use feature "switch"; -use lib 'tools'; -use Jobs; - -# read command line params -my $jobname = shift; - -# get script directory -my $scriptdir = File::Basename::dirname($0); - -# read ini file -my $inifile = $scriptdir . "/jobs.ini"; -my %job = Jobs::get($inifile, $jobname); - -# examine the platform -given ($job{'Platform'}) { - - when ("Win7") { - - $scriptdir =~ s/\//\\/g; # replace / -> \ - - # construct a build command - if ($job{'ToolChain'} eq "mingw") { - run($scriptdir . "\\build_win_mingw.bat", $job{'QtDir'}, $job{'Config'}, $job{'MinGWDir'}); - } - elsif ($job{'ToolChain'} eq "vs2005") { - run($scriptdir . "\\build_win_vs2005.bat", $job{'QtDir'}, $job{'Config'}); - } - elsif ($job{'ToolChain'} eq "vs2008") { - run($scriptdir . "\\build_win_vs2008.bat", $job{'QtDir'}, $job{'Config'}); - } - elsif ($job{'ToolChain'} eq "vs2010") { - run($scriptdir . "\\build_win_vs2010.bat", $job{'QtDir'}, $job{'Config'}); - } - elsif ($job{'ToolChain'} eq "vs2010-64bit") { - run($scriptdir . "\\build_win_vs2010_64bit.bat", $job{'QtDir'}, $job{'Config'}); - } - else { - die "Unknown toolchain!"; - } - } - - when ("Mac") { - - # setup build environment - $ENV{'QTDIR'} = $job{'QtDir'}; - $ENV{'PATH'} = $job{'QtDir'} . "/bin:" . $ENV{'PATH'}; - - # run qmake - my $cmd; - if ($job{'ToolChain'} eq "clang") { - run("qmake -r -spec unsupported/macx-clang CONFIG+=" . $job{'Config'}); - } - elsif ($job{'ToolChain'} eq "gcc") { - run("qmake -r CONFIG+=" . $job{'Config'}); - } - else { - die "Unknown toolchain!"; - } - - # run make - run("make"); - } - - when ("Linux") { - - # setup build environment - $ENV{'QTDIR'} = $job{'QtDir'}; - $ENV{'PATH'} = $job{'QtDir'} . "/bin:" . $ENV{'PATH'}; - - # run qmake - my $cmd; - if ($job{'ToolChain'} eq "gcc") { - run("qmake -r CONFIG+=" . $job{'Config'}); - } - else { - die "Unknown toolchain!"; - } - - # run make - run("make -j 4"); - } - - default { - die "Unknown platform " . $job{'Platform'}; - } -} - -sub run { - my $cmd; - foreach (@_) { - $cmd .= "$_ "; - } - print "running : $cmd\n"; - system(@_) == 0 or die "system \"$cmd\" failed: $?"; -} \ No newline at end of file diff --git a/tools/build_win_mingw.bat b/tools/build_win_mingw.bat deleted file mode 100644 index 54212cd..0000000 --- a/tools/build_win_mingw.bat +++ /dev/null @@ -1,8 +0,0 @@ -set QTDIR=%1 -set PATH=%1\bin; -set PATH=%PATH%;%3\bin -set PATH=%PATH%;%SystemRoot%\System32 -set QMAKESPEC=win32-g++ -qmake -r charts.pro CONFIG+=%2 -@echo on -mingw32-make \ No newline at end of file diff --git a/tools/build_win_vs2005.bat b/tools/build_win_vs2005.bat deleted file mode 100644 index 9642ba2..0000000 --- a/tools/build_win_vs2005.bat +++ /dev/null @@ -1,10 +0,0 @@ -set QTDIR=%1 -set PATH=%1\bin;%PATH%; -set QMAKESPEC=win32-msvc2005 -call "C:\Program Files (x86)\Microsoft Visual Studio 8\VC\vcvarsall.bat" x86 -@echo on -set INCLUDE=%INCLUDE%;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include -set LIB=%LIB%;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib -qmake -r charts.pro CONFIG+=%2 -@echo on -nmake diff --git a/tools/build_win_vs2008.bat b/tools/build_win_vs2008.bat deleted file mode 100644 index 4edcefc..0000000 --- a/tools/build_win_vs2008.bat +++ /dev/null @@ -1,8 +0,0 @@ -set QTDIR=%1 -set PATH=%1\bin;%PATH%; -set QMAKESPEC=win32-msvc2008 -call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 -@echo on -qmake -r charts.pro CONFIG+=%2 -@echo on -nmake diff --git a/tools/build_win_vs2010.bat b/tools/build_win_vs2010.bat deleted file mode 100644 index 690dabf..0000000 --- a/tools/build_win_vs2010.bat +++ /dev/null @@ -1,8 +0,0 @@ -set QTDIR=%1 -set PATH=%1\bin;%PATH%; -set QMAKESPEC=win32-msvc2010 -call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86 -@echo on -qmake -r charts.pro CONFIG+=%2 -@echo on -nmake diff --git a/tools/build_win_vs2010_64bit.bat b/tools/build_win_vs2010_64bit.bat deleted file mode 100644 index e89af2c..0000000 --- a/tools/build_win_vs2010_64bit.bat +++ /dev/null @@ -1,8 +0,0 @@ -set QTDIR=%1 -set PATH=%1\bin;%PATH%; -set QMAKESPEC=win32-msvc2010 -call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64 -@echo on -qmake -r charts.pro CONFIG+=%2 -@echo on -nmake diff --git a/tools/demoLauncher/demoLauncher.pro b/tools/demoLauncher/demoLauncher.pro index bfee99d..d22b097 100644 --- a/tools/demoLauncher/demoLauncher.pro +++ b/tools/demoLauncher/demoLauncher.pro @@ -1,3 +1,4 @@ +QT += core gui widgets TARGET = demoLauncher SOURCES += main.cpp\ widget.cpp \ diff --git a/tools/demoLauncher/graphicsbutton.cpp b/tools/demoLauncher/graphicsbutton.cpp index a91735f..9db45f0 100644 --- a/tools/demoLauncher/graphicsbutton.cpp +++ b/tools/demoLauncher/graphicsbutton.cpp @@ -20,9 +20,9 @@ ******************************************************************************/ #include "graphicsbutton.h" -#include -#include -#include +#include +#include +#include GraphicsButton::GraphicsButton(const QString &path, QDir appFolder, const QString &app, QWidget *parent) : QWidget(parent), diff --git a/tools/demoLauncher/graphicsbutton.h b/tools/demoLauncher/graphicsbutton.h index ad6afd0..3933d65 100644 --- a/tools/demoLauncher/graphicsbutton.h +++ b/tools/demoLauncher/graphicsbutton.h @@ -22,7 +22,7 @@ #ifndef GRAPHICSBUTTON_H #define GRAPHICSBUTTON_H -#include +#include #include class QProcess; diff --git a/tools/demoLauncher/main.cpp b/tools/demoLauncher/main.cpp index 059337f..a5048db 100644 --- a/tools/demoLauncher/main.cpp +++ b/tools/demoLauncher/main.cpp @@ -19,7 +19,7 @@ ** ******************************************************************************/ -#include +#include #include "widget.h" int main(int argc, char *argv[]) diff --git a/tools/demoLauncher/widget.cpp b/tools/demoLauncher/widget.cpp index 99769fa..e357572 100644 --- a/tools/demoLauncher/widget.cpp +++ b/tools/demoLauncher/widget.cpp @@ -20,9 +20,9 @@ ******************************************************************************/ #include "widget.h" -#include -#include -#include +#include +#include +#include #include "graphicsbutton.h" Widget::Widget(QWidget *parent) @@ -41,6 +41,8 @@ Widget::Widget(QWidget *parent) QDir imageFolder = m_appFolder; imageFolder.cdUp(); imageFolder.cdUp(); + imageFolder.cd("src"); + imageFolder.cd("charts"); imageFolder.cd("doc"); imageFolder.cd("images"); diff --git a/tools/demoLauncher/widget.h b/tools/demoLauncher/widget.h index 8dc0d16..d72e1e3 100644 --- a/tools/demoLauncher/widget.h +++ b/tools/demoLauncher/widget.h @@ -22,7 +22,7 @@ #ifndef WIDGET_H #define WIDGET_H -#include +#include #include class Widget : public QWidget diff --git a/tools/jobs.ini b/tools/jobs.ini deleted file mode 100644 index e9ed365..0000000 --- a/tools/jobs.ini +++ /dev/null @@ -1,154 +0,0 @@ - -; How to use -; ---------- -; - Section name must match to "Job Name" in Bamboo. -; * See ${bamboo.buildPlanName} in bamboo. -; * Case sensitive. -; - The parameters given can be anything you need for that particular build. -; * Implement your special parameter handling in the perl scripts. - -[Win7 vs2005 debug QtC v4.7.5 (Jani's machine)] -Platform=Win7 -QtDir=D:\Qt\qt-win-commercial-4.7.5-vs2005 -ToolChain=vs2005 -Config=debug - -[Win7 vs2005 release QtC v4.7.5 (Jani's machine)] -Platform=Win7 -QtDir=D:\Qt\qt-win-commercial-4.7.5-vs2005 -ToolChain=vs2005 -Config=release - -[Win7 MinGW debug QtC v4.8.0 (Jani's machine)] -Platform=Win7 -QtDir=D:\QtCommercialSdk\Desktop\480\mingw44 -ToolChain=mingw -Config=debug -MinGWDir=D:\QtCommercialSdk\Tools\mingw44 - -[Win7 MinGW release QtC v4.8.0 (Jani's machine)] -Platform=Win7 -QtDir=D:\QtCommercialSdk\Desktop\480\mingw44 -ToolChain=mingw -Config=release -MinGWDir=D:\QtCommercialSdk\Tools\mingw44 - -[Win7 vs2010 debug QtC v4.8.0 (Jani's machine)] -Platform=Win7 -QtDir=D:\QtCommercialSdk\Desktop\480\vs2010 -ToolChain=vs2010 -Config=debug - -[Win7 vs2010 release QtC v4.8.0 (Jani's machine)] -Platform=Win7 -QtDir=D:\QtCommercialSdk\Desktop\480\vs2010 -ToolChain=vs2010 -Config=release - -[Win7 vs2008 debug QtC v4.8.2 (Jani's machine)] -Platform=Win7 -QtDir=D:\QtCommercialSdk\Desktop\482\vs2008 -ToolChain=vs2008 -Config=debug - -[Win7 vs2008 release QtC v4.8.2 (Jani's machine)] -Platform=Win7 -QtDir=D:\QtCommercialSdk\Desktop\482\vs2008 -ToolChain=vs2008 -Config=release - -[Win7 vs2010 debug QtC v4.8.3 (Jani's machine)] -Platform=Win7 -QtDir=D:\QtCommercialSdk\Desktop\483\vs2010 -ToolChain=vs2010 -Config=debug - -[Win7 vs2010 release QtC v4.8.3 (Jani's machine)] -Platform=Win7 -QtDir=D:\QtCommercialSdk\Desktop\483\vs2010 -ToolChain=vs2010 -Config=release - -[Win7 vs2010 debug Qt v5.0.0-beta2 (Jani's machine)] -Platform=Win7 -QtDir=D:\Qt\qt-opensource-5.0.0-beta2\5.0.0-beta2\msvc2010 -ToolChain=vs2010 -Config=debug - -[Win7 vs2010 release Qt v5.0.0-beta2 (Jani's machine)] -Platform=Win7 -QtDir=D:\Qt\qt-opensource-5.0.0-beta2\5.0.0-beta2\msvc2010 -ToolChain=vs2010 -Config=release - -[Win7 vs2010 debug Qt5 QtSdk git (Jani's machine)] -Platform=Win7 -QtDir=D:\git\gitorious\qtsdk\qtbase -ToolChain=vs2010 -Config=debug - -[Win7 vs2010 release Qt5 QtSdk git (Jani's machine)] -Platform=Win7 -QtDir=D:\git\gitorious\qtsdk\qtbase -ToolChain=vs2010 -Config=release - -[Win7 vs2010-64bit debug QtC v4.8.1] -Platform=Win7 -QtDir=C:\Qt\4.8.1 -ToolChain=vs2010-64bit -Config=debug - -[Win7 vs2010-64bit release QtC v4.8.1] -Platform=Win7 -QtDir=C:\Qt\4.8.1 -ToolChain=vs2010-64bit -Config=release - -[Mac 10.7 Cocoa clang debug QtC v4.8.0 (Tero's iMac)] -Platform=Mac -QtDir=/Users/teahola/QtCommercialSdk/Desktop/480/cocoa_gcc -ToolChain=clang -Config=debug - -[Mac 10.7 Cocoa clang release QtC v4.8.0 (Tero's iMac)] -Platform=Mac -QtDir=/Users/teahola/QtCommercialSdk/Desktop/480/cocoa_gcc -ToolChain=clang -Config=release - -[Mac 10.7 Cocoa gcc debug QtC v4.8.0 (Tero's iMac)] -Platform=Mac -QtDir=/Users/teahola/QtCommercialSdk/Desktop/480/cocoa_gcc -ToolChain=gcc -Config=debug - -[Mac 10.7 Cocoa gcc release QtC v4.8.0 (Tero's iMac)] -Platform=Mac -QtDir=/Users/teahola/QtCommercialSdk/Desktop/480/cocoa_gcc -ToolChain=gcc -Config=release - -[Ubuntu 10.10 x86 debug QtC v4.8.1] -Platform=Linux -QtDir=/usr/local/Trolltech/Qt-4.8.1 -ToolChain=gcc -Config=debug - -[Ubuntu 10.10 x86 release QtC v4.8.1] -Platform=Linux -QtDir=/usr/local/Trolltech/Qt-4.8.1 -ToolChain=gcc -Config=release - -[Ubuntu 10.10 x86_64 debug QtC v4.8.1] -Platform=Linux -QtDir=/usr/local/Trolltech/Qt-4.8.1 -ToolChain=gcc -Config=debug - -[Ubuntu 10.10 x86_64 release QtC v4.8.1] -Platform=Linux -QtDir=/usr/local/Trolltech/Qt-4.8.1 -ToolChain=gcc -Config=release diff --git a/tools/normalize/README b/tools/normalize/README deleted file mode 100644 index 55c9210..0000000 --- a/tools/normalize/README +++ /dev/null @@ -1,16 +0,0 @@ -This tool greps through files for SIGNAL() or SLOT() macros and pipes the signals/slots -through QMetaObject::normalizedSignature(). - -Rationale: In connect statements, you'll get a micro-speed update when passing in normalized -signatures for signals and slots. - -Run it without any arguments to see the command line parameters. - -Typical usage on Qt: - -# find all files with non-normalized signal/slot connections and p4 edit them -normalize $QTDIR/src | xargs p4 edit -# replace all non-normalized signal/slots -normalize --modify $QTDIR/src -# p4 diff to see that everything is OK then submit :) -p4 submit $QTDIR/src/... diff --git a/tools/normalize/main.cpp b/tools/normalize/main.cpp deleted file mode 100644 index 572ebf4..0000000 --- a/tools/normalize/main.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/****************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Charts module. -** -** $QT_BEGIN_LICENSE:COMM$ -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** $QT_END_LICENSE$ -** -******************************************************************************/ -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -static bool printFilename = true; -static bool modify = false; - -QString signature(const QString &line, int pos) -{ - int start = pos; - // find first open parentheses - while (start < line.length() && line.at(start) != QLatin1Char('(')) - ++start; - int i = ++start; - int par = 1; - // find matching closing parentheses - while (i < line.length() && par > 0) { - if (line.at(i) == QLatin1Char('(')) - ++par; - else if (line.at(i) == QLatin1Char(')')) - --par; - ++i; - } - if (par == 0) - return line.mid(start, i - start - 1); - return QString(); -} - -bool checkSignature(const QString &fileName, QString &line, const char *sig) -{ - static QStringList fileList; - - int idx = -1; - bool found = false; - while ((idx = line.indexOf(sig, ++idx)) != -1) { - const QByteArray sl(signature(line, idx).toLocal8Bit()); - QByteArray nsl(QMetaObject::normalizedSignature(sl.constData())); - if (sl != nsl) { - found = true; - if (printFilename && !fileList.contains(fileName)) { - fileList.prepend(fileName); - printf("%s\n", fileName.toLocal8Bit().constData()); - } - if (modify) - line.replace(sl, nsl); - //qDebug("expected '%s', got '%s'", nsl.data(), sl.data()); - } - } - return found; -} - -void writeChanges(const QString &fileName, const QStringList &lines) -{ - QFile file(fileName); - if (!file.open(QIODevice::WriteOnly)) { - qDebug("unable to open file '%s' for writing (%s)", fileName.toLocal8Bit().constData(), file.errorString().toLocal8Bit().constData()); - return; - } - QTextStream stream(&file); - for (int i = 0; i < lines.count(); ++i) - stream << lines.at(i); - file.close(); -} - -void check(const QString &fileName) -{ - QFile file(fileName); - if (!file.open(QIODevice::ReadOnly)) { - qDebug("unable to open file: '%s' (%s)", fileName.toLocal8Bit().constData(), file.errorString().toLocal8Bit().constData()); - return; - } - QStringList lines; - bool found = false; - while (true) { - QByteArray bline = file.readLine(16384); - if (bline.isEmpty()) - break; - QString line = QString::fromLocal8Bit(bline); - Q_ASSERT_X(line.endsWith("\n"), "check()", fileName.toLocal8Bit().constData()); - found |= checkSignature(fileName, line, "SLOT"); - found |= checkSignature(fileName, line, "SIGNAL"); - if (modify) - lines << line; - } - file.close(); - - if (found && modify) { - printf("Modifying file: '%s'\n", fileName.toLocal8Bit().constData()); - writeChanges(fileName, lines); - } -} - -void traverse(const QString &path) -{ - QDirIterator dirIterator(path, QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files | QDir::NoSymLinks); - - while (dirIterator.hasNext()) { - QString filePath = dirIterator.next(); - if (filePath.endsWith(".cpp")) - check(filePath); - else if (QFileInfo(filePath).isDir()) - traverse(filePath); // recurse - } -} - -int main(int argc, char *argv[]) -{ - QCoreApplication app(argc, argv); - - if (app.argc() < 2 || (app.argc() == 2 && (app.argv()[1][0] == '-'))) { - printf("usage: normalize [--modify] \n"); - printf(" can be a single file or a directory (default: look for *.cpp recursively)"); - printf(" Outputs all filenames that contain non-normalized SIGNALs and SLOTs\n"); - printf(" with --modify: fix all occurrences of non-normalized SIGNALs and SLOTs\n"); - return 1; - } - - QString path; - if (qstrcmp(app.argv()[1], "--modify") == 0) { - printFilename = false; - modify = true; - path = app.argv()[2]; - } else { - path = app.argv()[1]; - } - - if (path.startsWith("-")) { - qWarning("unknown parameter: %s", path.toLocal8Bit().constData()); - return 1; - } - - QFileInfo fi(path); - if (fi.isFile()) { - check(path); - } else if (fi.isDir()) { - if (!path.endsWith("/")) - path.append("/"); - traverse(path); - } else { - qWarning("Don't know what to do with '%s'", path.toLocal8Bit().constData()); - return 1; - } - - return 0; -} diff --git a/tools/normalize/normalize.pro b/tools/normalize/normalize.pro deleted file mode 100644 index cff3f05..0000000 --- a/tools/normalize/normalize.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = app -CONFIG -= moc - -# Input -SOURCES += main.cpp - -QT = core -CONFIG += warn_on console -mac:CONFIG -= app_bundle diff --git a/tools/run_tests.pl b/tools/run_tests.pl deleted file mode 100644 index 279f619..0000000 --- a/tools/run_tests.pl +++ /dev/null @@ -1,95 +0,0 @@ -use Cwd; -use Cwd 'abs_path'; -use File::Basename; -use File::Copy; -use feature "switch"; -use lib 'tools'; -use Jobs; - -# read command line params -my $jobname = shift; - -# read ini file -my $inifile = File::Basename::dirname($0) . "/jobs.ini"; -my %job = Jobs::get($inifile, $jobname); - -# set/get paths -my $root_path = abs_path(); -my $bin_path = "$root_path/bin/" . $job{'Config'} . "/"; -my $reports_path = "test-reports"; - -# create reports path -mkdir $reports_path; - -# setup environment for running tests -given ($job{'Platform'}) { - - when ("Win7") { - # Add qtdir to path - $ENV{'PATH'} .= ";" . $job{'QtDir'} . "\\bin"; - - # replace / -> \ - $ENV{'PATH'} =~ s/\//\\/g; - } - - when ("Linux") { - # Add qtdir to path - $ENV{'PATH'} = $job{'QtDir'} . "/bin:" . $ENV{'PATH'}; - - # If this is not set we get "cannot connect to X server" errors - $ENV{'DISPLAY'} = ":0.0"; - } - - when ("Mac") { - # Set QML_IMPORT_PATH point to QML plugin dir - $ENV{'QML_IMPORT_PATH'} = $bin_path; - } -} - -# Go through all the files in the test folder -# autotest is an executable beginning with "tst_" -my $script_exit_status = 0; -opendir (TESTAPPDIR, "$bin_path") or die "Couldn't open test app dir"; -@files = ; -while ($testapp = readdir TESTAPPDIR) { - if (index($testapp, "tst_") == 0) { - if (-x "$bin_path$testapp") { - my $status = executeTestApp($testapp); - if ($status != 0) { - $script_exit_status = $status; - } - } else { - #print "file $testapp not executable\n"; - } - } -} -closedir TESTAPPDIR; - -# Do not return error codes for bamboo. -# Bamboo will determine test failures by parsing the xml logs. -exit(0); - - -sub executeTestApp($) { - my $testapp = $_[0]; - - # On OSX the actual test binary is in a sub folder - my $cmd_postfix = ""; - if ($^O eq "darwin") { - $cmd_postfix = "/Contents/MacOS/$testapp"; - $cmd_postfix = substr($cmd_postfix, 0, rindex($cmd_postfix, ".app")); - } - - my $cmd = "$bin_path$testapp$cmd_postfix -xunitxml -o $reports_path/$testapp.xml"; - print "executing: $cmd\n"; - system($cmd); - - # From http://perldoc.perl.org/perlvar.html about $?: - # The upper eight bits reflect specific error conditions encountered by the - # program (the program's exit() value). The lower eight bits reflect - # mode of failure, like signal death and core dump information. - # See wait(2) for details. - my $exit_status = $? >> 8; - print "\texit status: $exit_status\n"; - return $exit_status; -}