From 1ebe6b8fec84591c32f70fdcfafc92fda037e84d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 25 Jun 2013 17:44:35 +0200 Subject: [PATCH] make TR_EXCLUDE work for SUBDIRS this is needed for excluding subprojects we have no direct control over, e.g., git submodules. note that unlike TR_EXCLUDE for files, this matches SUBDIRS entries, not actual project file names. wildcards also work, though. Change-Id: I1d0a0410a28af4a60f045ee5bbac34540c14f0bd Reviewed-by: Friedemann Kleint Reviewed-by: hjk Reviewed-by: Oswald Buddenhagen --- src/linguist/lupdate/main.cpp | 17 +++++++- .../good/proparsingsubs/excluded/excluded.pro | 1 + .../testdata/good/proparsingsubs/excluded/main.cpp | 50 ++++++++++++++++++++++ .../testdata/good/proparsingsubs/project.pro | 3 ++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingsubs/excluded/excluded.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingsubs/excluded/main.cpp diff --git a/src/linguist/lupdate/main.cpp b/src/linguist/lupdate/main.cpp index 7229c9c..6af50f9 100644 --- a/src/linguist/lupdate/main.cpp +++ b/src/linguist/lupdate/main.cpp @@ -312,6 +312,19 @@ static QStringList getSources(const ProFileEvaluator &visitor, const QString &pr return sourceFiles; } +static void excludeProjects(const ProFileEvaluator &visitor, QStringList *subProjects) +{ + foreach (const QString &ex, visitor.values(QLatin1String("TR_EXCLUDE"))) { + QRegExp rx(ex, Qt::CaseSensitive, QRegExp::Wildcard); + for (QStringList::Iterator it = subProjects->begin(); it != subProjects->end(); ) { + if (rx.exactMatch(*it)) + it = subProjects->erase(it); + else + ++it; + } + } +} + static void processSources(Translator &fetchedTor, const QStringList &sourceFiles, ConversionData &cd) { @@ -380,9 +393,11 @@ static void processProject( } QString proPath = QFileInfo(proFile).path(); if (visitor.templateType() == ProFileEvaluator::TT_Subdirs) { + QStringList subProjects = visitor.values(QLatin1String("SUBDIRS")); + excludeProjects(visitor, &subProjects); QStringList subProFiles; QDir proDir(proPath); - foreach (const QString &subdir, visitor.values(QLatin1String("SUBDIRS"))) { + foreach (const QString &subdir, subProjects) { QString realdir = visitor.value(subdir + QLatin1String(".subdir")); if (realdir.isEmpty()) realdir = visitor.value(subdir + QLatin1String(".file")); diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/excluded/excluded.pro b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/excluded/excluded.pro new file mode 100644 index 0000000..28dcadc --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/excluded/excluded.pro @@ -0,0 +1 @@ +SOURCES += main.cpp diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/excluded/main.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/excluded/main.cpp new file mode 100644 index 0000000..cc99f9d --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/excluded/main.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// IMPORTANT!!!! If you want to add testdata to this file, +// always add it to the end in order to not change the linenumbers of translations!!! + + +void func1() { + QString fake = QApplication::tr("fake", "This message will not be collected"); +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/project.pro b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/project.pro index 13f9217..cad99dc 100644 --- a/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/project.pro +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/project.pro @@ -1,3 +1,6 @@ TEMPLATE = subdirs comm.subdir = common SUBDIRS = win mac unix comm + +SUBDIRS += excluded +TR_EXCLUDE = excluded -- 2.7.4