Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
3739af6c
Commit
3739af6c
authored
Jul 23, 2009
by
Oswald Buddenhagen
Browse files
make Option a nested class of ProFileEvaluator
it's still static at that point, though.
parent
c699522b
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/shared/proparser/profileevaluator.cpp
View file @
3739af6c
...
...
@@ -28,7 +28,6 @@
**************************************************************************/
#include
"profileevaluator.h"
#include
"proparserutils.h"
#include
"proitems.h"
#include
<QtCore/QByteArray>
...
...
@@ -83,51 +82,20 @@ namespace {
//
///////////////////////////////////////////////////////////////////////
QString
Option
::
fixString
(
QString
string
,
uchar
flags
)
{
// XXX Ripped out caching, so this will be slow. Should not matter for current uses.
//fix the environment variables
if
(
flags
&
Option
::
FixEnvVars
)
{
int
rep
;
QRegExp
reg_variableName
(
QLatin1String
(
"
\\
$
\\
(.*
\\
)"
));
reg_variableName
.
setMinimal
(
true
);
while
((
rep
=
reg_variableName
.
indexIn
(
string
))
!=
-
1
)
string
.
replace
(
rep
,
reg_variableName
.
matchedLength
(),
QString
::
fromLocal8Bit
(
qgetenv
(
string
.
mid
(
rep
+
2
,
reg_variableName
.
matchedLength
()
-
3
).
toLatin1
().
constData
()).
constData
()));
}
//canonicalize it (and treat as a path)
if
(
flags
&
Option
::
FixPathCanonicalize
)
{
#if 0
string = QFileInfo(string).canonicalFilePath();
#endif
string
=
QDir
::
cleanPath
(
string
);
}
if
(
string
.
length
()
>
2
&&
string
[
0
].
isLetter
()
&&
string
[
1
]
==
QLatin1Char
(
':'
))
string
[
0
]
=
string
[
0
].
toLower
();
//fix separators
Q_ASSERT
(
!
((
flags
&
Option
::
FixPathToLocalSeparators
)
&&
(
flags
&
Option
::
FixPathToTargetSeparators
)));
if
(
flags
&
Option
::
FixPathToLocalSeparators
)
{
#if defined(Q_OS_WIN32)
string
=
string
.
replace
(
QLatin1Char
(
'/'
),
QLatin1Char
(
'\\'
));
ProFileEvaluator
::
Option
::
TARG_MODE
ProFileEvaluator
::
Option
::
target_mode
=
ProFileEvaluator
::
Option
::
TARG_WIN_MODE
;
#elif defined(Q_OS_MAC)
ProFileEvaluator
::
Option
::
TARG_MODE
ProFileEvaluator
::
Option
::
target_mode
=
ProFileEvaluator
::
Option
::
TARG_MACX_MODE
;
#elif defined(Q_OS_QNX6)
ProFileEvaluator
::
Option
::
TARG_MODE
ProFileEvaluator
::
Option
::
target_mode
=
ProFileEvaluator
::
Option
::
TARG_QNX6_MODE
;
#else
string
=
string
.
replace
(
QLatin1Char
(
'\\'
),
QLatin1Char
(
'/'
))
;
ProFileEvaluator
::
Option
::
TARG_MODE
ProFileEvaluator
::
Option
::
target_mode
=
ProFileEvaluator
::
Option
::
TARG_UNIX_MODE
;
#endif
}
else
if
(
flags
&
Option
::
FixPathToTargetSeparators
)
{
string
=
string
.
replace
(
QLatin1Char
(
'/'
),
Option
::
dir_sep
)
.
replace
(
QLatin1Char
(
'\\'
),
Option
::
dir_sep
);
}
if
((
string
.
startsWith
(
QLatin1Char
(
'"'
))
&&
string
.
endsWith
(
QLatin1Char
(
'"'
)))
||
(
string
.
startsWith
(
QLatin1Char
(
'\''
))
&&
string
.
endsWith
(
QLatin1Char
(
'\''
))))
string
=
string
.
mid
(
1
,
string
.
length
()
-
2
);
return
string
;
}
QString
ProFileEvaluator
::
Option
::
qmakespec
;
QString
ProFileEvaluator
::
Option
::
dirlist_sep
;
QString
ProFileEvaluator
::
Option
::
dir_sep
;
QChar
ProFileEvaluator
::
Option
::
field_sep
;
///////////////////////////////////////////////////////////////////////
//
...
...
@@ -705,7 +673,7 @@ static QStringList split_value_list(const QString &vals, bool do_semicolon=false
}
if
(
!
parens
&&
quote
.
isEmpty
()
&&
((
do_semicolon
&&
unicode
==
SEMICOLON
)
||
vals_data
[
x
]
==
Option
::
field_sep
))
{
vals_data
[
x
]
==
ProFileEvaluator
::
Option
::
field_sep
))
{
ret
<<
build
;
build
.
clear
();
}
else
{
...
...
@@ -752,6 +720,34 @@ static void replaceInList(QStringList *varlist,
}
}
static
QString
expandEnvVars
(
const
QString
&
str
)
{
QString
string
=
str
;
int
rep
;
QRegExp
reg_variableName
(
QLatin1String
(
"
\\
$
\\
(.*
\\
)"
));
reg_variableName
.
setMinimal
(
true
);
while
((
rep
=
reg_variableName
.
indexIn
(
string
))
!=
-
1
)
string
.
replace
(
rep
,
reg_variableName
.
matchedLength
(),
QString
::
fromLocal8Bit
(
qgetenv
(
string
.
mid
(
rep
+
2
,
reg_variableName
.
matchedLength
()
-
3
).
toLatin1
().
constData
()).
constData
()));
return
string
;
}
// This is braindead, but we want qmake compat
static
QString
fixPathToLocalOS
(
const
QString
&
str
)
{
QString
string
=
str
;
if
(
string
.
length
()
>
2
&&
string
[
0
].
isLetter
()
&&
string
[
1
]
==
QLatin1Char
(
':'
))
string
[
0
]
=
string
[
0
].
toLower
();
#if defined(Q_OS_WIN32)
string
.
replace
(
QLatin1Char
(
'/'
),
QLatin1Char
(
'\\'
));
#else
string
.
replace
(
QLatin1Char
(
'\\'
),
QLatin1Char
(
'/'
));
#endif
return
string
;
}
//////// Evaluator /////////
ProItem
::
ProItemReturn
ProFileEvaluator
::
Private
::
visitBeginProBlock
(
ProBlock
*
block
)
...
...
@@ -1056,7 +1052,8 @@ static QStringList qmake_mkspec_paths()
const
QString
concat
=
QDir
::
separator
()
+
QString
(
QLatin1String
(
"mkspecs"
));
QByteArray
qmakepath
=
qgetenv
(
"QMAKEPATH"
);
if
(
!
qmakepath
.
isEmpty
())
{
const
QStringList
lst
=
QString
::
fromLocal8Bit
(
qmakepath
).
split
(
Option
::
dirlist_sep
);
const
QStringList
lst
=
QString
::
fromLocal8Bit
(
qmakepath
)
.
split
(
ProFileEvaluator
::
Option
::
dirlist_sep
);
for
(
QStringList
::
ConstIterator
it
=
lst
.
begin
();
it
!=
lst
.
end
();
++
it
)
ret
<<
((
*
it
)
+
concat
);
}
...
...
@@ -1090,7 +1087,7 @@ QStringList ProFileEvaluator::Private::qmakeFeaturePaths()
QString path;
int last_slash = Option::mkfile::cachefile.lastIndexOf(Option::dir_sep);
if (last_slash != -1)
path =
Option::
fixPathToLocalOS(Option::mkfile::cachefile.left(last_slash));
path = fixPathToLocalOS(Option::mkfile::cachefile.left(last_slash));
foreach (const QString &concat_it, concat)
feature_roots << (path + concat_it);
}
...
...
@@ -1657,7 +1654,6 @@ QStringList ProFileEvaluator::Private::evaluateExpandFunction(const QString &fun
q
->
logMessage
(
format
(
"cat(file, singleline=true) requires one or two arguments."
));
}
else
{
QString
file
=
args
[
0
];
file
=
Option
::
fixPathToLocalOS
(
file
);
bool
singleLine
=
true
;
if
(
args
.
count
()
>
1
)
...
...
@@ -1682,7 +1678,7 @@ QStringList ProFileEvaluator::Private::evaluateExpandFunction(const QString &fun
} else {
QString file = args[0], seek_variableName = args[1];
ProFile pro(
Option::
fixPathToLocalOS(file));
ProFile pro(fixPathToLocalOS(file));
ProFileEvaluator visitor;
visitor.setVerbose(m_verbose);
...
...
@@ -1819,7 +1815,7 @@ QStringList ProFileEvaluator::Private::evaluateExpandFunction(const QString &fun
if
(
args
.
count
()
==
2
)
recursive
=
(
!
args
[
1
].
compare
(
QLatin1String
(
"true"
),
Qt
::
CaseInsensitive
)
||
args
[
1
].
toInt
());
QStringList
dirs
;
QString
r
=
Option
::
fixPathToLocalOS
(
args
[
0
]);
QString
r
=
fixPathToLocalOS
(
args
[
0
]);
int
slash
=
r
.
lastIndexOf
(
QDir
::
separator
());
if
(
slash
!=
-
1
)
{
dirs
.
append
(
r
.
left
(
slash
));
...
...
@@ -2332,7 +2328,7 @@ ProItem::ProItemReturn ProFileEvaluator::Private::evaluateConditionalFunction(
q
->
logMessage
(
format
(
"%1(message) requires one argument."
).
arg
(
function
));
return
ProItem
::
ReturnFalse
;
}
QString
msg
=
Option
::
fixString
(
args
.
first
(),
Option
::
FixEnvVars
);
QString
msg
=
expandEnvVars
(
args
.
first
()
);
q
->
fileMessage
(
QString
::
fromLatin1
(
"Project %1: %2"
).
arg
(
function
.
toUpper
(),
msg
));
// ### Consider real termination in non-cumulative mode
return
returnBool
(
function
!=
QLatin1String
(
"error"
));
...
...
@@ -2367,7 +2363,7 @@ ProItem::ProItemReturn ProFileEvaluator::Private::evaluateConditionalFunction(
return
ProItem
::
ReturnFalse
;
}
QString
file
=
args
.
first
();
file
=
Option
::
fixPathToLocalOS
(
file
);
file
=
fixPathToLocalOS
(
file
);
if
(
QFile
::
exists
(
file
))
{
return
ProItem
::
ReturnTrue
;
...
...
@@ -2607,7 +2603,7 @@ inline QStringList fixEnvVariables(const QStringList &x)
{
QStringList
ret
;
foreach
(
const
QString
&
str
,
x
)
ret
<<
Option
::
fixString
(
str
,
Option
::
Fix
EnvVars
);
ret
<<
expand
EnvVars
(
str
);
return
ret
;
}
...
...
src/shared/proparser/profileevaluator.h
View file @
3739af6c
...
...
@@ -43,6 +43,51 @@ QT_BEGIN_NAMESPACE
class
ProFileEvaluator
{
public:
// This struct is from qmake, but we are not using everything.
struct
Option
{
//simply global convenience
//static QString libtool_ext;
//static QString pkgcfg_ext;
//static QString prf_ext;
//static QString prl_ext;
//static QString ui_ext;
//static QStringList h_ext;
//static QStringList cpp_ext;
//static QString h_moc_ext;
//static QString cpp_moc_ext;
//static QString obj_ext;
//static QString lex_ext;
//static QString yacc_ext;
//static QString h_moc_mod;
//static QString cpp_moc_mod;
//static QString lex_mod;
//static QString yacc_mod;
static
QString
dir_sep
;
static
QString
dirlist_sep
;
static
QString
qmakespec
;
static
QChar
field_sep
;
enum
TARG_MODE
{
TARG_UNIX_MODE
,
TARG_WIN_MODE
,
TARG_MACX_MODE
,
TARG_MAC9_MODE
,
TARG_QNX6_MODE
};
static
TARG_MODE
target_mode
;
//static QString pro_ext;
//static QString res_ext;
static
void
init
()
{
#ifdef Q_OS_WIN
dirlist_sep
=
QLatin1Char
(
';'
);
dir_sep
=
QLatin1Char
(
'\\'
);
#else
dirlist_sep
=
QLatin1Char
(
':'
);
dir_sep
=
QLatin1Char
(
'/'
);
#endif
qmakespec
=
QString
::
fromLatin1
(
qgetenv
(
"QMAKESPEC"
).
data
());
field_sep
=
QLatin1Char
(
' '
);
}
};
enum
TemplateType
{
TT_Unknown
=
0
,
TT_Application
,
...
...
src/shared/proparser/proparser.pri
View file @
3739af6c
...
...
@@ -12,7 +12,6 @@ HEADERS += \
profileevaluator.h \
proiteminfo.h \
proitems.h \
proparserutils.h \
prowriter.h \
proxml.h \
valueeditor.h \
...
...
src/shared/proparser/proparserutils.h
deleted
100644 → 0
View file @
c699522b
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://www.qtsoftware.com/contact.
**
**************************************************************************/
#ifndef PROPARSERUTILS_H
#define PROPARSERUTILS_H
QT_BEGIN_NAMESPACE
// This struct is from qmake, but we are not using everything.
struct
Option
{
//simply global convenience
//static QString libtool_ext;
//static QString pkgcfg_ext;
//static QString prf_ext;
//static QString prl_ext;
//static QString ui_ext;
//static QStringList h_ext;
//static QStringList cpp_ext;
//static QString h_moc_ext;
//static QString cpp_moc_ext;
//static QString obj_ext;
//static QString lex_ext;
//static QString yacc_ext;
//static QString h_moc_mod;
//static QString cpp_moc_mod;
//static QString lex_mod;
//static QString yacc_mod;
static
QString
dir_sep
;
static
QString
dirlist_sep
;
static
QString
qmakespec
;
static
QChar
field_sep
;
enum
TARG_MODE
{
TARG_UNIX_MODE
,
TARG_WIN_MODE
,
TARG_MACX_MODE
,
TARG_MAC9_MODE
,
TARG_QNX6_MODE
};
static
TARG_MODE
target_mode
;
//static QString pro_ext;
//static QString res_ext;
static
void
init
()
{
#ifdef Q_OS_WIN
Option
::
dirlist_sep
=
QLatin1Char
(
';'
);
Option
::
dir_sep
=
QLatin1Char
(
'\\'
);
#else
Option
::
dirlist_sep
=
QLatin1Char
(
':'
);
Option
::
dir_sep
=
QLatin1Char
(
QLatin1Char
(
'/'
));
#endif
Option
::
qmakespec
=
QString
::
fromLatin1
(
qgetenv
(
"QMAKESPEC"
).
data
());
Option
::
field_sep
=
QLatin1Char
(
' '
);
}
enum
StringFixFlags
{
FixNone
=
0x00
,
FixEnvVars
=
0x01
,
FixPathCanonicalize
=
0x02
,
FixPathToLocalSeparators
=
0x04
,
FixPathToTargetSeparators
=
0x08
};
static
QString
fixString
(
QString
string
,
uchar
flags
);
inline
static
QString
fixPathToLocalOS
(
const
QString
&
in
,
bool
fix_env
=
true
,
bool
canonical
=
true
)
{
uchar
flags
=
FixPathToLocalSeparators
;
if
(
fix_env
)
flags
|=
FixEnvVars
;
if
(
canonical
)
flags
|=
FixPathCanonicalize
;
return
fixString
(
in
,
flags
);
}
};
#if defined(Q_OS_WIN32)
Option
::
TARG_MODE
Option
::
target_mode
=
Option
::
TARG_WIN_MODE
;
#elif defined(Q_OS_MAC)
Option
::
TARG_MODE
Option
::
target_mode
=
Option
::
TARG_MACX_MODE
;
#elif defined(Q_OS_QNX6)
Option
::
TARG_MODE
Option
::
target_mode
=
Option
::
TARG_QNX6_MODE
;
#else
Option
::
TARG_MODE
Option
::
target_mode
=
Option
::
TARG_UNIX_MODE
;
#endif
QString
Option
::
qmakespec
;
QString
Option
::
dirlist_sep
;
QString
Option
::
dir_sep
;
QChar
Option
::
field_sep
;
QT_END_NAMESPACE
#endif // PROPARSERUTILS_H
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment