Merge "Merge remote-tracking branch 'origin/dev' into wip/qt6"

This commit is contained in:
Alexandru Croitor 2019-09-04 14:33:40 +02:00
commit 93f2f33a49
768 changed files with 130342 additions and 82513 deletions

View File

@ -2,7 +2,6 @@ load(qt_build_config)
CONFIG += warning_clean
DEFINES += QT_NO_JAVA_STYLE_ITERATORS
DEFINES += QT_NO_LINKED_LIST
QT_SOURCE_TREE = $$PWD
QT_BUILD_TREE = $$shadowed($$PWD)

View File

@ -79,9 +79,6 @@ normalizePath(\$out_basedir);
our $build_basedir;
our $basedir;
# Make sure we use Windows line endings for chomp and friends on Windows.
$INPUT_RECORD_SEPARATOR = "\r\n" if ($^O eq "msys");
# will be defined based on the modules sync.profile
our (%modules, %moduleheaders, @allmoduleheadersprivate, %classnames, %deprecatedheaders);
our (@qpa_headers, @private_headers);
@ -182,10 +179,10 @@ sub shouldMasterInclude {
my ($iheader) = @_;
return 0 if (basename($iheader) =~ /_/);
return 0 if (basename($iheader) =~ /qconfig/);
local $/ = "\x0a";
if (open(F, "<$iheader")) {
while (<F>) {
chomp;
chop if /\r$/;
s/\x0d?\x0a//;
return 0 if (/^\#pragma qt_no_master_include$/);
}
close(F);
@ -215,11 +212,11 @@ sub classNames {
my $ihdrbase = basename($iheader);
my $parsable = "";
local $/ = "\x0a";
if(open(F, "<$iheader")) {
while(<F>) {
s/\x0d?\x0a//;
my $line = $_;
chomp $line;
chop $line if ($line =~ /\r$/);
if($line =~ /^\#/) {
$$clean = 0 if ($line =~ m/^#pragma qt_sync_skip_header_check/);
return @ret if($line =~ m/^#pragma qt_sync_stop_processing/);
@ -231,6 +228,7 @@ sub classNames {
$line .= ";" if($line =~ m/^Q_[A-Z_0-9]*\(.*\)[\r\n]*$/); #qt macro
$line .= ";" if($line =~ m/^QT_(BEGIN|END)_HEADER[\r\n]*$/); #qt macro
$line .= ";" if($line =~ m/^QT_(BEGIN|END)_NAMESPACE(_[A-Z]+)*[\r\n]*$/); #qt macro
$line .= ";" if($line =~ m/^QT_DEPRECATED_X\(.*\)[\r\n]*$/); #qt macro
$line .= ";" if($line =~ m/^QT_MODULE\(.*\)[\r\n]*$/); # QT_MODULE macro
$line .= ";" if($line =~ m/^QT_WARNING_(PUSH|POP|DISABLE_\w+\(.*\))[\r\n]*$/); # qt macros
$$requires = $1 if ($line =~ m/^QT_REQUIRE_CONFIG\((.*)\);[\r\n]*$/);
@ -336,6 +334,7 @@ sub check_header {
$header_skip_qt_begin_namespace_test = 1 if ($ignore_for_qt_begin_namespace_check{$header});
}
local $/ = "\x0a";
open(F, "<$iheader") or return;
my $qt_begin_namespace_found = 0;
my $qt_end_namespace_found = 0;
@ -344,7 +343,7 @@ sub check_header {
my $stop_processing = 0;
my $we_mean_it = 0;
while ($line = <F>) {
chomp $line;
$line =~ s/\x0d?\x0a//;
my $output_line = 1;
if ($line =~ /^ *\# *pragma (qt_no_included_check|qt_sync_stop_processing)/) {
$stop_processing = 1;
@ -965,9 +964,10 @@ foreach my $lib (@modules_to_sync) {
#push @files, "$out_basedir/include/Qt/$t" if(-e "$out_basedir/include/Qt/$t");
foreach my $file (@files) {
my $remove_file = 0;
local $/ = "\x0a";
if(open(F, "<$file")) {
while(my $line = <F>) {
chomp $line;
$line =~ s/\x0d?\x0a//;
if($line =~ /^\#include \"([^\"]*)\"$/) {
my $include = $1;
$include = $subdir . "/" . $include unless(substr($include, 0, 1) eq "/");

View File

@ -1 +1,2 @@
SOURCES = arch.cpp
include(write_info.pri)

View File

@ -1,2 +1,3 @@
option(host_build)
SOURCES = arch.cpp
include(write_info.pri)

View File

@ -0,0 +1,14 @@
targetinfofile = $$basename(_PRO_FILE_)
targetinfofile ~= s/pro$/target.txt/
win32 {
ext = .exe
} else:wasm {
equals(WASM_OBJECT_FILES, 1): \
ext = .o
else: \
ext = .wasm
}
content = $${file_prefix}$${TARGET}$${ext}
write_file($$OUT_PWD/$$targetinfofile, content)

View File

@ -203,9 +203,8 @@ Build environment:
-android-ndk-platform Set Android platform
-android-ndk-host .... Set Android NDK host (linux-x86, linux-x86_64, etc.)
[$ANDROID_NDK_HOST]
-android-arch ........ Set Android architecture (armeabi, armeabi-v7a,
arm64-v8a, x86, x86_64)
-android-toolchain-version ... Set Android toolchain version
-android-abis ....... Comma separated Android abis, default is:
armeabi-v7a,arm64-v8a,x86,x86_64
-android-style-assets Automatically extract style assets from the device at
run time. This option makes the Android style behave
correctly, but also makes the Android platform plugin
@ -297,8 +296,7 @@ Gui, printing, widget options:
-gbm ............... Enable backends for GBM [auto] (Linux only)
-kms ............... Enable backends for KMS [auto] (Linux only)
-linuxfb ........... Enable Linux Framebuffer support [auto] (Linux only)
-xcb ............... Enable X11 support. Select used xcb-* libraries [system/qt/no]
(-qt-xcb still uses system version of libxcb itself)
-xcb ............... Enable X11 support [auto] (Linux only)
Input backends:
-libudev............ Enable udev support [auto]
@ -307,7 +305,7 @@ Gui, printing, widget options:
-libinput .......... Enable libinput support [auto]
-mtdev ............. Enable mtdev support [auto]
-tslib ............. Enable tslib support [auto]
-xcb-xinput ........ Enable XInput2 support [auto]
-bundled-xcb-xinput Use bundled XInput2 support [auto]
-xkbcommon ......... Enable key mapping support [auto]
Image formats:

View File

@ -51,11 +51,11 @@
"translationdir": "string",
"android-arch": "string",
"android-abis": "string",
"android-ndk": "string",
"android-ndk-host": "string",
"android-ndk-platform": "string",
"android-sdk": "string",
"android-toolchain-version": "string",
"android-style-assets": "boolean",
"appstore-compliant": "boolean",

View File

@ -286,37 +286,13 @@ defineTest(qtConfTest_architecture) {
!qtConfTest_compile($${1}): \
error("Could not determine $$eval($${1}.label). See config.log for details.")
host = $$eval($${1}.host)
isEmpty(host): host = false
file_prefix =
exts = -
$$host {
equals(QMAKE_HOST.os, Windows): \
exts = .exe
} else {
win32 {
exts = .exe
} else:android {
file_prefix = lib
exts = .so
} else:wasm {
exts = .wasm .o
}
}
test = $$eval($${1}.test)
output = $$eval($${1}.output)
test_out_dir = $$OUT_PWD/$$basename(QMAKE_CONFIG_TESTS_DIR)/$$test
test_out_file =
for(ext, exts) {
equals(ext, -): ext =
f = $$test_out_dir/$$file_prefix$$output$$ext
exists($$f) {
test_out_file = $$f
break()
}
}
isEmpty(test_out_file): \
test_out_file = $$test_out_dir/$$cat($$test_out_dir/$${output}.target.txt)
exists($$test_out_file): \
content = $$cat($$test_out_file, blob)
else: \
error("$$eval($${1}.label) detection binary not found.")
content = $$cat($$test_out_file, blob)
@ -597,14 +573,7 @@ defineTest(qtConfOutput_prepareOptions) {
qtConfFatalError("Cannot find Android NDK." \
"Please use -android-ndk option to specify one.")
ndk_tc_ver = $$eval(config.input.android-toolchain-version)
isEmpty(ndk_tc_ver): \
ndk_tc_ver = 4.9
!exists($$ndk_root/toolchains/arm-linux-androideabi-$$ndk_tc_ver/prebuilt/*): \
qtConfFatalError("Cannot detect Android NDK toolchain." \
"Please use -android-toolchain-version to specify it.")
ndk_tc_pfx = $$ndk_root/toolchains/arm-linux-androideabi-$$ndk_tc_ver/prebuilt
ndk_tc_pfx = $$ndk_root/toolchains/llvm/prebuilt
ndk_host = $$eval(config.input.android-ndk-host)
isEmpty(ndk_host): \
ndk_host = $$getenv(ANDROID_NDK_HOST)
@ -642,10 +611,11 @@ defineTest(qtConfOutput_prepareOptions) {
qtConfFatalError("Specified Android NDK host is invalid.")
}
target_arch = $$eval(config.input.android-arch)
isEmpty(target_arch): \
target_arch = armeabi-v7a
android_abis = $$eval(config.input.android-abis)
isEmpty(android_abis): \
android_abis = $$eval(config.input.android-arch)
isEmpty(android_abis): \
android_abis = armeabi-v7a,arm64-v8a,x86,x86_64
platform = $$eval(config.input.android-ndk-platform)
isEmpty(platform): \
platform = android-21
@ -655,8 +625,7 @@ defineTest(qtConfOutput_prepareOptions) {
"DEFAULT_ANDROID_NDK_ROOT = $$val_escape(ndk_root)" \
"DEFAULT_ANDROID_PLATFORM = $$platform" \
"DEFAULT_ANDROID_NDK_HOST = $$ndk_host" \
"DEFAULT_ANDROID_TARGET_ARCH = $$target_arch" \
"DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION = $$ndk_tc_ver"
"DEFAULT_ANDROID_ABIS = $$split(android_abis, ',')"
}
export($${currentConfig}.output.devicePro)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

View File

@ -304,8 +304,8 @@
\snippet threads/mandelbrot/mandelbrotwidget.cpp 12
The wheel event handler is reimplemented to make the mouse wheel
control the zoom level. QWheelEvent::delta() returns the angle of
the wheel mouse movement, in eights of a degree. For most mice,
control the zoom level. QWheelEvent::angleDelta() returns the angle
of the wheel mouse movement, in eighths of a degree. For most mice,
one wheel step corresponds to 15 degrees. We find out how many
mouse steps we have and determine the resulting zoom factor.
For example, if we have two wheel steps in the positive direction

View File

@ -176,7 +176,7 @@ void MandelbrotWidget::keyPressEvent(QKeyEvent *event)
//! [12]
void MandelbrotWidget::wheelEvent(QWheelEvent *event)
{
int numDegrees = event->delta() / 8;
int numDegrees = event->angleDelta().y() / 8;
double numSteps = numDegrees / 15.0f;
zoom(pow(ZoomInFactor, numSteps));
}

View File

@ -55,11 +55,10 @@ Window::Window(QWidget *parent)
m_iconSize(64, 64)
{
m_ui.setupUi(this);
QButtonGroup *buttonGroup = findChild<QButtonGroup *>(); // ### workaround for uic in 4.4
m_ui.easingCurvePicker->setIconSize(m_iconSize);
m_ui.easingCurvePicker->setMinimumHeight(m_iconSize.height() + 50);
buttonGroup->setId(m_ui.lineRadio, 0);
buttonGroup->setId(m_ui.circleRadio, 1);
m_ui.buttonGroup->setId(m_ui.lineRadio, 0);
m_ui.buttonGroup->setId(m_ui.circleRadio, 1);
QEasingCurve dummy;
m_ui.periodSpinBox->setValue(dummy.period());
@ -68,7 +67,7 @@ Window::Window(QWidget *parent)
connect(m_ui.easingCurvePicker, &QListWidget::currentRowChanged,
this, &Window::curveChanged);
connect(buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
connect(m_ui.buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
this, &Window::pathChanged);
connect(m_ui.periodSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &Window::periodChanged);

View File

@ -50,16 +50,13 @@
#include "animation.h"
#include <QPointF>
#include <QVector>
#include <QIODevice>
#include <QDataStream>
class Frame
{
public:
Frame() {
}
Frame() = default;
int nodeCount() const
{
@ -85,9 +82,8 @@ private:
QVector<QPointF> m_nodePositions;
};
Animation::Animation()
Animation::Animation() : m_currentFrame(0)
{
m_currentFrame = 0;
m_frames.append(new Frame);
}
@ -103,6 +99,8 @@ void Animation::setTotalFrames(int totalFrames)
while (totalFrames < m_frames.size())
delete m_frames.takeLast();
setCurrentFrame(m_currentFrame);
}
int Animation::totalFrames() const
@ -112,7 +110,7 @@ int Animation::totalFrames() const
void Animation::setCurrentFrame(int currentFrame)
{
m_currentFrame = qMax(qMin(currentFrame, totalFrames()-1), 0);
m_currentFrame = qBound(0, currentFrame, totalFrames() - 1);
}
int Animation::currentFrame() const
@ -177,18 +175,16 @@ void Animation::load(QIODevice *device)
int frameCount;
stream >> frameCount;
for (int i=0; i<frameCount; ++i) {
for (int i = 0; i < frameCount; ++i) {
int nodeCount;
stream >> nodeCount;
Frame *frame = new Frame;
frame->setNodeCount(nodeCount);
for (int j=0; j<nodeCount; ++j) {
for (int j = 0; j < nodeCount; ++j) {
QPointF pos;
stream >> pos;
frame->setNodePos(j, pos);
}

View File

@ -52,8 +52,8 @@
#define ANIMATION_H
#include <QPointF>
#include <QList>
#include <QString>
#include <QVector>
class Frame;
QT_BEGIN_NAMESPACE
@ -85,7 +85,7 @@ public:
private:
QString m_name;
QList<Frame *> m_frames;
QVector<Frame *> m_frames;
int m_currentFrame;
};

View File

@ -51,13 +51,8 @@
#include "graphicsview.h"
#include "stickman.h"
#include <QtGui/QKeyEvent>
#include <QtWidgets/QGraphicsScene>
#include <QtWidgets/QGraphicsView>
GraphicsView::GraphicsView(QWidget *parent)
: QGraphicsView(parent), m_editor(nullptr)
{}
#include <QKeyEvent>
#include <QGraphicsScene>
void GraphicsView::keyPressEvent(QKeyEvent *e)
{
@ -66,7 +61,8 @@ void GraphicsView::keyPressEvent(QKeyEvent *e)
emit keyPressed(Qt::Key(e->key()));
}
void GraphicsView::resizeEvent(QResizeEvent *)
void GraphicsView::resizeEvent(QResizeEvent *e)
{
fitInView(scene()->sceneRect());
QGraphicsView::resizeEvent(e);
}

View File

@ -51,24 +51,20 @@
#ifndef GRAPHICSVIEW_H
#define GRAPHICSVIEW_H
#include <QtWidgets/QGraphicsView>
#include <QGraphicsView>
class MainWindow;
class GraphicsView: public QGraphicsView
{
Q_OBJECT
public:
GraphicsView(QWidget *parent = nullptr);
using QGraphicsView::QGraphicsView;
protected:
void resizeEvent(QResizeEvent *event) override;
void keyPressEvent(QKeyEvent *) override;
void resizeEvent(QResizeEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
signals:
void keyPressed(int key);
private:
MainWindow *m_editor;
};
#endif

View File

@ -54,8 +54,15 @@
#include "animation.h"
#include "graphicsview.h"
#include <QtCore>
#include <QtWidgets>
#include <QEventTransition>
#include <QFile>
#include <QParallelAnimationGroup>
#include <QPropertyAnimation>
#include <QRandomGenerator>
#include <QSignalTransition>
#include <QState>
#include <QStateMachine>
#include <QTimer>
class KeyPressTransition: public QSignalTransition
{
@ -107,7 +114,7 @@ LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver)
// Create animation group to be used for all transitions
m_animationGroup = new QParallelAnimationGroup();
const int stickManNodeCount = m_stickMan->nodeCount();
for (int i=0; i<stickManNodeCount; ++i) {
for (int i = 0; i < stickManNodeCount; ++i) {
QPropertyAnimation *pa = new QPropertyAnimation(m_stickMan->node(i), "pos");
m_animationGroup->addAnimation(pa);
}
@ -175,7 +182,7 @@ void LifeCycle::addActivity(const QString &fileName, Qt::Key key, QObject *sende
QState *state = makeState(m_alive, fileName);
m_alive->addTransition(new KeyPressTransition(m_keyReceiver, key, state));
if (sender || signal)
if (sender && signal)
m_alive->addTransition(sender, signal, state);
}
@ -192,13 +199,13 @@ QState *LifeCycle::makeState(QState *parentState, const QString &animationFileNa
const int frameCount = animation.totalFrames();
QState *previousState = nullptr;
for (int i=0; i<frameCount; ++i) {
for (int i = 0; i < frameCount; ++i) {
animation.setCurrentFrame(i);
//! [1]
QState *frameState = new QState(topLevel);
const int nodeCount = animation.nodeCount();
for (int j=0; j<nodeCount; ++j)
for (int j = 0; j < nodeCount; ++j)
frameState->assignProperty(m_stickMan->node(j), "pos", animation.nodePos(j));
//! [1]

View File

@ -53,16 +53,16 @@
#include <Qt>
class StickMan;
QT_BEGIN_NAMESPACE
class QStateMachine;
class QAnimationGroup;
class QState;
class QAbstractState;
class QAbstractTransition;
class QAnimationGroup;
class QObject;
class QState;
class QStateMachine;
QT_END_NAMESPACE
class GraphicsView;
class StickMan;
class LifeCycle
{
public:
@ -70,7 +70,8 @@ public:
~LifeCycle();
void setDeathAnimation(const QString &fileName);
void addActivity(const QString &fileName, Qt::Key key, QObject *sender = NULL, const char *signal = NULL);
void addActivity(const QString &fileName, Qt::Key key,
QObject *sender = nullptr, const char *signal = nullptr);
void start();

View File

@ -51,13 +51,13 @@
#ifndef NODE_H
#define NODE_H
#include <QGraphicsItem>
#include <QGraphicsObject>
class Node: public QGraphicsObject
{
Q_OBJECT
public:
explicit Node(const QPointF &pos, QGraphicsItem *parent = 0);
explicit Node(const QPointF &pos, QGraphicsItem *parent = nullptr);
~Node();
QRectF boundingRect() const override;

View File

@ -51,12 +51,7 @@
#include "rectbutton.h"
#include <QPainter>
RectButton::RectButton(QString buttonText) : m_ButtonText(buttonText)
{
}
RectButton::~RectButton()
RectButton::RectButton(const QString &buttonText) : m_ButtonText(buttonText)
{
}

View File

@ -57,19 +57,19 @@ class RectButton : public QGraphicsObject
{
Q_OBJECT
public:
RectButton(QString buttonText);
~RectButton();
RectButton(const QString &buttonText);
QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
protected:
QString m_ButtonText;
void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
signals:
void clicked();
private:
QString m_ButtonText;
};
#endif // RECTBUTTON_H

View File

@ -52,10 +52,9 @@
#include "node.h"
#include <QPainter>
#include <QTimer>
#include <qmath.h>
#include <QtMath>
static const qreal Coords[NodeCount * 2] = {
static constexpr qreal Coords[NodeCount * 2] = {
0.0, -150.0, // head, #0
0.0, -100.0, // body pentagon, top->bottom, left->right, #1 - 5
@ -81,7 +80,7 @@ static const qreal Coords[NodeCount * 2] = {
};
static const int Bones[BoneCount * 2] = {
static constexpr int Bones[BoneCount * 2] = {
0, 1, // neck
1, 2, // body
@ -117,19 +116,13 @@ static const int Bones[BoneCount * 2] = {
StickMan::StickMan()
{
m_sticks = true;
m_isDead = false;
m_pixmap = QPixmap("images/head.png");
m_penColor = Qt::white;
m_fillColor = Qt::black;
// Set up start position of limbs
for (int i=0; i<NodeCount; ++i) {
for (int i = 0; i < NodeCount; ++i) {
m_nodes[i] = new Node(QPointF(Coords[i * 2], Coords[i * 2 + 1]), this);
connect(m_nodes[i], &Node::positionChanged, this, &StickMan::childPositionChanged);
}
for (int i=0; i<BoneCount; ++i) {
for (int i = 0; i < BoneCount; ++i) {
int n1 = Bones[i * 2];
int n2 = Bones[i * 2 + 1];
@ -137,16 +130,12 @@ StickMan::StickMan()
Node *node2 = m_nodes[n2];
QPointF dist = node1->pos() - node2->pos();
m_perfectBoneLengths[i] = sqrt(pow(dist.x(),2) + pow(dist.y(),2));
m_perfectBoneLengths[i] = sqrt(pow(dist.x(), 2) + pow(dist.y(), 2));
}
startTimer(10);
}
StickMan::~StickMan()
{
}
void StickMan::childPositionChanged()
{
prepareGeometryChange();
@ -155,7 +144,7 @@ void StickMan::childPositionChanged()
void StickMan::setDrawSticks(bool on)
{
m_sticks = on;
for (int i=0;i<nodeCount();++i) {
for (int i = 0; i < nodeCount(); ++i) {
Node *node = m_nodes[i];
node->setVisible(on);
}
@ -188,7 +177,7 @@ void StickMan::stabilize()
{
static const qreal threshold = 0.001;
for (int i=0; i<BoneCount; ++i) {
for (int i = 0; i < BoneCount; ++i) {
int n1 = Bones[i * 2];
int n2 = Bones[i * 2 + 1];
@ -236,7 +225,7 @@ void StickMan::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidge
stabilize();
if (m_sticks) {
painter->setPen(Qt::white);
for (int i=0; i<BoneCount; ++i) {
for (int i = 0; i < BoneCount; ++i) {
int n1 = Bones[i * 2];
int n2 = Bones[i * 2 + 1];

View File

@ -57,8 +57,6 @@ static const int NodeCount = 16;
static const int BoneCount = 24;
class Node;
QT_BEGIN_NAMESPACE
QT_END_NAMESPACE
class StickMan: public QGraphicsObject
{
Q_OBJECT
@ -67,7 +65,6 @@ class StickMan: public QGraphicsObject
Q_PROPERTY(bool isDead WRITE setIsDead READ isDead)
public:
StickMan();
~StickMan();
QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
@ -101,13 +98,11 @@ private:
Node *m_nodes[NodeCount];
qreal m_perfectBoneLengths[BoneCount];
uint m_sticks : 1;
uint m_isDead : 1;
uint m_reserved : 30;
bool m_sticks = true;
bool m_isDead = false;
QPixmap m_pixmap;
QColor m_penColor;
QColor m_fillColor;
QColor m_penColor = Qt::white;
QColor m_fillColor = Qt::black;
};
#endif // STICKMAN_H

View File

@ -51,22 +51,13 @@
//Own
#include "animationmanager.h"
//Qt
#include <QtCore/QAbstractAnimation>
#include <QtCore/QDebug>
// the universe's only animation manager
AnimationManager *AnimationManager::instance = nullptr;
AnimationManager::AnimationManager()
{
}
#include <QAbstractAnimation>
AnimationManager *AnimationManager::self()
{
if (!instance)
instance = new AnimationManager;
return instance;
// the universe's only animation manager
static AnimationManager s_instance;
return &s_instance;
}
void AnimationManager::registerAnimation(QAbstractAnimation *anim)

View File

@ -51,7 +51,7 @@
#ifndef ANIMATIONMANAGER_H
#define ANIMATIONMANAGER_H
#include <QtCore/QObject>
#include <QObject>
QT_BEGIN_NAMESPACE
class QAbstractAnimation;
@ -59,9 +59,10 @@ QT_END_NAMESPACE
class AnimationManager : public QObject
{
Q_OBJECT
Q_OBJECT
AnimationManager() = default;
~AnimationManager() = default;
public:
AnimationManager();
void registerAnimation(QAbstractAnimation *anim);
void unregisterAnimation(QAbstractAnimation *anim);
void unregisterAllAnimations();
@ -75,8 +76,7 @@ private slots:
void unregisterAnimation_helper(QObject *obj);
private:
static AnimationManager *instance;
QList<QAbstractAnimation *> animations;
QVector<QAbstractAnimation *> animations;
};
#endif // ANIMATIONMANAGER_H

View File

@ -52,18 +52,17 @@
#include "boat.h"
#include "boat_p.h"
#include "bomb.h"
#include "pixmapitem.h"
#include "graphicsscene.h"
#include "animationmanager.h"
#include "qanimationstate.h"
//Qt
#include <QtCore/QPropertyAnimation>
#include <QtCore/QStateMachine>
#include <QtCore/QHistoryState>
#include <QtCore/QFinalState>
#include <QtCore/QState>
#include <QtCore/QSequentialAnimationGroup>
#include <QFinalState>
#include <QHistoryState>
#include <QPropertyAnimation>
#include <QSequentialAnimationGroup>
#include <QState>
#include <QStateMachine>
static QAbstractAnimation *setupDestroyAnimation(Boat *boat)
{
@ -181,7 +180,7 @@ Boat::Boat()
launchStateLeft->addTransition(historyState);
launchStateRight->addTransition(historyState);
QFinalState *final = new QFinalState(machine);
QFinalState *finalState = new QFinalState(machine);
//This state play the destroyed animation
QAnimationState *destroyedState = new QAnimationState(machine);
@ -191,10 +190,10 @@ Boat::Boat()
moving->addTransition(this, &Boat::boatDestroyed, destroyedState);
//Transition to final state when the destroyed animation is finished
destroyedState->addTransition(destroyedState, &QAnimationState::animationFinished, final);
destroyedState->addTransition(destroyedState, &QAnimationState::animationFinished, finalState);
//The machine has finished to be executed, then the boat is dead
connect(machine,&QState::finished, this, &Boat::boatExecutionFinished);
connect(machine, &QState::finished, this, &Boat::boatExecutionFinished);
}

View File

@ -48,12 +48,11 @@
**
****************************************************************************/
#ifndef __BOAT__H__
#define __BOAT__H__
#ifndef BOAT_H
#define BOAT_H
#include "pixmapitem.h"
class Bomb;
QT_BEGIN_NAMESPACE
class QVariantAnimation;
class QAbstractAnimation;
@ -101,4 +100,4 @@ private:
QStateMachine *machine;
};
#endif //__BOAT__H__
#endif // BOAT_H

View File

@ -67,7 +67,9 @@
#include "graphicsscene.h"
// Qt
#include <QtWidgets/QKeyEventTransition>
#include <QGraphicsRotation>
#include <QKeyEventTransition>
#include <QState>
static const int MAX_BOMB = 5;
@ -88,7 +90,7 @@ protected:
return (boat->currentSpeed() == 1);
}
private:
Boat * boat;
Boat *boat;
};
//These transtion test if we have to move the boat (i.e current speed was 0 or another value)
@ -118,7 +120,7 @@ protected:
boat->updateBoatMovement();
}
private:
Boat * boat;
Boat *boat;
int key;
};
@ -139,7 +141,7 @@ protected:
return (boat->bombsLaunched() < MAX_BOMB);
}
private:
Boat * boat;
Boat *boat;
};
//This state is describing when the boat is moving right
@ -157,7 +159,7 @@ protected:
boat->updateBoatMovement();
}
private:
Boat * boat;
Boat *boat;
};
//This state is describing when the boat is moving left
@ -175,7 +177,7 @@ protected:
boat->updateBoatMovement();
}
private:
Boat * boat;
Boat *boat;
};
//This state is describing when the boat is in a stand by position
@ -194,7 +196,7 @@ protected:
boat->updateBoatMovement();
}
private:
Boat * boat;
Boat *boat;
};
//This state is describing the launch of the torpedo on the right
@ -216,7 +218,7 @@ protected:
boat->setBombsLaunched(boat->bombsLaunched() + 1);
}
private:
Boat * boat;
Boat *boat;
};
//This state is describing the launch of the torpedo on the left
@ -238,7 +240,7 @@ protected:
boat->setBombsLaunched(boat->bombsLaunched() + 1);
}
private:
Boat * boat;
Boat *boat;
};
#endif // BOAT_P_H

View File

@ -51,15 +51,14 @@
//Own
#include "bomb.h"
#include "submarine.h"
#include "pixmapitem.h"
#include "animationmanager.h"
#include "qanimationstate.h"
//Qt
#include <QtCore/QSequentialAnimationGroup>
#include <QtCore/QPropertyAnimation>
#include <QtCore/QStateMachine>
#include <QtCore/QFinalState>
#include <QFinalState>
#include <QPropertyAnimation>
#include <QSequentialAnimationGroup>
#include <QStateMachine>
Bomb::Bomb() : PixmapItem(QString("bomb"), GraphicsScene::Big)
{
@ -83,7 +82,7 @@ void Bomb::launch(Bomb::Direction direction)
anim->setEndValue(QPointF(x() + delta*2,scene()->height()));
anim->setDuration(y()/2*60);
launchAnimation->addAnimation(anim);
connect(anim,&QVariantAnimation::valueChanged,this,&Bomb::onAnimationLaunchValueChanged);
connect(anim, &QVariantAnimation::valueChanged, this, &Bomb::onAnimationLaunchValueChanged);
connect(this, &Bomb::bombExploded, launchAnimation, &QAbstractAnimation::stop);
//We setup the state machine of the bomb
QStateMachine *machine = new QStateMachine(this);
@ -93,18 +92,18 @@ void Bomb::launch(Bomb::Direction direction)
launched->setAnimation(launchAnimation);
//End
QFinalState *final = new QFinalState(machine);
QFinalState *finalState = new QFinalState(machine);
machine->setInitialState(launched);
//### Add a nice animation when the bomb is destroyed
launched->addTransition(this, &Bomb::bombExploded,final);
launched->addTransition(this, &Bomb::bombExploded, finalState);
//If the animation is finished, then we move to the final state
launched->addTransition(launched, &QAnimationState::animationFinished, final);
launched->addTransition(launched, &QAnimationState::animationFinished, finalState);
//The machine has finished to be executed, then the boat is dead
connect(machine,&QState::finished,this, &Bomb::bombExecutionFinished);
connect(machine,&QState::finished, this, &Bomb::bombExecutionFinished);
machine->start();

View File

@ -48,8 +48,8 @@
**
****************************************************************************/
#ifndef __BOMB__H__
#define __BOMB__H__
#ifndef BOMB_H
#define BOMB_H
#include "pixmapitem.h"
@ -73,4 +73,4 @@ private slots:
void onAnimationLaunchValueChanged(const QVariant &);
};
#endif //__BOMB__H__
#endif // BOMB_H

View File

@ -55,38 +55,33 @@
#include "submarine.h"
#include "torpedo.h"
#include "bomb.h"
#include "pixmapitem.h"
#include "animationmanager.h"
#include "qanimationstate.h"
#include "progressitem.h"
#include "textinformationitem.h"
//Qt
#include <QtCore/QPropertyAnimation>
#include <QtCore/QSequentialAnimationGroup>
#include <QtCore/QParallelAnimationGroup>
#include <QtCore/QStateMachine>
#include <QtCore/QFinalState>
#include <QtCore/QPauseAnimation>
#include <QtWidgets/QAction>
#include <QtCore/QDir>
#include <QtWidgets/QApplication>
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QGraphicsView>
#include <QtWidgets/QGraphicsSceneMouseEvent>
#include <QtCore/QXmlStreamReader>
#include <QAction>
#include <QApplication>
#include <QFile>
#include <QFinalState>
#include <QParallelAnimationGroup>
#include <QPropertyAnimation>
#include <QSequentialAnimationGroup>
#include <QStateMachine>
#include <QXmlStreamReader>
GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode)
: QGraphicsScene(x , y, width, height), mode(mode), boat(new Boat)
GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode, QObject *parent)
: QGraphicsScene(x, y, width, height, parent), mode(mode), boat(new Boat)
{
PixmapItem *backgroundItem = new PixmapItem(QString("background"),mode);
PixmapItem *backgroundItem = new PixmapItem(QStringLiteral("background"), mode);
backgroundItem->setZValue(1);
backgroundItem->setPos(0,0);
addItem(backgroundItem);
PixmapItem *surfaceItem = new PixmapItem(QString("surface"),mode);
PixmapItem *surfaceItem = new PixmapItem(QStringLiteral("surface"), mode);
surfaceItem->setZValue(3);
surfaceItem->setPos(0,sealLevel() - surfaceItem->boundingRect().height()/2);
surfaceItem->setPos(0, sealLevel() - surfaceItem->boundingRect().height() / 2);
addItem(surfaceItem);
//The item that display score and level
@ -137,8 +132,8 @@ qreal GraphicsScene::sealLevel() const
void GraphicsScene::setupScene(QAction *newAction, QAction *quitAction)
{
static const int nLetters = 10;
static struct {
static constexpr int nLetters = 10;
static constexpr struct {
char const *pix;
qreal initX, initY;
qreal destX, destY;
@ -154,8 +149,8 @@ void GraphicsScene::setupScene(QAction *newAction, QAction *quitAction)
{"q", 200, 2000, 510, 250 },
{"excl", 0, 2000, 570, 220 } };
QSequentialAnimationGroup * lettersGroupMoving = new QSequentialAnimationGroup(this);
QParallelAnimationGroup * lettersGroupFading = new QParallelAnimationGroup(this);
QSequentialAnimationGroup *lettersGroupMoving = new QSequentialAnimationGroup(this);
QParallelAnimationGroup *lettersGroupFading = new QParallelAnimationGroup(this);
for (int i = 0; i < nLetters; ++i) {
PixmapItem *logo = new PixmapItem(QLatin1String(":/logo-") + logoData[i].pix, this);
@ -180,7 +175,7 @@ void GraphicsScene::setupScene(QAction *newAction, QAction *quitAction)
PlayState *gameState = new PlayState(this, machine);
//Final state
QFinalState *final = new QFinalState(machine);
QFinalState *finalState = new QFinalState(machine);
//Animation when the player enter in the game
QAnimationState *lettersMovingState = new QAnimationState(machine);
@ -198,8 +193,8 @@ void GraphicsScene::setupScene(QAction *newAction, QAction *quitAction)
gameState->addTransition(newAction, &QAction::triggered, gameState);
//Wanna quit, then connect to CTRL+Q
gameState->addTransition(quitAction, &QAction::triggered, final);
lettersMovingState->addTransition(quitAction, &QAction::triggered, final);
gameState->addTransition(quitAction, &QAction::triggered, finalState);
lettersMovingState->addTransition(quitAction, &QAction::triggered, finalState);
//Welcome screen is the initial state
machine->setInitialState(lettersMovingState);
@ -213,21 +208,24 @@ void GraphicsScene::setupScene(QAction *newAction, QAction *quitAction)
void GraphicsScene::addItem(Bomb *bomb)
{
bombs.insert(bomb);
connect(bomb,&Bomb::bombExecutionFinished,this, &GraphicsScene::onBombExecutionFinished);
connect(bomb, &Bomb::bombExecutionFinished,
this, &GraphicsScene::onBombExecutionFinished);
QGraphicsScene::addItem(bomb);
}
void GraphicsScene::addItem(Torpedo *torpedo)
{
torpedos.insert(torpedo);
connect(torpedo,&Torpedo::torpedoExecutionFinished,this, &GraphicsScene::onTorpedoExecutionFinished);
connect(torpedo, &Torpedo::torpedoExecutionFinished,
this, &GraphicsScene::onTorpedoExecutionFinished);
QGraphicsScene::addItem(torpedo);
}
void GraphicsScene::addItem(SubMarine *submarine)
{
submarines.insert(submarine);
connect(submarine,&SubMarine::subMarineExecutionFinished,this, &GraphicsScene::onSubMarineExecutionFinished);
connect(submarine, &SubMarine::subMarineExecutionFinished,
this, &GraphicsScene::onSubMarineExecutionFinished);
QGraphicsScene::addItem(submarine);
}
@ -239,15 +237,18 @@ void GraphicsScene::addItem(QGraphicsItem *item)
void GraphicsScene::onBombExecutionFinished()
{
Bomb *bomb = qobject_cast<Bomb *>(sender());
if (!bomb)
return;
bombs.remove(bomb);
bomb->deleteLater();
if (boat)
boat->setBombsLaunched(boat->bombsLaunched() - 1);
boat->setBombsLaunched(boat->bombsLaunched() - 1);
}
void GraphicsScene::onTorpedoExecutionFinished()
{
Torpedo *torpedo = qobject_cast<Torpedo *>(sender());
if (!torpedo)
return;
torpedos.remove(torpedo);
torpedo->deleteLater();
}
@ -255,6 +256,8 @@ void GraphicsScene::onTorpedoExecutionFinished()
void GraphicsScene::onSubMarineExecutionFinished()
{
SubMarine *submarine = qobject_cast<SubMarine *>(sender());
if (!submarine)
return;
submarines.remove(submarine);
if (submarines.count() == 0)
emit allSubMarineDestroyed(submarine->points());
@ -266,16 +269,22 @@ void GraphicsScene::onSubMarineExecutionFinished()
void GraphicsScene::clearScene()
{
for (SubMarine *sub : qAsConst(submarines)) {
// make sure to not go into onSubMarineExecutionFinished
sub->disconnect(this);
sub->destroy();
sub->deleteLater();
}
for (Torpedo *torpedo : qAsConst(torpedos)) {
// make sure to not go into onTorpedoExecutionFinished
torpedo->disconnect(this);
torpedo->destroy();
torpedo->deleteLater();
}
for (Bomb *bomb : qAsConst(bombs)) {
// make sure to not go into onBombExecutionFinished
bomb->disconnect(this);
bomb->destroy();
bomb->deleteLater();
}

View File

@ -48,13 +48,12 @@
**
****************************************************************************/
#ifndef __GRAPHICSSCENE__H__
#define __GRAPHICSSCENE__H__
#ifndef GRAPHICSSCENE_H
#define GRAPHICSSCENE_H
//Qt
#include <QtWidgets/QGraphicsScene>
#include <QtCore/QSet>
#include <QtCore/QState>
#include <QGraphicsScene>
#include <QSet>
class Boat;
@ -78,18 +77,18 @@ public:
};
struct SubmarineDescription {
int type;
int points;
int type = 0;
int points = 0;
QString name;
};
struct LevelDescription {
int id;
int id = 0;
QString name;
QList<QPair<int,int> > submarines;
QVector<QPair<int, int>> submarines;
};
GraphicsScene(int x, int y, int width, int height, Mode mode = Big);
GraphicsScene(int x, int y, int width, int height, Mode mode, QObject *parent = nullptr);
qreal sealLevel() const;
void setupScene(QAction *newAction, QAction *quitAction);
void addItem(Bomb *bomb);
@ -127,5 +126,5 @@ private:
friend class UpdateScoreTransition;
};
#endif //__GRAPHICSSCENE__H__
#endif // GRAPHICSSCENE_H

View File

@ -56,11 +56,10 @@
#include <QGraphicsView>
#include <QApplication>
#include <QMenu>
#include <QMenuBar>
#include <QLayout>
#ifndef QT_NO_OPENGL
# include <QtOpenGL/QtOpenGL>
# include <QtOpenGL>
#endif
MainWindow::MainWindow(QWidget *parent)
@ -74,10 +73,10 @@ MainWindow::MainWindow(QWidget *parent)
quitAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q));
if (QApplication::arguments().contains("-fullscreen")) {
scene = new GraphicsScene(0, 0, 750, 400, GraphicsScene::Small);
scene = new GraphicsScene(0, 0, 750, 400, GraphicsScene::Small, this);
setWindowState(Qt::WindowFullScreen);
} else {
scene = new GraphicsScene(0, 0, 880, 630);
scene = new GraphicsScene(0, 0, 880, 630, GraphicsScene::Big, this);
layout()->setSizeConstraint(QLayout::SetFixedSize);
}

View File

@ -48,11 +48,11 @@
**
****************************************************************************/
#ifndef __MAINWINDOW__H__
#define __MAINWINDOW__H__
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
//Qt
#include <QtWidgets/QMainWindow>
#include <QMainWindow>
class GraphicsScene;
QT_BEGIN_NAMESPACE
class QGraphicsView;
@ -69,4 +69,4 @@ private:
QGraphicsView *view;
};
#endif //__MAINWINDOW__H__
#endif // MAINWINDOW_H

View File

@ -54,7 +54,7 @@
//Qt
#include <QPainter>
PixmapItem::PixmapItem(const QString &fileName,GraphicsScene::Mode mode, QGraphicsItem * parent)
PixmapItem::PixmapItem(const QString &fileName, GraphicsScene::Mode mode, QGraphicsItem *parent)
: QGraphicsObject(parent)
{
if (mode == GraphicsScene::Big)
@ -63,7 +63,8 @@ PixmapItem::PixmapItem(const QString &fileName,GraphicsScene::Mode mode, QGraphi
pix = QPixmap(QStringLiteral(":/small/") + fileName);
}
PixmapItem::PixmapItem(const QString &fileName, QGraphicsScene *scene) : QGraphicsObject(), pix(fileName)
PixmapItem::PixmapItem(const QString &fileName, QGraphicsScene *scene)
: QGraphicsObject(), pix(fileName)
{
scene->addItem(this);
}

View File

@ -48,14 +48,14 @@
**
****************************************************************************/
#ifndef __PIXMAPITEM__H__
#define __PIXMAPITEM__H__
#ifndef PIXMAPITEM_H
#define PIXMAPITEM_H
//Own
#include "graphicsscene.h"
//Qt
#include <QtWidgets/QGraphicsObject>
#include <QGraphicsObject>
class PixmapItem : public QGraphicsObject
{
@ -69,4 +69,4 @@ private:
QPixmap pix;
};
#endif //__PIXMAPITEM__H__
#endif // PIXMAPITEM_H

View File

@ -49,10 +49,11 @@
****************************************************************************/
#include "progressitem.h"
#include "pixmapitem.h"
ProgressItem::ProgressItem (QGraphicsItem * parent)
: QGraphicsTextItem(parent), currentLevel(1), currentScore(0)
#include <QFont>
ProgressItem::ProgressItem(QGraphicsItem *parent)
: QGraphicsTextItem(parent)
{
setFont(QFont("Comic Sans MS"));
setPos(parentItem()->boundingRect().topRight() - QPointF(180, -5));

View File

@ -52,19 +52,19 @@
#define PROGRESSITEM_H
//Qt
#include <QtWidgets/QGraphicsTextItem>
#include <QGraphicsTextItem>
class ProgressItem : public QGraphicsTextItem
{
public:
ProgressItem(QGraphicsItem * parent = 0);
ProgressItem(QGraphicsItem *parent = nullptr);
void setLevel(int level);
void setScore(int score);
private:
void updateProgress();
int currentLevel;
int currentScore;
int currentLevel = 1;
int currentScore = 0;
};
#endif // PROGRESSITEM_H

View File

@ -50,7 +50,7 @@
#include "qanimationstate.h"
#include <QtCore/qstate.h>
#include <QAbstractAnimation>
QT_BEGIN_NAMESPACE
@ -106,7 +106,7 @@ void QAnimationState::setAnimation(QAbstractAnimation *animation)
return;
//Disconnect from the previous animation if exist
if(m_animation)
if (m_animation)
disconnect(m_animation, &QAbstractAnimation::finished, this, &QAnimationState::animationFinished);
m_animation = animation;

View File

@ -51,13 +51,7 @@
#ifndef QANIMATIONSTATE_H
#define QANIMATIONSTATE_H
#ifndef QT_STATEMACHINE_SOLUTION
# include <QtCore/qstate.h>
# include <QtCore/qabstractanimation.h>
#else
# include "qstate.h"
# include "qabstractanimation.h"
#endif
#include <QState>
QT_BEGIN_NAMESPACE
@ -67,7 +61,7 @@ class QAnimationState : public QState
{
Q_OBJECT
public:
QAnimationState(QState *parent = 0);
QAnimationState(QState *parent = nullptr);
~QAnimationState();
void setAnimation(QAbstractAnimation *animation);

View File

@ -59,12 +59,12 @@
#include "textinformationitem.h"
//Qt
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QGraphicsView>
#include <QtCore/QStateMachine>
#include <QtWidgets/QKeyEventTransition>
#include <QtCore/QFinalState>
#include <QtCore/QRandomGenerator>
#include <QFinalState>
#include <QGraphicsView>
#include <QKeyEventTransition>
#include <QMessageBox>
#include <QRandomGenerator>
#include <QStateMachine>
PlayState::PlayState(GraphicsScene *scene, QState *parent)
: QState(parent), scene(scene), machine(nullptr),
@ -146,7 +146,7 @@ void PlayState::onEntry(QEvent *)
machine->setInitialState(levelState);
//Final state
QFinalState *final = new QFinalState(machine);
QFinalState *finalState = new QFinalState(machine);
//This transition is triggered when the player press space after completing a level
CustomSpaceTransition *spaceTransition = new CustomSpaceTransition(scene->views().at(0), this, QEvent::KeyPress, Qt::Key_Space);
@ -154,7 +154,7 @@ void PlayState::onEntry(QEvent *)
winState->addTransition(spaceTransition);
//We lost we should reach the final state
lostState->addTransition(lostState, &QState::finished, final);
lostState->addTransition(lostState, &QState::finished, finalState);
machine->start();
}
@ -181,11 +181,9 @@ void LevelState::initializeLevel()
scene->progressItem->setScore(game->score);
scene->progressItem->setLevel(game->currentLevel + 1);
GraphicsScene::LevelDescription currentLevelDescription = scene->levelsData.value(game->currentLevel);
const GraphicsScene::LevelDescription currentLevelDescription = scene->levelsData.value(game->currentLevel);
for (const QPair<int,int> &subContent : currentLevelDescription.submarines) {
for (int i = 0; i < currentLevelDescription.submarines.size(); ++i ) {
QPair<int,int> subContent = currentLevelDescription.submarines.at(i);
GraphicsScene::SubmarineDescription submarineDesc = scene->submarinesData.at(subContent.first);
for (int j = 0; j < subContent.second; ++j ) {
@ -202,9 +200,10 @@ void LevelState::initializeLevel()
}
/** Pause State */
PauseState::PauseState(GraphicsScene *scene, QState *parent) : QState(parent),scene(scene)
PauseState::PauseState(GraphicsScene *scene, QState *parent) : QState(parent), scene(scene)
{
}
void PauseState::onEntry(QEvent *)
{
AnimationManager::self()->pauseAll();
@ -324,8 +323,7 @@ bool WinTransition::eventTest(QEvent *event)
/** Space transition */
CustomSpaceTransition::CustomSpaceTransition(QWidget *widget, PlayState *game, QEvent::Type type, int key)
: QKeyEventTransition(widget, type, key),
game(game)
: QKeyEventTransition(widget, type, key), game(game)
{
}

View File

@ -52,15 +52,11 @@
#define STATES_H
//Qt
#include <QtCore/QState>
#include <QtCore/QSignalTransition>
#include <QtCore/QPropertyAnimation>
#include <QtWidgets/QKeyEventTransition>
#include <QtCore/QSet>
#include <QKeyEventTransition>
#include <QSignalTransition>
#include <QState>
class GraphicsScene;
class Boat;
class SubMarine;
QT_BEGIN_NAMESPACE
class QStateMachine;
QT_END_NAMESPACE
@ -68,7 +64,7 @@ QT_END_NAMESPACE
class PlayState : public QState
{
public:
explicit PlayState(GraphicsScene *scene, QState *parent = 0);
explicit PlayState(GraphicsScene *scene, QState *parent = nullptr);
~PlayState();
protected:
@ -92,7 +88,7 @@ private :
class LevelState : public QState
{
public:
LevelState(GraphicsScene *scene, PlayState *game, QState *parent = 0);
LevelState(GraphicsScene *scene, PlayState *game, QState *parent = nullptr);
protected:
void onEntry(QEvent *) override;
private :
@ -104,7 +100,7 @@ private :
class PauseState : public QState
{
public:
explicit PauseState(GraphicsScene *scene, QState *parent = 0);
explicit PauseState(GraphicsScene *scene, QState *parent = nullptr);
protected:
void onEntry(QEvent *) override;
@ -116,7 +112,7 @@ private :
class LostState : public QState
{
public:
LostState(GraphicsScene *scene, PlayState *game, QState *parent = 0);
LostState(GraphicsScene *scene, PlayState *game, QState *parent = nullptr);
protected:
void onEntry(QEvent *) override;
@ -129,7 +125,7 @@ private :
class WinState : public QState
{
public:
WinState(GraphicsScene *scene, PlayState *game, QState *parent = 0);
WinState(GraphicsScene *scene, PlayState *game, QState *parent = nullptr);
protected:
void onEntry(QEvent *) override;
@ -154,7 +150,7 @@ public:
protected:
bool eventTest(QEvent *event) override;
private:
PlayState * game;
PlayState *game;
GraphicsScene *scene;
};
@ -166,7 +162,7 @@ public:
protected:
bool eventTest(QEvent *event) override;
private:
PlayState * game;
PlayState *game;
GraphicsScene *scene;
};

View File

@ -52,15 +52,14 @@
#include "submarine.h"
#include "submarine_p.h"
#include "torpedo.h"
#include "pixmapitem.h"
#include "graphicsscene.h"
#include "animationmanager.h"
#include "qanimationstate.h"
#include <QtCore/QPropertyAnimation>
#include <QtCore/QStateMachine>
#include <QtCore/QFinalState>
#include <QtCore/QSequentialAnimationGroup>
#include <QFinalState>
#include <QPropertyAnimation>
#include <QStateMachine>
#include <QSequentialAnimationGroup>
static QAbstractAnimation *setupDestroyAnimation(SubMarine *sub)
{
@ -86,9 +85,8 @@ SubMarine::SubMarine(int type, const QString &name, int points) : PixmapItem(QSt
graphicsRotation = new QGraphicsRotation(this);
graphicsRotation->setAxis(Qt::YAxis);
graphicsRotation->setOrigin(QVector3D(size().width()/2, size().height()/2, 0));
QList<QGraphicsTransform *> r;
r.append(graphicsRotation);
graphicsRotation->setOrigin(QVector3D(size().width() / 2, size().height() / 2, 0));
QList<QGraphicsTransform *> r({graphicsRotation});
setTransformations(r);
//We setup the state machine of the submarine
@ -112,7 +110,7 @@ SubMarine::SubMarine(int type, const QString &name, int points) : PixmapItem(QSt
machine->setInitialState(moving);
//End
QFinalState *final = new QFinalState(machine);
QFinalState *finalState = new QFinalState(machine);
//If the moving animation is finished we move to the return state
movement->addTransition(movement, &QAnimationState::animationFinished, rotation);
@ -128,7 +126,7 @@ SubMarine::SubMarine(int type, const QString &name, int points) : PixmapItem(QSt
moving->addTransition(this, &SubMarine::subMarineDestroyed, destroyedState);
//Transition to final state when the destroyed animation is finished
destroyedState->addTransition(destroyedState, &QAnimationState::animationFinished, final);
destroyedState->addTransition(destroyedState, &QAnimationState::animationFinished, finalState);
//The machine has finished to be executed, then the submarine is dead
connect(machine,&QState::finished,this, &SubMarine::subMarineExecutionFinished);
@ -145,9 +143,8 @@ void SubMarine::setCurrentDirection(SubMarine::Movement direction)
{
if (this->direction == direction)
return;
if (direction == SubMarine::Right && this->direction == SubMarine::None) {
if (direction == SubMarine::Right && this->direction == SubMarine::None)
graphicsRotation->setAngle(180);
}
this->direction = direction;
}
@ -158,9 +155,8 @@ enum SubMarine::Movement SubMarine::currentDirection() const
void SubMarine::setCurrentSpeed(int speed)
{
if (speed < 0 || speed > 3) {
if (speed < 0 || speed > 3)
qWarning("SubMarine::setCurrentSpeed : The speed is invalid");
}
this->speed = speed;
emit subMarineStateChanged();
}
@ -172,7 +168,7 @@ int SubMarine::currentSpeed() const
void SubMarine::launchTorpedo(int speed)
{
Torpedo * torp = new Torpedo();
Torpedo *torp = new Torpedo;
GraphicsScene *scene = static_cast<GraphicsScene *>(this->scene());
scene->addItem(torp);
torp->setPos(pos());

View File

@ -48,15 +48,12 @@
**
****************************************************************************/
#ifndef __SUBMARINE__H__
#define __SUBMARINE__H__
//Qt
#include <QtWidgets/QGraphicsTransform>
#ifndef SUBMARINE_H
#define SUBMARINE_H
#include "pixmapitem.h"
class Torpedo;
#include <QGraphicsRotation>
class SubMarine : public PixmapItem
{
@ -99,4 +96,4 @@ private:
QGraphicsRotation *graphicsRotation;
};
#endif //__SUBMARINE__H__
#endif // SUBMARINE_H

View File

@ -68,16 +68,15 @@
#include "qanimationstate.h"
//Qt
#include <QtCore/QPropertyAnimation>
#include <QtCore/QRandomGenerator>
#include <QtWidgets/QGraphicsScene>
#include <QPropertyAnimation>
#include <QRandomGenerator>
//This state is describing when the boat is moving right
class MovementState : public QAnimationState
{
Q_OBJECT
public:
explicit MovementState(SubMarine *submarine, QState *parent = 0) : QAnimationState(parent)
explicit MovementState(SubMarine *submarine, QState *parent = nullptr) : QAnimationState(parent)
{
movementAnimation = new QPropertyAnimation(submarine, "pos");
connect(movementAnimation, &QPropertyAnimation::valueChanged,
@ -117,7 +116,7 @@ private:
class ReturnState : public QAnimationState
{
public:
explicit ReturnState(SubMarine *submarine, QState *parent = 0) : QAnimationState(parent)
explicit ReturnState(SubMarine *submarine, QState *parent = nullptr) : QAnimationState(parent)
{
returnAnimation = new QPropertyAnimation(submarine->rotation(), "angle");
returnAnimation->setDuration(500);

View File

@ -50,14 +50,15 @@
#include "textinformationitem.h"
#include "pixmapitem.h"
TextInformationItem::TextInformationItem (QGraphicsItem * parent)
TextInformationItem::TextInformationItem (QGraphicsItem *parent)
: QGraphicsTextItem(parent)
{
setFont(QFont("Comic Sans MS", 15));
}
#include <QDebug>
void TextInformationItem::setMessage(const QString& text)
void TextInformationItem::setMessage(const QString &text)
{
setHtml(text);
setPos(parentItem()->boundingRect().center().x() - boundingRect().size().width()/2 , parentItem()->boundingRect().center().y());
setPos(parentItem()->boundingRect().center().x() - boundingRect().size().width() / 2,
parentItem()->boundingRect().center().y());
}

View File

@ -52,13 +52,13 @@
#define TEXTINFORMATIONITEM_H
//Qt
#include <QtWidgets/QGraphicsTextItem>
#include <QGraphicsTextItem>
class TextInformationItem : public QGraphicsTextItem
{
public:
TextInformationItem(QGraphicsItem * parent = 0);
void setMessage(const QString& text);
TextInformationItem(QGraphicsItem *parent = nullptr);
void setMessage(const QString &text);
};
#endif // TEXTINFORMATIONITEM_H

View File

@ -50,15 +50,14 @@
//Own
#include "torpedo.h"
#include "pixmapitem.h"
#include "boat.h"
#include "graphicsscene.h"
#include "animationmanager.h"
#include "qanimationstate.h"
#include <QtCore/QPropertyAnimation>
#include <QtCore/QStateMachine>
#include <QtCore/QFinalState>
#include <QPropertyAnimation>
#include <QStateMachine>
#include <QFinalState>
Torpedo::Torpedo() : PixmapItem(QString::fromLatin1("torpedo"),GraphicsScene::Big),
currentSpeed(0)
@ -70,11 +69,11 @@ void Torpedo::launch()
{
QPropertyAnimation *launchAnimation = new QPropertyAnimation(this, "pos");
AnimationManager::self()->registerAnimation(launchAnimation);
launchAnimation->setEndValue(QPointF(x(),qobject_cast<GraphicsScene *>(scene())->sealLevel() - 15));
launchAnimation->setEndValue(QPointF(x(), qobject_cast<GraphicsScene *>(scene())->sealLevel() - 15));
launchAnimation->setEasingCurve(QEasingCurve::InQuad);
launchAnimation->setDuration(y()/currentSpeed*10);
connect(launchAnimation,&QVariantAnimation::valueChanged,this,&Torpedo::onAnimationLaunchValueChanged);
connect(this,&Torpedo::torpedoExploded, launchAnimation, &QAbstractAnimation::stop);
launchAnimation->setDuration(y() / currentSpeed * 10);
connect(launchAnimation, &QVariantAnimation::valueChanged, this, &Torpedo::onAnimationLaunchValueChanged);
connect(this, &Torpedo::torpedoExploded, launchAnimation, &QAbstractAnimation::stop);
//We setup the state machine of the torpedo
QStateMachine *machine = new QStateMachine(this);
@ -84,18 +83,18 @@ void Torpedo::launch()
launched->setAnimation(launchAnimation);
//End
QFinalState *final = new QFinalState(machine);
QFinalState *finalState = new QFinalState(machine);
machine->setInitialState(launched);
//### Add a nice animation when the torpedo is destroyed
launched->addTransition(this, &Torpedo::torpedoExploded,final);
launched->addTransition(this, &Torpedo::torpedoExploded, finalState);
//If the animation is finished, then we move to the final state
launched->addTransition(launched, &QAnimationState::animationFinished, final);
launched->addTransition(launched, &QAnimationState::animationFinished, finalState);
//The machine has finished to be executed, then the boat is dead
connect(machine,&QState::finished,this, &Torpedo::torpedoExecutionFinished);
connect(machine, &QState::finished, this, &Torpedo::torpedoExecutionFinished);
machine->start();
}

View File

@ -48,8 +48,8 @@
**
****************************************************************************/
#ifndef __TORPEDO__H__
#define __TORPEDO__H__
#ifndef TORPEDO_H
#define TORPEDO_H
#include "pixmapitem.h"
@ -73,4 +73,4 @@ private:
int currentSpeed;
};
#endif //__TORPEDO__H__
#endif // TORPEDO_H

View File

@ -128,10 +128,6 @@ void ColorEdit::mousePressEvent(QMouseEvent *event)
QColor color(m_color);
QColorDialog dialog(color, 0);
dialog.setOption(QColorDialog::ShowAlphaChannel, true);
// The ifdef block is a workaround for the beta, TODO: remove when bug 238525 is fixed
#if 0 // Used to be included in Qt4 for Q_WS_MAC
dialog.setOption(QColorDialog::DontUseNativeDialog, true);
#endif
dialog.move(280, 120);
if (dialog.exec() == QDialog::Rejected)
return;

View File

@ -68,7 +68,7 @@
void GraphicsView::wheelEvent(QWheelEvent *e)
{
if (e->modifiers() & Qt::ControlModifier) {
if (e->delta() > 0)
if (e->angleDelta().y() > 0)
view->zoomIn(6);
else
view->zoomOut(6);

View File

@ -190,7 +190,7 @@ void GraphWidget::timerEvent(QTimerEvent *event)
//! [5]
void GraphWidget::wheelEvent(QWheelEvent *event)
{
scaleView(pow((double)2, -event->delta() / 240.0));
scaleView(pow((double)2, -event->angleDelta().y() / 240.0));
}
//! [5]
#endif

View File

@ -65,8 +65,10 @@ int main(int argc, char *argv[])
parser.setApplicationDescription("Qt Dir View Example");
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption dontUseCustomDirectoryIconsOption("c", "Set QFileIconProvider::DontUseCustomDirectoryIcons");
QCommandLineOption dontUseCustomDirectoryIconsOption("c", "Set QFileSystemModel::DontUseCustomDirectoryIcons");
parser.addOption(dontUseCustomDirectoryIconsOption);
QCommandLineOption dontWatchOption("w", "Set QFileSystemModel::DontWatch");
parser.addOption(dontWatchOption);
parser.addPositionalArgument("directory", "The directory to start in.");
parser.process(app);
const QString rootPath = parser.positionalArguments().isEmpty()
@ -75,7 +77,9 @@ int main(int argc, char *argv[])
QFileSystemModel model;
model.setRootPath("");
if (parser.isSet(dontUseCustomDirectoryIconsOption))
model.iconProvider()->setOptions(QFileIconProvider::DontUseCustomDirectoryIcons);
model.setOption(QFileSystemModel::DontUseCustomDirectoryIcons);
if (parser.isSet(dontWatchOption))
model.setOption(QFileSystemModel::DontWatchForChanges);
QTreeView tree;
tree.setModel(&model);
if (!rootPath.isEmpty()) {

View File

@ -260,7 +260,7 @@ void XFormView::timerEvent(QTimerEvent *e)
#if QT_CONFIG(wheelevent)
void XFormView::wheelEvent(QWheelEvent *e)
{
m_scale += e->delta() / qreal(600);
m_scale += e->angleDelta().y() / qreal(600);
m_scale = qMax(qreal(0.1), qMin(qreal(4), m_scale));
emit scaleChanged(int(m_scale*1000));
}

View File

@ -248,7 +248,7 @@ static const char *encodingToolTips[]
{
QT_TRANSLATE_NOOP("EncodingDialog", "Unicode points for use with any encoding (C++, Python)"),
QT_TRANSLATE_NOOP("EncodingDialog", "QString::fromUtf8()"),
QT_TRANSLATE_NOOP("EncodingDialog", "QStringViewLiteral(), wchar_t on Windows"),
QT_TRANSLATE_NOOP("EncodingDialog", "wchar_t on Windows, char16_t everywhere"),
QT_TRANSLATE_NOOP("EncodingDialog", "wchar_t on Unix (Ucs4)"),
QT_TRANSLATE_NOOP("EncodingDialog", "QLatin1String")
};

View File

@ -53,12 +53,6 @@
#include "languagechooser.h"
#include "mainwindow.h"
#if 0 // Used to be included in Qt4 for Q_WS_MAC
QT_BEGIN_NAMESPACE
extern void qt_mac_set_menubar_merge(bool merge);
QT_END_NAMESPACE
#endif
LanguageChooser::LanguageChooser(const QString& defaultLang, QWidget *parent)
: QDialog(parent, Qt::WindowStaysOnTopHint)
{
@ -95,10 +89,6 @@ LanguageChooser::LanguageChooser(const QString& defaultLang, QWidget *parent)
mainLayout->addWidget(buttonBox);
setLayout(mainLayout);
#if 0 // Used to be included in Qt4 for Q_WS_MAC
qt_mac_set_menubar_merge(false);
#endif
setWindowTitle("I18N");
}

View File

@ -93,15 +93,16 @@ void ButtonTester::mouseDoubleClickEvent(QMouseEvent *e)
void ButtonTester::wheelEvent (QWheelEvent *e)
{
QString result;
if (e->delta() > 0) {
if (e->orientation() == Qt::Vertical) {
const bool vertical = qAbs(e->angleDelta().y()) >= qAbs(e->angleDelta().x());
const int delta = vertical ? e->angleDelta().y() : e->angleDelta().x();
if (delta > 0) {
if (vertical) {
result = "Mouse Wheel Event: UP";
} else {
result = "Mouse Wheel Event: LEFT";
}
} else if (e->delta() < 0) {
if (e->orientation() == Qt::Vertical) {
} else if (delta < 0) {
if (vertical) {
result = "Mouse Wheel Event: DOWN";
} else {
result = "Mouse Wheel Event: RIGHT";

View File

@ -8,43 +8,108 @@ CONFIG += android_install unversioned_soname unversioned_libname
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/clang.conf)
include(../common/android-base-head.conf)
NDK_LLVM_PATH = $$NDK_ROOT/toolchains/llvm/prebuilt/$$NDK_HOST
QMAKE_CC = $$NDK_LLVM_PATH/bin/clang
QMAKE_CXX = $$NDK_LLVM_PATH/bin/clang++
load(device_config)
equals(ANDROID_TARGET_ARCH, armeabi-v7a): \
QMAKE_CFLAGS += -target armv7-none-linux-androideabi
else: equals(ANDROID_TARGET_ARCH, armeabi): \
QMAKE_CFLAGS += -target armv5te-none-linux-androideabi
else: equals(ANDROID_TARGET_ARCH, arm64-v8a): \
QMAKE_CFLAGS += -target aarch64-none-linux-android
else: equals(ANDROID_TARGET_ARCH, x86): \
QMAKE_CFLAGS += -target i686-none-linux-android -mstackrealign
else: equals(ANDROID_TARGET_ARCH, x86_64): \
QMAKE_CFLAGS += -target x86_64-none-linux-android
# In early configure setup; nothing useful to be done here.
isEmpty(DEFAULT_ANDROID_NDK_ROOT): return()
QMAKE_CFLAGS += -gcc-toolchain $$NDK_TOOLCHAIN_PATH -fno-limit-debug-info
NDK_ROOT = $$(ANDROID_NDK_ROOT)
isEmpty(NDK_ROOT): NDK_ROOT = $$DEFAULT_ANDROID_NDK_ROOT
QMAKE_LINK = $$QMAKE_CXX $$QMAKE_CFLAGS -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++
equals(ANDROID_TARGET_ARCH, armeabi-v7a): QMAKE_LINK += -Wl,--exclude-libs,libunwind.a
!exists($$NDK_ROOT): error("You need to set the ANDROID_NDK_ROOT environment variable to point to your Android NDK.")
QMAKE_CFLAGS += -DANDROID_HAS_WSTRING --sysroot=$$NDK_ROOT/sysroot \
-isystem $$NDK_ROOT/sysroot/usr/include/$$NDK_TOOLS_PREFIX \
-isystem $$NDK_ROOT/sources/cxx-stl/llvm-libc++/include \
-isystem $$NDK_ROOT/sources/android/support/include \
-isystem $$NDK_ROOT/sources/cxx-stl/llvm-libc++abi/include
NDK_HOST = $$(ANDROID_NDK_HOST)
isEmpty(NDK_HOST): NDK_HOST = $$DEFAULT_ANDROID_NDK_HOST
ANDROID_SOURCES_CXX_STL_LIBDIR = $$NDK_ROOT/sources/cxx-stl/llvm-libc++/libs/$$ANDROID_TARGET_ARCH
ANDROID_PLATFORM = $$(ANDROID_NDK_PLATFORM)
isEmpty(ANDROID_PLATFORM): ANDROID_PLATFORM = $$DEFAULT_ANDROID_PLATFORM
ANDROID_STDCPP_PATH = $$ANDROID_SOURCES_CXX_STL_LIBDIR/libc++_shared.so
ANDROID_SDK_ROOT = $$(ANDROID_SDK_ROOT)
isEmpty(ANDROID_SDK_ROOT): ANDROID_SDK_ROOT = $$DEFAULT_ANDROID_SDK_ROOT
ANDROID_SDK_BUILD_TOOLS_REVISION = $$(ANDROID_BUILD_TOOLS_REVISION)
isEmpty(ANDROID_SDK_BUILD_TOOLS_REVISION) {
SDK_BUILD_TOOLS_REVISIONS = $$files($$ANDROID_SDK_ROOT/build-tools/*)
for (REVISION, SDK_BUILD_TOOLS_REVISIONS) {
BASENAME = $$basename(REVISION)
greaterThan(BASENAME, $$ANDROID_SDK_BUILD_TOOLS_REVISION): ANDROID_SDK_BUILD_TOOLS_REVISION = $$BASENAME
}
}
ALL_ANDROID_ABIS = $$(ALL_ANDROID_ABIS)
isEmpty(ALL_ANDROID_ABIS): ALL_ANDROID_ABIS = $$DEFAULT_ANDROID_ABIS
isEmpty(ALL_ANDROID_ABIS): ALL_ANDROID_ABIS = arm64-v8a armeabi-v7a x86_64 x86
CONFIG += $$ANDROID_PLATFORM
QMAKE_PCH_OUTPUT_EXT = .gch
QMAKE_CFLAGS_PRECOMPILE = -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
QMAKE_CFLAGS_USE_PRECOMPILE = -include ${QMAKE_PCH_OUTPUT_BASE}
QMAKE_CXXFLAGS_PRECOMPILE = -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
NDK_LLVM_PATH = $$NDK_ROOT/toolchains/llvm/prebuilt/$$NDK_HOST
QMAKE_CC = $$NDK_LLVM_PATH/bin/clang
QMAKE_CXX = $$NDK_LLVM_PATH/bin/clang++
QMAKE_LINK = $$QMAKE_CXX
QMAKE_OBJCOPY = $$NDK_LLVM_PATH/bin/llvm-objcopy
QMAKE_AR = $$NDK_LLVM_PATH/bin/llvm-ar cqs
QMAKE_OBJCOPY = $$NDK_LLVM_PATH/bin/llvm-objcopy
QMAKE_NM = $$NDK_LLVM_PATH/bin/llvm-nm -P
QMAKE_CFLAGS_OPTIMIZE = -Oz
QMAKE_CFLAGS_OPTIMIZE_FULL = -Oz
QMAKE_CFLAGS_WARN_ON = -Wall -W
QMAKE_CFLAGS_WARN_OFF =
QMAKE_CFLAGS_SHLIB = -fPIC
QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses
QMAKE_CFLAGS_THREAD = -D_REENTRANT
QMAKE_CFLAGS_HIDESYMS = -fvisibility=hidden
QMAKE_CFLAGS_NEON = -mfpu=neon
QMAKE_LFLAGS_APP = -Wl,--no-undefined -Wl,-z,noexecstack -shared
QMAKE_LFLAGS_SHLIB = -Wl,--no-undefined -Wl,-z,noexecstack -shared
QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB
QMAKE_LFLAGS_NOUNDEF = -Wl,--no-undefined
QMAKE_LFLAGS_RPATH = -Wl,-rpath=
QMAKE_LFLAGS_RPATHLINK = -Wl,-rpath-link=
QMAKE_LIBS_X11 =
QMAKE_LIBS_THREAD =
QMAKE_LIBS_OPENGL =
QMAKE_INCDIR_POST =
QMAKE_INCDIR_X11 =
QMAKE_LIBDIR_X11 =
QMAKE_INCDIR_OPENGL =
QMAKE_LIBDIR_OPENGL =
ANDROID_USE_LLVM = true
exists($$ANDROID_SOURCES_CXX_STL_LIBDIR/libc++.so): \
ANDROID_CXX_STL_LIBS = -lc++
else: \
ANDROID_CXX_STL_LIBS = $$ANDROID_SOURCES_CXX_STL_LIBDIR/libc++.so.$$replace(ANDROID_PLATFORM, "android-", "")
armeabi-v7a.sdk = armeabi-v7a
armeabi-v7a.target = armeabi-v7a
armeabi-v7a.dir_affix = armeabi-v7a
armeabi-v7a.CONFIG = armeabi-v7a
armeabi-v7a.deployment_identifier = armeabi-v7a
include(../common/android-base-tail.conf)
arm64-v8a.sdk = arm64-v8a
arm64-v8a.target = arm64-v8a
arm64-v8a.dir_affix = arm64-v8a
arm64-v8a.CONFIG = arm64-v8a
arm64-v8a.deployment_identifier = arm64-v8a
x86.sdk = x86
x86.target = x86
x86.dir_affix = x86
x86.CONFIG = x86
x86.deployment_identifier = x86
x86_64.sdk = x86_64
x86_64.target = x86_64
x86_64.dir_affix = x86_64
x86_64.CONFIG = x86_64
x86_64.deployment_identifier = x86_64
load(qt_config)

View File

@ -1,35 +0,0 @@
# qmake configuration for building with android-g++
MAKEFILE_GENERATOR = UNIX
QMAKE_PLATFORM = android
QMAKE_COMPILER = gcc
CONFIG += android_install unversioned_soname unversioned_libname plugin_with_soname android_deployment_settings
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/android-base-head.conf)
QMAKE_CC = $${CROSS_COMPILE}gcc
QMAKE_CXX = $${CROSS_COMPILE}g++
QMAKE_LINK = $$QMAKE_CXX
ANDROID_SOURCES_CXX_STL_LIBDIR = $$NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$$NDK_TOOLCHAIN_VERSION/libs/$$ANDROID_TARGET_ARCH
ANDROID_STDCPP_PATH = $$ANDROID_SOURCES_CXX_STL_LIBDIR/libgnustl_shared.so
ANDROID_CXX_STL_LIBS = -lgnustl_shared -lgcc
ANDROID_USE_LLVM = false
exists($$NDK_ROOT/sysroot/usr/include): \
QMAKE_CFLAGS += --sysroot=$$NDK_ROOT/sysroot \
-isystem $$NDK_ROOT/sysroot/usr/include/$$NDK_TOOLS_PREFIX
else: QMAKE_CFLAGS += --sysroot=$$ANDROID_PLATFORM_ROOT_PATH
QMAKE_CFLAGS += -isystem $$NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$$NDK_TOOLCHAIN_VERSION/include \
-isystem $$ANDROID_SOURCES_CXX_STL_LIBDIR/include
equals(ANDROID_TARGET_ARCH, armeabi)|equals(ANDROID_TARGET_ARCH, armeabi-v7a): \
LIBGCC_PATH_FULL = $$system("$$QMAKE_CXX -mthumb-interwork -print-libgcc-file-name")
else: \
LIBGCC_PATH_FULL = $$system("$$QMAKE_CXX -print-libgcc-file-name")
ANDROID_SOURCES_CXX_STL_LIBDIR += $$dirname(LIBGCC_PATH_FULL)
include(../common/android-base-tail.conf)

View File

@ -1,177 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the qmake spec 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QPLATFORMDEFS_H
#define QPLATFORMDEFS_H
// Get Qt defines/settings
#include "qglobal.h"
// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs
// 1) need to reset default environment if _BSD_SOURCE is defined
// 2) need to specify POSIX thread interfaces explicitly in glibc 2.0
// 3) it seems older glibc need this to include the X/Open stuff
#include <unistd.h>
// We are hot - unistd.h should have turned on the specific APIs we requested
#include <features.h>
#include <pthread.h>
#include <dirent.h>
#include <fcntl.h>
#include <grp.h>
#include <pwd.h>
#include <signal.h>
#include <dlfcn.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/ipc.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/wait.h>
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
#ifdef QT_LARGEFILE_SUPPORT
#define QT_STATBUF struct stat64
#define QT_STATBUF4TSTAT struct stat64
#define QT_STAT ::stat64
#define QT_FSTAT ::fstat64
#define QT_LSTAT ::lstat64
#define QT_OPEN ::open64
#define QT_TRUNCATE ::truncate64
#define QT_FTRUNCATE ::ftruncate64
#define QT_LSEEK ::lseek64
#else
#define QT_STATBUF struct stat
#define QT_STATBUF4TSTAT struct stat
#define QT_STAT ::stat
#define QT_FSTAT ::fstat
#define QT_LSTAT ::lstat
#define QT_OPEN ::open
#define QT_TRUNCATE ::truncate
#define QT_FTRUNCATE ::ftruncate
#define QT_LSEEK ::lseek
#endif
#ifdef QT_LARGEFILE_SUPPORT
#define QT_FOPEN ::fopen64
#define QT_FSEEK ::fseeko64
#define QT_FTELL ::ftello64
#define QT_FGETPOS ::fgetpos64
#define QT_FSETPOS ::fsetpos64
#define QT_MMAP ::mmap64
#define QT_FPOS_T fpos64_t
#define QT_OFF_T off64_t
#else
#define QT_FOPEN ::fopen
#define QT_FSEEK ::fseek
#define QT_FTELL ::ftell
#define QT_FGETPOS ::fgetpos
#define QT_FSETPOS ::fsetpos
#define QT_MMAP ::mmap
#define QT_FPOS_T fpos_t
#define QT_OFF_T long
#endif
#define QT_STAT_REG S_IFREG
#define QT_STAT_DIR S_IFDIR
#define QT_STAT_MASK S_IFMT
#define QT_STAT_LNK S_IFLNK
#define QT_SOCKET_CONNECT ::connect
#define QT_SOCKET_BIND ::bind
#define QT_FILENO fileno
#define QT_CLOSE ::close
#define QT_READ ::read
#define QT_WRITE ::write
#define QT_ACCESS ::access
#define QT_GETCWD ::getcwd
#define QT_CHDIR ::chdir
#define QT_MKDIR ::mkdir
#define QT_RMDIR ::rmdir
#define QT_OPEN_LARGEFILE O_LARGEFILE
#define QT_OPEN_RDONLY O_RDONLY
#define QT_OPEN_WRONLY O_WRONLY
#define QT_OPEN_RDWR O_RDWR
#define QT_OPEN_CREAT O_CREAT
#define QT_OPEN_TRUNC O_TRUNC
#define QT_OPEN_APPEND O_APPEND
#define QT_OPEN_EXCL O_EXCL
// Directory iteration
#define QT_DIR DIR
#define QT_OPENDIR ::opendir
#define QT_CLOSEDIR ::closedir
#if defined(QT_LARGEFILE_SUPPORT) \
&& defined(QT_USE_XOPEN_LFS_EXTENSIONS) \
&& !defined(QT_NO_READDIR64)
#define QT_DIRENT struct dirent64
#define QT_READDIR ::readdir64
#define QT_READDIR_R ::readdir64_r
#else
#define QT_DIRENT struct dirent
#define QT_READDIR ::readdir
#define QT_READDIR_R ::readdir_r
#endif
#define QT_SOCKET_CONNECT ::connect
#define QT_SOCKET_BIND ::bind
#define QT_SIGNAL_RETTYPE void
#define QT_SIGNAL_ARGS int
#define QT_SIGNAL_IGNORE SIG_IGN
#define QT_SOCKLEN_T socklen_t
#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
#define QT_SNPRINTF ::snprintf
#define QT_VSNPRINTF ::vsnprintf
#endif
#endif // QPLATFORMDEFS_H

View File

@ -1,72 +0,0 @@
load(device_config)
# In early configure setup; nothing useful to be done here.
isEmpty(DEFAULT_ANDROID_NDK_ROOT): return()
NDK_ROOT = $$(ANDROID_NDK_ROOT)
isEmpty(NDK_ROOT): NDK_ROOT = $$DEFAULT_ANDROID_NDK_ROOT
NDK_HOST = $$(ANDROID_NDK_HOST)
isEmpty(NDK_HOST): NDK_HOST = $$DEFAULT_ANDROID_NDK_HOST
ANDROID_PLATFORM = $$(ANDROID_NDK_PLATFORM)
isEmpty(ANDROID_PLATFORM): ANDROID_PLATFORM = $$DEFAULT_ANDROID_PLATFORM
ANDROID_TARGET_ARCH = $$(ANDROID_TARGET_ARCH)
isEmpty(ANDROID_TARGET_ARCH): ANDROID_TARGET_ARCH = $$DEFAULT_ANDROID_TARGET_ARCH
NDK_TOOLCHAIN_PREFIX = $$(ANDROID_NDK_TOOLCHAIN_PREFIX)
isEmpty(NDK_TOOLCHAIN_PREFIX) {
equals(ANDROID_TARGET_ARCH, x86): NDK_TOOLCHAIN_PREFIX = x86
else: equals(ANDROID_TARGET_ARCH, x86_64): NDK_TOOLCHAIN_PREFIX = x86_64
else: equals(ANDROID_TARGET_ARCH, arm64-v8a): NDK_TOOLCHAIN_PREFIX = aarch64-linux-android
else: NDK_TOOLCHAIN_PREFIX = arm-linux-androideabi
}
NDK_TOOLS_PREFIX = $$(ANDROID_NDK_TOOLS_PREFIX)
isEmpty(NDK_TOOLS_PREFIX) {
equals(ANDROID_TARGET_ARCH, x86): NDK_TOOLS_PREFIX = i686-linux-android
else: equals(ANDROID_TARGET_ARCH, x86_64): NDK_TOOLS_PREFIX = x86_64-linux-android
else: equals(ANDROID_TARGET_ARCH, arm64-v8a): NDK_TOOLS_PREFIX = aarch64-linux-android
else: NDK_TOOLS_PREFIX = arm-linux-androideabi
}
NDK_TOOLCHAIN_VERSION = $$(ANDROID_NDK_TOOLCHAIN_VERSION)
isEmpty(NDK_TOOLCHAIN_VERSION): NDK_TOOLCHAIN_VERSION = $$DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION
equals(ANDROID_TARGET_ARCH, x86): ANDROID_ARCHITECTURE = x86
else: equals(ANDROID_TARGET_ARCH, x86_64): ANDROID_ARCHITECTURE = x86_64
else: equals(ANDROID_TARGET_ARCH, arm64-v8a): ANDROID_ARCHITECTURE = arm64
else: ANDROID_ARCHITECTURE = arm
!equals(NDK_TOOLCHAIN_VERSION, 4.4.3): ANDROID_CXXSTL_SUFFIX = -$$NDK_TOOLCHAIN_VERSION
NDK_TOOLCHAIN = $$NDK_TOOLCHAIN_PREFIX-$$NDK_TOOLCHAIN_VERSION
NDK_TOOLCHAIN_PATH = $$NDK_ROOT/toolchains/$$NDK_TOOLCHAIN/prebuilt/$$NDK_HOST
ANDROID_SDK_ROOT = $$(ANDROID_SDK_ROOT)
isEmpty(ANDROID_SDK_ROOT): ANDROID_SDK_ROOT = $$DEFAULT_ANDROID_SDK_ROOT
ANDROID_SDK_BUILD_TOOLS_REVISION = $$(ANDROID_BUILD_TOOLS_REVISION)
isEmpty(ANDROID_SDK_BUILD_TOOLS_REVISION) {
SDK_BUILD_TOOLS_REVISIONS = $$files($$ANDROID_SDK_ROOT/build-tools/*)
for (REVISION, SDK_BUILD_TOOLS_REVISIONS) {
BASENAME = $$basename(REVISION)
greaterThan(BASENAME, $$ANDROID_SDK_BUILD_TOOLS_REVISION): ANDROID_SDK_BUILD_TOOLS_REVISION = $$BASENAME
}
}
CONFIG += $$ANDROID_PLATFORM
QMAKE_CFLAGS = -D__ANDROID_API__=$$replace(ANDROID_PLATFORM, "android-", "")
ANDROID_PLATFORM_ROOT_PATH = $$NDK_ROOT/platforms/$$ANDROID_PLATFORM/arch-$$ANDROID_ARCHITECTURE/
CROSS_COMPILE = $$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX-
QMAKE_PCH_OUTPUT_EXT = .gch
QMAKE_CFLAGS_PRECOMPILE = -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
QMAKE_CFLAGS_USE_PRECOMPILE = -include ${QMAKE_PCH_OUTPUT_BASE}
QMAKE_CXXFLAGS_PRECOMPILE = -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE

View File

@ -1,90 +0,0 @@
# In early configure setup; nothing useful to be done here.
isEmpty(DEFAULT_ANDROID_NDK_ROOT): return()
# -fstack-protector-strong offers good protection against stack smashing attacks.
# It is (currently) enabled only on Android because we know for sure that Andoroid compilers supports it
QMAKE_CFLAGS += -fstack-protector-strong -DANDROID
equals(ANDROID_TARGET_ARCH, armeabi-v7a): \
QMAKE_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -fno-builtin-memmove
else: equals(ANDROID_TARGET_ARCH, armeabi): \
QMAKE_CFLAGS += -march=armv5te -mtune=xscale -msoft-float -fno-builtin-memmove
# -fno-builtin-memmove is used to workaround https://code.google.com/p/android/issues/detail?id=81692
QMAKE_CFLAGS_WARN_ON = -Wall -W
QMAKE_CFLAGS_WARN_OFF =
equals(ANDROID_TARGET_ARCH, armeabi-v7a) | equals(ANDROID_TARGET_ARCH, armeabi) {
CONFIG += optimize_size
QMAKE_CFLAGS_DEBUG = -g -marm -O0
equals(ANDROID_TARGET_ARCH, armeabi):if(equals(NDK_TOOLCHAIN_VERSION, 4.8)|equals(NDK_TOOLCHAIN_VERSION, 4.9)) {
DEFINES += QT_OS_ANDROID_GCC_48_WORKAROUND
} else {
QMAKE_CFLAGS_RELEASE += -mthumb
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -mthumb
}
}
QMAKE_CFLAGS_SHLIB = -fPIC
QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses
QMAKE_CFLAGS_THREAD = -D_REENTRANT
QMAKE_CFLAGS_HIDESYMS = -fvisibility=hidden
QMAKE_CFLAGS_NEON = -mfpu=neon
QMAKE_CFLAGS_GNUC99 = -std=gnu99
QMAKE_CFLAGS_GNUC11 = -std=gnu11
QMAKE_CXXFLAGS_CXX11 = -std=c++11
QMAKE_CXXFLAGS_CXX14 = -std=c++14
QMAKE_CXXFLAGS_CXX1Z = -std=c++1z
QMAKE_CXXFLAGS_GNUCXX11 = -std=gnu++11
QMAKE_CXXFLAGS_GNUCXX14 = -std=gnu++14
QMAKE_CXXFLAGS_GNUCXX1Z = -std=gnu++1z
QMAKE_CXXFLAGS = $$QMAKE_CFLAGS
QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON
QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF
QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE
QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
QMAKE_CXXFLAGS_DEBUG += $$QMAKE_CFLAGS_DEBUG
QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB
QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC
QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD
QMAKE_CXXFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden
# modifications to linux.conf
QMAKE_AR = $${CROSS_COMPILE}ar cqs
QMAKE_OBJCOPY = $${CROSS_COMPILE}objcopy
QMAKE_NM = $${CROSS_COMPILE}nm -P
QMAKE_STRIP =
#$${CROSS_COMPILE}strip
QMAKE_RANLIB = $${CROSS_COMPILE}ranlib
QMAKE_INCDIR_POST =
QMAKE_LIBDIR_POST = $$ANDROID_SOURCES_CXX_STL_LIBDIR
QMAKE_INCDIR_X11 =
QMAKE_LIBDIR_X11 =
QMAKE_INCDIR_OPENGL =
QMAKE_LIBDIR_OPENGL =
QMAKE_LINK_SHLIB = $$QMAKE_LINK
QMAKE_LFLAGS = --sysroot=$$ANDROID_PLATFORM_ROOT_PATH
equals(ANDROID_TARGET_ARCH, x86_64) QMAKE_LFLAGS += -L$$ANDROID_PLATFORM_ROOT_PATH/usr/lib64
QMAKE_LFLAGS_APP = -Wl,--no-undefined -Wl,-z,noexecstack -shared
QMAKE_LFLAGS_SHLIB = -Wl,--no-undefined -Wl,-z,noexecstack -shared
QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB
QMAKE_LFLAGS_NOUNDEF = -Wl,--no-undefined
QMAKE_LFLAGS_RPATH = -Wl,-rpath=
QMAKE_LFLAGS_RPATHLINK = -Wl,-rpath-link=
QMAKE_LIBS_PRIVATE = $$ANDROID_CXX_STL_LIBS -llog -lz -lm -ldl -lc
QMAKE_LIBS_X11 =
QMAKE_LIBS_THREAD =
QMAKE_LIBS_EGL = -lEGL
QMAKE_LIBS_OPENGL =
QMAKE_LIBS_OPENGL_ES2 = -lGLESv2
!exists($$NDK_ROOT): error("You need to set the ANDROID_NDK_ROOT environment variable to point to your Android NDK.")
load(qt_config)

View File

@ -84,7 +84,7 @@ QMAKE_RUN_CXX_IMP_BATCH = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ @<<
QMAKE_LINK = link
QMAKE_LFLAGS = /NOLOGO /DYNAMICBASE /NXCOMPAT
QMAKE_LFLAGS_RELEASE = /INCREMENTAL:NO
QMAKE_LFLAGS_RELEASE = /OPT:REF /INCREMENTAL:NO
QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO = /DEBUG /OPT:REF /INCREMENTAL:NO
QMAKE_LFLAGS_DEBUG = /DEBUG
QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:CONSOLE

View File

@ -4,29 +4,46 @@ APK_PATH = $$shell_path($$OUT_PWD/android-build/$${TARGET}.apk)
apk_install_target.depends = first
apk_install_target.commands = $(MAKE) -f $(MAKEFILE) INSTALL_ROOT=$$OUT_PWD/android-build install
apk.target = apk
apk.depends = apk_install_target
qtPrepareTool(ANDROIDDEPLOYQT, androiddeployqt)
isEmpty(ANDROID_DEPLOYMENT_SETTINGS_FILE): ANDROID_DEPLOYMENT_SETTINGS_FILE = $$OUT_PWD/android-$$TARGET-deployment-settings.json
contains(QMAKE_HOST.os, Windows): extension = .exe
apk.target = apk
apk.depends = apk_install_target
apk.commands = $$ANDROIDDEPLOYQT --input $$ANDROID_DEPLOYMENT_SETTINGS_FILE --output $$OUT_PWD/android-build --apk $$APK_PATH
aab.target = aab
aab.depends = apk_install_target
aab.commands = $$ANDROIDDEPLOYQT --input $$ANDROID_DEPLOYMENT_SETTINGS_FILE --output $$OUT_PWD/android-build --aab --apk $$APK_PATH
} else {
prepareRecursiveTarget(aab)
prepareRecursiveTarget(apk)
prepareRecursiveTarget(apk_install_target)
}
QMAKE_EXTRA_TARGETS *= apk apk_install_target
contains(TEMPLATE, ".*app") {
!android_app {
!contains(TARGET, ".so"): TARGET = lib$${TARGET}.so
QMAKE_LFLAGS += -Wl,-soname,$$shell_quote($$TARGET)
build_pass {
contains(TEMPLATE, ".*app") {
!android_app {
!contains(TARGET, ".so") {
single_arch:TARGET = lib$${TARGET}.so
else:TARGET = lib$${TARGET}_$${QT_ARCH}.so
}
QMAKE_LFLAGS += -Wl,-soname,$$shell_quote($$TARGET)
android_install {
target.path=/libs/$$ANDROID_TARGET_ARCH/
INSTALLS *= target
android_install {
target.path=/libs/$$ANDROID_TARGET_ARCH/
INSTALLS *= target
}
}
} else: contains(TEMPLATE, "lib"):!static:!QTDIR_build:android_install {
target.path = /libs/$$ANDROID_TARGET_ARCH/
INSTALLS *= target
}
} else: contains(TEMPLATE, "lib"):!static:!QTDIR_build:android_install {
target.path = /libs/$$ANDROID_TARGET_ARCH/
INSTALLS *= target
} else {
QMAKE_EXTRA_TARGETS *= aab apk apk_install_target
android-build-distclean.commands = \
$$QMAKE_DEL_TREE $$shell_quote($$shell_path($$OUT_PWD/android-build))
QMAKE_EXTRA_TARGETS *= android-build-distclean
CLEAN_DEPS += android-build-distclean
}

View File

@ -17,32 +17,21 @@ contains(TEMPLATE, ".*app"):!build_pass:!android-embedded {
isEmpty(NDK_ROOT): NDK_ROOT = $$DEFAULT_ANDROID_NDK_ROOT
FILE_CONTENT += " \"ndk\": $$emitString($$NDK_ROOT),"
equals(ANDROID_USE_LLVM, true) {
FILE_CONTENT += " \"toolchain-prefix\": \"llvm\","
FILE_CONTENT += " \"tool-prefix\": \"llvm\","
} else {
NDK_TOOLCHAIN_PREFIX = $$(ANDROID_NDK_TOOLCHAIN_PREFIX)
isEmpty(NDK_TOOLCHAIN_PREFIX) {
equals(ANDROID_TARGET_ARCH, x86): NDK_TOOLCHAIN_PREFIX = x86
else: equals(ANDROID_TARGET_ARCH, x86_64): NDK_TOOLCHAIN_PREFIX = x86_64
else: equals(ANDROID_TARGET_ARCH, arm64-v8a): NDK_TOOLCHAIN_PREFIX = aarch64-linux-android
else: NDK_TOOLCHAIN_PREFIX = arm-linux-androideabi
}
FILE_CONTENT += " \"toolchain-prefix\": $$emitString($$NDK_TOOLCHAIN_PREFIX),"
FILE_CONTENT += " \"tool-prefix\": $$emitString($$NDK_TOOLS_PREFIX),"
}
NDK_TOOLCHAIN_VERSION = $$(ANDROID_NDK_TOOLCHAIN_VERSION)
isEmpty(NDK_TOOLCHAIN_VERSION): NDK_TOOLCHAIN_VERSION = $$DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION
FILE_CONTENT += " \"toolchain-version\": $$emitString($$NDK_TOOLCHAIN_VERSION),"
FILE_CONTENT += " \"toolchain-prefix\": \"llvm\","
FILE_CONTENT += " \"tool-prefix\": \"llvm\","
NDK_HOST = $$(ANDROID_NDK_HOST)
isEmpty(NDK_HOST): NDK_HOST = $$DEFAULT_ANDROID_NDK_HOST
FILE_CONTENT += " \"ndk-host\": $$emitString($$NDK_HOST),"
ANDROID_TARGET_ARCH = $$(ANDROID_TARGET_ARCH)
isEmpty(ANDROID_TARGET_ARCH): ANDROID_TARGET_ARCH = $$DEFAULT_ANDROID_TARGET_ARCH
FILE_CONTENT += " \"target-architecture\": $$emitString($$ANDROID_TARGET_ARCH),"
for (arch, ANDROID_ABIS) {
equals(arch, x86): libs_arch = i686-linux-android
else: equals(arch, x86_64): libs_arch = x86_64-linux-android
else: equals(arch, arm64-v8a): libs_arch = aarch64-linux-android
else: libs_arch = arm-linux-androideabi
ARCHS += "$$emitString($$arch):$$emitString($$libs_arch)"
}
FILE_CONTENT += " \"architectures\": {$$join(ARCHS,", ")},"
# Explicitly set qt dependencies of application for deployment
!isEmpty(ANDROID_DEPLOYMENT_DEPENDENCIES): \
@ -74,13 +63,11 @@ contains(TEMPLATE, ".*app"):!build_pass:!android-embedded {
QML_ROOT_PATH = $$_PRO_FILE_PWD_
FILE_CONTENT += " \"qml-root-path\": $$emitString($$QML_ROOT_PATH),"
FILE_CONTENT += " \"stdcpp-path\": $$emitString($$ANDROID_STDCPP_PATH),"
FILE_CONTENT += " \"useLLVM\": $$ANDROID_USE_LLVM,"
FILE_CONTENT += " \"application-binary\": $$emitString($$absolute_path($$DESTDIR, $$OUT_PWD)/$$TARGET)"
FILE_CONTENT += ""
FILE_CONTENT += " \"application-binary\": $$emitString($$TARGET)"
FILE_CONTENT += "}"
isEmpty(ANDROID_DEPLOYMENT_SETTINGS_FILE): ANDROID_DEPLOYMENT_SETTINGS_FILE = $$OUT_PWD/android-$$TARGET-deployment-settings.json
write_file($$ANDROID_DEPLOYMENT_SETTINGS_FILE, FILE_CONTENT)|error()
}

View File

@ -0,0 +1,77 @@
load(default_pre)
build_pass:armeabi-v7a {
QT_ARCH = armeabi-v7a
} else:build_pass:arm64-v8a {
QT_ARCH = arm64-v8a
} else:build_pass:x86 {
QT_ARCH = x86
} else:build_pass:x86_64 {
QT_ARCH = x86_64
} else {
# default architecture
QT_ARCH = arm64-v8a
}
DEFAULT_ANDROID_TARGET_ARCH=$${QT_ARCH}
ANDROID_TARGET_ARCH = $$(ANDROID_TARGET_ARCH)
isEmpty(ANDROID_TARGET_ARCH): ANDROID_TARGET_ARCH = $$DEFAULT_ANDROID_TARGET_ARCH
# Follow https://android.googlesource.com/platform/ndk/+/ndk-release-r20/docs/BuildSystemMaintainers.md
equals(ANDROID_TARGET_ARCH, armeabi-v7a): \
QMAKE_CFLAGS = -target armv7a-linux-androideabi$$replace(ANDROID_PLATFORM, "android-", "")
else: equals(ANDROID_TARGET_ARCH, arm64-v8a): \
QMAKE_CFLAGS = -target aarch64-linux-android$$replace(ANDROID_PLATFORM, "android-", "")
else: equals(ANDROID_TARGET_ARCH, x86): \
QMAKE_CFLAGS = -target i686-linux-android$$replace(ANDROID_PLATFORM, "android-", "") -mstackrealign
else: equals(ANDROID_TARGET_ARCH, x86_64): \
QMAKE_CFLAGS = -target x86_64-linux-android$$replace(ANDROID_PLATFORM, "android-", "")
QMAKE_CFLAGS += -fno-limit-debug-info
QMAKE_LINK = $$QMAKE_CXX $$QMAKE_CFLAGS
ANDROID_STDCPP_PATH = $$NDK_LLVM_PATH/sysroot/usr/lib/
# -fstack-protector-strong offers good protection against stack smashing attacks.
# It is (currently) enabled only on Android because we know for sure that Android compilers supports it
QMAKE_CFLAGS += -fPIC -fstack-protector-strong -DANDROID
equals(ANDROID_TARGET_ARCH, armeabi-v7a) | equals(ANDROID_TARGET_ARCH, armeabi) {
CONFIG += optimize_size
QMAKE_CFLAGS_DEBUG = -g -marm -O0
QMAKE_CFLAGS_RELEASE += -mthumb
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -mthumb
}
QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO = $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
QMAKE_CXXFLAGS = $$QMAKE_CFLAGS
QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON
QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF
QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE
QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG
QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB
QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC
QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD
QMAKE_LIBS_EGL = -lEGL
QMAKE_LIBS_OPENGL_ES2 = -lGLESv2
QMAKE_STRIP =
#$${CROSS_COMPILE}strip
equals(QT_ARCH, x86): CROSS_COMPILE = $$NDK_LLVM_PATH/bin/i686-linux-android-
else: equals(QT_ARCH, x86_64): CROSS_COMPILE = $$NDK_LLVM_PATH/bin/x86_64-linux-android-
else: equals(QT_ARCH, arm64-v8a): CROSS_COMPILE = $$NDK_LLVM_PATH/bin/aarch64-linux-android-
else: CROSS_COMPILE = $$NDK_LLVM_PATH/bin/arm-linux-androideabi-
QMAKE_RANLIB = $${CROSS_COMPILE}ranlib
QMAKE_LINK_SHLIB = $$QMAKE_LINK
QMAKE_LFLAGS =
QMAKE_LIBS_PRIVATE = -llog -lz -lm -ldl -lc

View File

@ -0,0 +1,10 @@
load(resolve_config)
!equals(TEMPLATE, aux):!host_build:!single_arch:!java:android {
isEmpty(ANDROID_ABIS): ANDROID_ABIS = $$ALL_ANDROID_ABIS
ALL_ABIS = $$join(ANDROID_ABIS, _and_)
CONFIG += $$ALL_ABIS build_all
addExclusiveBuildsProper($$ALL_ABIS, $$ANDROID_ABIS)
unset(ALL_ABIS)
}

View File

@ -138,8 +138,8 @@ CMAKE_RELEASE_TYPE =
# the debug libraries at build time.
equals(QMAKE_HOST.os, Windows): CMAKE_BIN_SUFFIX = ".exe"
if(build_all|CONFIG(debug, debug|release)): CMAKE_DEBUG_TYPE = debug
if(build_all|CONFIG(release, debug|release)): CMAKE_RELEASE_TYPE = release
if(debug_and_release:build_all)|CONFIG(debug, debug|release): CMAKE_DEBUG_TYPE = debug
if(debug_and_release:build_all)|CONFIG(release, debug|release): CMAKE_RELEASE_TYPE = release
# CMAKE_DEBUG_AND_RELEASE is used to tell the _populate_$${CMAKE_MODULE_NAME}_target_properties
# functions whether a Configuration specific generator expression needs to be added to the values
@ -153,67 +153,109 @@ if(build_all|CONFIG(release, debug|release)): CMAKE_RELEASE_TYPE = release
# <CONFIG> equivalent to the value specified by CMAKE_BUILD_TYPE.
# This means that when Qt was built in a Release configuration, and the application in a Debug
# configuration, IMPORTED_LOCATION_RELEASE will be used for the Qt libraries.
debug_and_release {
#
# Note that we need to check for the "debug_and_release" feature, and not the CONFIG value, because
# the CONFIG value is always set to true on Windows in msvc-desktop.conf disregarding whether the
# configure line specified just -debug or just -release.
# This also means that if a user configures and builds Qt with -release, and then calls nmake debug
# to build debug libraries of Qt, the generated CMake file won't know about debug libraries,
# and will always link against the release libraries.
qtConfig(debug_and_release) {
CMAKE_DEBUG_AND_RELEASE = TRUE
} else {
CMAKE_DEBUG_AND_RELEASE = FALSE
}
contains(CONFIG, plugin) {
!isEmpty(PLUGIN_EXTENDS):!equals(PLUGIN_EXTENDS, -) {
count(PLUGIN_EXTENDS, 1, greaterThan): \
error("Plugin declares to extend multiple modules. We don't handle that ...")
PLUGIN_MODULE_NAME = $$PLUGIN_EXTENDS
equals(PLUGIN_EXTENDS, -) {
CMAKE_PLUGIN_EXTENDS = -
} else {
PLUGIN_MODULE_NAME =
for (mod, QT_MODULES) {
contains(QT.$${mod}.plugin_types, $$PLUGIN_TYPE) {
!isEmpty(PLUGIN_MODULE_NAME): \
error("Multiple modules claim plugin type '$$PLUGIN_TYPE' ($$mod, in addition to $$PLUGIN_MODULE_NAME)")
PLUGIN_MODULE_NAME = $$mod
break()
}
list_plugin_extends =
for (p, PLUGIN_EXTENDS) {
m = $$cmakeModuleName($$p)
list_plugin_extends += Qt5::$$m
}
isEmpty(PLUGIN_MODULE_NAME): error("No module claims plugin type '$$PLUGIN_TYPE'")
CMAKE_PLUGIN_EXTENDS = $$join(list_plugin_extends, ";")
}
PLUGIN_MODULE_NAME =
unique_qt_modules = $$unique(QT_MODULES) # In case modules appear in multiple places
for (mod, unique_qt_modules) {
contains(QT.$${mod}.plugin_types, $$PLUGIN_TYPE) {
!isEmpty(PLUGIN_MODULE_NAME): \
error("Multiple modules claim plugin type '$$PLUGIN_TYPE' ($$mod, in addition to $$PLUGIN_MODULE_NAME)")
PLUGIN_MODULE_NAME = $$mod
}
}
isEmpty(PLUGIN_MODULE_NAME): error("No module claims plugin type '$$PLUGIN_TYPE'")
sorted_deps = $$sort_depends(QT_PLUGIN.$${CMAKE_QT_STEM}.DEPENDS, QT.)
mod_deps =
lib_deps =
aux_mod_deps =
aux_lib_deps =
for (dep, sorted_deps) {
cdep = $$cmakeModuleName($$dep)
mod_deps += $$cdep
lib_deps += Qt5::$$cdep
}
CMAKE_PLUGIN_MODULE_DEPS = $$join(mod_deps, ";")
CMAKE_PLUGIN_QT5_MODULE_DEPS = $$join(lib_deps, ";")
CMAKE_MODULE_NAME = $$cmakeModuleName($$PLUGIN_MODULE_NAME)
CMAKE_PLUGIN_NAME = $$PLUGIN_CLASS_NAME
CMAKE_PLUGIN_TYPE = $$PLUGIN_TYPE
CMAKE_PLUGIN_TYPE_ESCAPED = $$replace(PLUGIN_TYPE, [-/], _)
win32 {
isEmpty(CMAKE_STATIC_TYPE) {
CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.dll
CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.dll
CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.dll
CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}d.dll
CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.prl
CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}d.prl
} else:mingw {
CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}.a
CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}d.a
CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.a
CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}d.a
CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.prl
CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}d.prl
} else { # MSVC static
CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.lib
CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.lib
CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.lib
CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}d.lib
CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.prl
CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}d.prl
}
} else {
mac {
isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .dylib
else: CMAKE_PlUGIN_EXT = .a
isEmpty(CMAKE_STATIC_TYPE): CMAKE_PLUGIN_EXT = .dylib
else: CMAKE_PLUGIN_EXT = .a
CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}$${CMAKE_PLUGIN_EXT}
CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}_debug$${CMAKE_PLUGIN_EXT}
CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.prl
CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}_debug.prl
} else {
isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .so
else: CMAKE_PlUGIN_EXT = .a
isEmpty(CMAKE_STATIC_TYPE): CMAKE_PLUGIN_EXT = .so
else: CMAKE_PLUGIN_EXT = .a
CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}$${CMAKE_PLUGIN_EXT}
CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}$${CMAKE_PLUGIN_EXT}
CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.prl
CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.prl
}
}
cmake_target_file.input = $$PWD/data/cmake/Qt5PluginTarget.cmake.in
cmake_target_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}_$${PLUGIN_CLASS_NAME}.cmake
cmake_qt5_plugin_import_file.input = $$PWD/data/cmake/Qt5ImportPlugin.cpp.in
cmake_qt5_plugin_import_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}_$${PLUGIN_CLASS_NAME}_Import.cpp
!build_pass:QMAKE_SUBSTITUTES += \
cmake_target_file
!build_pass {
QMAKE_SUBSTITUTES += cmake_target_file
static|staticlib: QMAKE_SUBSTITUTES += cmake_qt5_plugin_import_file
}
cmake_qt5_plugin_file.files = $$cmake_target_file.output
static|staticlib: cmake_qt5_plugin_file.files += $$cmake_qt5_plugin_import_file.output
cmake_qt5_plugin_file.path = $$[QT_INSTALL_LIBS]/cmake/Qt5$${CMAKE_MODULE_NAME}
INSTALLS += cmake_qt5_plugin_file
@ -244,6 +286,7 @@ CMAKE_MODULE_DEPS = $$join(mod_deps, ";")
CMAKE_QT5_MODULE_DEPS = $$join(lib_deps, ";")
CMAKE_INTERFACE_MODULE_DEPS = $$join(aux_mod_deps, ";")
CMAKE_INTERFACE_QT5_MODULE_DEPS = $$join(aux_lib_deps, ";")
CMAKE_MODULE_PLUGIN_TYPES = $$join(QT.$${MODULE}.plugin_types, ";")
mac {
!isEmpty(CMAKE_STATIC_TYPE) {

View File

@ -317,6 +317,22 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_EXECUTABLE_COMPILE_FLAGS)
!!ENDIF // TEMPLATE != aux
# It can happen that the same FooConfig.cmake file is included when calling find_package()
# on some Qt component. An example of that is when using a Qt static build with auto inclusion
# of plugins:
#
# Qt5WidgetsConfig.cmake -> Qt5GuiConfig.cmake -> Qt5Gui_QSvgIconPlugin.cmake ->
# Qt5SvgConfig.cmake -> Qt5WidgetsConfig.cmake ->
# finish processing of second Qt5WidgetsConfig.cmake ->
# return to first Qt5WidgetsConfig.cmake ->
# add_library cannot create imported target "Qt5::Widgets".
#
# Make sure to return early in the original Config inclusion, because the target has already
# been defined as part of the second inclusion.
if(TARGET Qt5::$${CMAKE_MODULE_NAME})
return()
endif()
set(_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES \"$${CMAKE_QT5_MODULE_DEPS}\")
!!IF !isEmpty(CMAKE_INTERFACE_QT5_MODULE_DEPS)
@ -381,6 +397,8 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_QT_ENABLED_FEATURES $$join(QT.$${MODULE}.enabled_features, ";"))
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_QT_DISABLED_FEATURES $$join(QT.$${MODULE}.disabled_features, ";"))
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_QT_PLUGIN_TYPES \"$${CMAKE_MODULE_PLUGIN_TYPES}\")
set(_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIRS_EXIST TRUE)
foreach (_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIR ${Qt5$${CMAKE_MODULE_NAME}_OWN_PRIVATE_INCLUDE_DIRS})
if (NOT EXISTS ${_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIR})
@ -488,7 +506,8 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
file(GLOB pluginTargets \"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}_*Plugin.cmake\")
macro(_populate_$${CMAKE_MODULE_NAME}_plugin_properties Plugin Configuration PLUGIN_LOCATION)
macro(_populate_$${CMAKE_MODULE_NAME}_plugin_properties Plugin Configuration PLUGIN_LOCATION
IsDebugAndRelease)
set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
!!IF isEmpty(CMAKE_PLUGIN_DIR_IS_ABSOLUTE)
@ -500,6 +519,36 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
set_target_properties(Qt5::${Plugin} PROPERTIES
\"IMPORTED_LOCATION_${Configuration}\" ${imported_location}
)
!!IF !isEmpty(CMAKE_STATIC_TYPE)
set(_static_deps
${_Qt5${Plugin}_STATIC_${Configuration}_LIB_DEPENDENCIES}
)
if(NOT "${IsDebugAndRelease}")
set(_genex_condition \"1\")
else()
if("${Configuration}" STREQUAL "DEBUG")
set(_genex_condition \"$<CONFIG:Debug>\")
else()
set(_genex_condition \"$<NOT:$<CONFIG:Debug>>\")
endif()
endif()
if(_static_deps)
set(_static_deps_genex \"$<${_genex_condition}:${_static_deps}>\")
set_property(TARGET Qt5::${Plugin} APPEND PROPERTY INTERFACE_LINK_LIBRARIES
\"${_static_deps_genex}\"
)
endif()
set(_static_link_flags \"${_Qt5${Plugin}_STATIC_${Configuration}_LINK_FLAGS}\")
if(NOT CMAKE_VERSION VERSION_LESS \"3.13\" AND _static_link_flags)
set(_static_link_flags_genex \"$<${_genex_condition}:${_static_link_flags}>\")
set_property(TARGET Qt5::${Plugin} APPEND PROPERTY INTERFACE_LINK_OPTIONS
\"${_static_link_flags_genex}\"
)
endif()
!!ENDIF
endmacro()
if (pluginTargets)

View File

@ -0,0 +1,2 @@
#include <QtPlugin>
Q_IMPORT_PLUGIN($$CMAKE_PLUGIN_NAME)

View File

@ -1,11 +1,102 @@
add_library(Qt5::$$CMAKE_PLUGIN_NAME MODULE IMPORTED)
!!IF !isEmpty(CMAKE_STATIC_TYPE)
set(_Qt5$${CMAKE_PLUGIN_NAME}_MODULE_DEPENDENCIES \"$${CMAKE_PLUGIN_MODULE_DEPS}\")
foreach(_module_dep ${_Qt5$${CMAKE_PLUGIN_NAME}_MODULE_DEPENDENCIES})
if(NOT Qt5${_module_dep}_FOUND)
find_package(Qt5${_module_dep}
$$VERSION ${_Qt5$${CMAKE_MODULE_NAME}_FIND_VERSION_EXACT}
${_Qt5$${CMAKE_MODULE_NAME}_DEPENDENCIES_FIND_QUIET}
${_Qt5$${CMAKE_MODULE_NAME}_FIND_DEPENDENCIES_REQUIRED}
PATHS \"${CMAKE_CURRENT_LIST_DIR}/..\" NO_DEFAULT_PATH
)
endif()
endforeach()
!!IF !isEmpty(CMAKE_RELEASE_TYPE)
_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
_qt5_$${CMAKE_MODULE_NAME}_process_prl_file(
\"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_PLUGIN_DIR}$${CMAKE_PRL_FILE_LOCATION_RELEASE}\" RELEASE
_Qt5$${CMAKE_PLUGIN_NAME}_STATIC_RELEASE_LIB_DEPENDENCIES
_Qt5$${CMAKE_PLUGIN_NAME}_STATIC_RELEASE_LINK_FLAGS
)
!!ELSE
_qt5_$${CMAKE_MODULE_NAME}_process_prl_file(
\"$${CMAKE_PLUGIN_DIR}$${CMAKE_PRL_FILE_LOCATION_RELEASE}\" RELEASE
_Qt5$${CMAKE_PLUGIN_NAME}_STATIC_RELEASE_LIB_DEPENDENCIES
_Qt5$${CMAKE_PLUGIN_NAME}_STATIC_RELEASE_LINK_FLAGS
)
!!ENDIF
!!ENDIF
!!IF !isEmpty(CMAKE_DEBUG_TYPE)
!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
_qt5_$${CMAKE_MODULE_NAME}_process_prl_file(
\"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_PLUGIN_DIR}$${CMAKE_PRL_FILE_LOCATION_DEBUG}\" DEBUG
_Qt5$${CMAKE_PLUGIN_NAME}_STATIC_DEBUG_LIB_DEPENDENCIES
_Qt5$${CMAKE_PLUGIN_NAME}_STATIC_DEBUG_LINK_FLAGS
)
!!ELSE
_qt5_$${CMAKE_MODULE_NAME}_process_prl_file(
\"$${CMAKE_PLUGIN_DIR}$${CMAKE_PRL_FILE_LOCATION_DEBUG}\" DEBUG
_Qt5$${CMAKE_PLUGIN_NAME}_STATIC_DEBUG_LIB_DEPENDENCIES
_Qt5$${CMAKE_PLUGIN_NAME}_STATIC_DEBUG_LINK_FLAGS
)
!!ENDIF
!!ENDIF
set_property(TARGET Qt5::$$CMAKE_PLUGIN_NAME PROPERTY INTERFACE_SOURCES
\"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}_$${CMAKE_PLUGIN_NAME}_Import.cpp\"
)
!!ENDIF
!!IF !isEmpty(CMAKE_RELEASE_TYPE)
_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE}\" $${CMAKE_DEBUG_AND_RELEASE})
!!ENDIF
!!IF !isEmpty(CMAKE_DEBUG_TYPE)
_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG}\" $${CMAKE_DEBUG_AND_RELEASE})
!!ENDIF
list(APPEND Qt5$${CMAKE_MODULE_NAME}_PLUGINS Qt5::$$CMAKE_PLUGIN_NAME)
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY QT_ALL_PLUGINS_$${CMAKE_PLUGIN_TYPE_ESCAPED} Qt5::$${CMAKE_PLUGIN_NAME})
!!IF !isEmpty(CMAKE_STATIC_TYPE)
# $<GENEX_EVAL:...> wasn\'t added until CMake 3.12, so put a version guard around it
if(CMAKE_VERSION VERSION_LESS \"3.12\")
set(_manual_plugins_genex \"$<TARGET_PROPERTY:QT_PLUGINS>\")
set(_plugin_type_genex \"$<TARGET_PROPERTY:QT_PLUGINS_$${CMAKE_PLUGIN_TYPE_ESCAPED}>\")
set(_no_plugins_genex \"$<TARGET_PROPERTY:QT_NO_PLUGINS>\")
else()
set(_manual_plugins_genex \"$<GENEX_EVAL:$<TARGET_PROPERTY:QT_PLUGINS>>\")
set(_plugin_type_genex \"$<GENEX_EVAL:$<TARGET_PROPERTY:QT_PLUGINS_$${CMAKE_PLUGIN_TYPE_ESCAPED}>>\")
set(_no_plugins_genex \"$<GENEX_EVAL:$<TARGET_PROPERTY:QT_NO_PLUGINS>>\")
endif()
set(_user_specified_genex
\"$<IN_LIST:Qt5::$$CMAKE_PLUGIN_NAME,${_manual_plugins_genex};${_plugin_type_genex}>\"
)
string(CONCAT _plugin_genex
\"$<$<OR:\"
# Add this plugin if it\'s in the list of manual plugins or plugins for the type
\"${_user_specified_genex},\"
# Add this plugin if the list of plugins for the type is empty, the PLUGIN_EXTENDS
# is either empty or equal to the module name, and the user hasn\'t blacklisted it
\"$<AND:\"
\"$<STREQUAL:${_plugin_type_genex},>,\"
\"$<OR:\"
\"$<STREQUAL:$<TARGET_PROPERTY:Qt5::$${CMAKE_PLUGIN_NAME},QT_PLUGIN_EXTENDS>,Qt5::$${CMAKE_MODULE_NAME}>,\"
\"$<STREQUAL:$<TARGET_PROPERTY:Qt5::$${CMAKE_PLUGIN_NAME},QT_PLUGIN_EXTENDS>,>\"
\">,\"
\"$<NOT:$<IN_LIST:Qt5::$${CMAKE_PLUGIN_NAME},${_no_plugins_genex}>>\"
\">\"
\">:Qt5::$$CMAKE_PLUGIN_NAME>\"
)
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY INTERFACE_LINK_LIBRARIES
${_plugin_genex}
)
set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} APPEND PROPERTY INTERFACE_LINK_LIBRARIES
\"$${CMAKE_PLUGIN_QT5_MODULE_DEPS}\"
)
!!ENDIF
set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} PROPERTY QT_PLUGIN_TYPE \"$$CMAKE_PLUGIN_TYPE\")
set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} PROPERTY QT_PLUGIN_EXTENDS \"$$CMAKE_PLUGIN_EXTENDS\")

View File

@ -1,4 +1,6 @@
load(qt_functions)
contains(TEMPLATE, subdirs) {
for(build, QMAKE_EXCLUSIVE_BUILDS) {
prepareRecursiveTarget($$build)

View File

@ -1,5 +1,9 @@
load(default_post)
# Recompute SDK version in case the user set it explicitly
sdk_version = $$QMAKE_MAC_SDK_VERSION
QMAKE_MAC_SDK_VERSION = $$xcodeSDKInfo(SDKVersion)
contains(TEMPLATE, .*app) {
!macx-xcode:if(isEmpty(BUILDS)|build_pass) {
# Detect changes to the platform SDK
@ -14,7 +18,7 @@ contains(TEMPLATE, .*app) {
!versionAtLeast(QMAKE_MAC_SDK_VERSION, $$QT_MAC_SDK_VERSION_MIN): \
warning("Qt requires at least version $$QT_MAC_SDK_VERSION_MIN of the platform SDK," \
"you're using $${QMAKE_MAC_SDK_VERSION}. Please upgrade.")
"you're building against version $${QMAKE_MAC_SDK_VERSION}. Please upgrade.")
!isEmpty(QT_MAC_SDK_VERSION_MAX) {
# For Qt developers only
@ -244,6 +248,11 @@ macx-xcode {
QMAKE_PCH_OUTPUT_EXT = _${QMAKE_PCH_ARCH}$${QMAKE_PCH_OUTPUT_EXT}
}
!equals(sdk_version, $$QMAKE_MAC_SDK_VERSION) {
# Explicit SDK version has been set, respect that
QMAKE_LFLAGS += -Wl,-sdk_version -Wl,$$sdk_version
}
cache(QMAKE_XCODE_DEVELOPER_PATH, stash)
!isEmpty(QMAKE_XCODE_VERSION): \
cache(QMAKE_XCODE_VERSION, stash)
@ -261,7 +270,7 @@ xcode_product_bundle_identifier_setting.value = "$${xcode_product_bundle_identif
QMAKE_MAC_XCODE_SETTINGS += xcode_product_bundle_identifier_setting
!macx-xcode {
generate_xcode_project.commands = @$(QMAKE) -spec macx-xcode $(EXPORT__PRO_FILE_)
generate_xcode_project.commands = @$(QMAKE) -spec macx-xcode $(EXPORT__PRO_FILE_) $$QMAKE_ARGS
generate_xcode_project.target = xcodeproj
QMAKE_EXTRA_VARIABLES += _PRO_FILE_
QMAKE_EXTRA_TARGETS += generate_xcode_project

View File

@ -22,7 +22,11 @@ for(ever) {
!defined(QMAKE_LIBS_$$nu, var): \
error("Library '$$lower($$replace(nu, _, -))' is not defined.")
debug: \
android {
ABI_LIBS = $$eval(QMAKE_LIBS_$${nu}_$${QT_ARCH})
isEmpty(ABI_LIBS): ABI_LIBS = $$eval(QMAKE_LIBS_$${nu})
LIBS$${suffix} += $$ABI_LIBS
} else: debug: \
LIBS$${suffix} += $$eval(QMAKE_LIBS_$${nu}_DEBUG) $$eval(QMAKE_LIBS_$$nu)
else: \
LIBS$${suffix} += $$eval(QMAKE_LIBS_$${nu}_RELEASE) $$eval(QMAKE_LIBS_$$nu)

View File

@ -52,15 +52,26 @@ builtin_resources {
qmldir.base = $$qmldir_path
qmldir.files = $$qmldir_file
qmldir.path = $$[QT_INSTALL_QML]/$$TARGETPATH
INSTALLS += qmldir
qmlfiles.base = $$_PRO_FILE_PWD_
qmlfiles.files = $$fq_aux_qml_files
install_qml_files: qmlfiles.files += $$fq_qml_files
qmlfiles.path = $${qmldir.path}
INSTALLS += qmlfiles
!debug_and_release|!build_all|CONFIG(release, debug|release) {
INSTALL_QML_FILES = false
android {
build_pass {
isEmpty(ANDROID_ABIS): ANDROID_ABIS = $$ALL_ANDROID_ABIS
ABI = $$first(ANDROID_ABIS)
equals(ABI, $$QT_ARCH): INSTALL_QML_FILES = true
}
} else: !debug_and_release|!build_all|CONFIG(release, debug|release): INSTALL_QML_FILES = true
equals(INSTALL_QML_FILES, true) {
INSTALLS += qmldir
INSTALLS += qmlfiles
!prefix_build {
COPIES += qmldir qmlfiles
} else {

View File

@ -16,7 +16,7 @@
ANDROID_DEPENDS_DIR = $$MODULE_BASE_OUTDIR/lib/
DEPENDENCY_FILE = $$ANDROID_DEPENDS_DIR$$TARGET-android-dependencies.xml
!build_pass {
build_pass:!isEmpty(QT_ARCH): {
!isEmpty(MODULE_PLUGIN_TYPES) {
for(PLUGIN_TYPE, MODULE_PLUGIN_TYPES) {
ANDROID_BUNDLED_FILES += "plugins/$$PLUGIN_TYPE"
@ -46,6 +46,8 @@ DEPENDENCY_FILE = $$ANDROID_DEPENDS_DIR$$TARGET-android-dependencies.xml
EXTENDS = $$section(LIB_FILE, ":", 1, 1)
!isEmpty(EXTENDS): EXTENDS = "extends=\"$$EXTENDS\""
LIB_FILE = $$section(LIB_FILE, ":", 0, 0)
LIB_FILE = $$replace(LIB_FILE,".so", "_$${QT_ARCH}.so")
!isEmpty(EXTENDS): EXTENDS = $$replace(EXTENDS,".so", "_$${QT_ARCH}.so")
FILE_CONTENT += "<lib file=\"$$LIB_FILE\" $$EXTENDS />"
}
}
@ -54,12 +56,14 @@ DEPENDENCY_FILE = $$ANDROID_DEPENDS_DIR$$TARGET-android-dependencies.xml
for(REPLACEMENT, ANDROID_LIB_DEPENDENCY_REPLACEMENTS) {
REPLACEMENT_FILE = $$section(REPLACEMENT, ":", 0, 0)
LIB_FILE = $$section(REPLACEMENT, ":", 1, 1)
REPLACEMENT_FILE = $$replace(REPLACEMENT_FILE,".so", "_$${QT_ARCH}.so")
FILE_CONTENT += "<lib file=\"$$LIB_FILE\" replaces=\"$$REPLACEMENT_FILE\" />"
}
}
!isEmpty(ANDROID_BUNDLED_FILES) {
for (BUNDLED_FILE, ANDROID_BUNDLED_FILES) {
BUNDLED_FILE = $$replace(BUNDLED_FILE,".so", "_$${QT_ARCH}.so")
FILE_CONTENT += "<bundled file=\"$$BUNDLED_FILE\" />"
}
}

View File

@ -108,6 +108,10 @@ macos: CONFIG += testcase_no_bundle
# Override MinGW's definition in _mingw.h
mingw: DEFINES += WINVER=0x0601 _WIN32_WINNT=0x0601
# By default, the following features should not be used in Qt's own
# implementation, so declare them invisible to Qt modules.
DEFINES += QT_NO_LINKED_LIST # QLinkedList
defineTest(qtBuildPart) {
bp = $$eval($$upper($$section(_QMAKE_CONF_, /, -2, -2))_BUILD_PARTS)
isEmpty(bp): bp = $$QT_BUILD_PARTS

View File

@ -560,7 +560,7 @@ defineTest(qtConfResolveLibs) {
} else {
paths += $$lp
}
} else: contains(l, "^-l.*") {
} else: !android: contains(l, "^-l.*") {
lib = $$replace(l, "^-l", )
lcan =
integrity:contains(lib, "^.*\\.a") {
@ -1905,8 +1905,11 @@ defineTest(qtConfCreateReportRecurse) {
entry = $${1}.$$n
subKeys = $$eval($${entry}._KEYS_)
contains(subKeys, condition) {
condition = $$eval($${entry}.condition)
r = $$qtConfEvaluate($$condition)
r = true
for (condition, $$qtConfScalarOrList($${entry}.condition)) {
r = $$qtConfEvaluate($$condition)
!$$r: break()
}
!qtConfIsBoolean($$r): \
error("Evaluation of condition '$$condition' in report entry $${entry} yielded non-boolean value '$$r'.")
!$$r: next()

View File

@ -1,7 +1,8 @@
defineReplace(qtPlatformTargetSuffix) {
suffix =
CONFIG(debug, debug|release) {
android: return($${suffix}_$${QT_ARCH})
else: CONFIG(debug, debug|release) {
!debug_and_release|build_pass {
mac: return($${suffix}_debug)
win32: return($${suffix}d)

View File

@ -29,19 +29,19 @@ DLLDESTDIR = $$MODULE_BASE_OUTDIR/bin
THE_TARGET = $$qt5LibraryTarget($$TARGET)
!build_pass {
MODULE = $$replace(TARGET, ^qt, )
MODULE ~= s,-,_,
MODULE_PRI = $$MODULE_QMAKE_OUTDIR/mkspecs/modules/qt_ext_$${MODULE}.pri
ucmodule = $$upper($$MODULE)
MODULE = $$replace(TARGET, ^qt, )
MODULE ~= s,-,_,
MODULE_PRI = $$MODULE_QMAKE_OUTDIR/mkspecs/modules/qt_ext_$${MODULE}.pri
ucmodule = $$upper($$MODULE)
win32|CONFIG(static, static|shared) {
prefix = $$QMAKE_PREFIX_STATICLIB
suffix = $$QMAKE_EXTENSION_STATICLIB
} else {
prefix = $$QMAKE_PREFIX_SHLIB
suffix = $$QMAKE_EXTENSION_SHLIB
}
win32|CONFIG(static, static|shared) {
prefix = $$QMAKE_PREFIX_STATICLIB
suffix = $$QMAKE_EXTENSION_STATICLIB
} else {
prefix = $$QMAKE_PREFIX_SHLIB
suffix = $$QMAKE_EXTENSION_SHLIB
}
!build_pass {
CC_USES =
LD_USES =
for (use, QMAKE_USE) {
@ -58,7 +58,9 @@ THE_TARGET = $$qt5LibraryTarget($$TARGET)
"QMAKE_DEPENDS_$${ucmodule}_LD =$$join(LD_USES, " ", " ")" \
"QMAKE_INCDIR_$${ucmodule} = $$val_escape(MODULE_INCLUDEPATH)" \
"QMAKE_DEFINES_$${ucmodule} = $$val_escape(MODULE_DEFINES)"
debug_and_release {
android {
MODULE_PRI_CONT += "QMAKE_LIBS_$${ucmodule} ="
} else: debug_and_release {
win32: \
MODULE_DEBUG_LIBS = $$DESTDIR/$$prefix$${TARGET}d.$$suffix
else: darwin: \
@ -76,6 +78,11 @@ THE_TARGET = $$qt5LibraryTarget($$TARGET)
"QMAKE_LIBS_$${ucmodule} = $$val_escape(MODULE_LIBS)"
}
write_file($$MODULE_PRI, MODULE_PRI_CONT)|error()
} else: android {
ABI_TARGET = $$qt5LibraryTarget($$TARGET)
ABI_MODULE_LIBS = $$DESTDIR/$$prefix$${ABI_TARGET}.$$suffix
MODULE_PRI_CONT = "QMAKE_LIBS_$${ucmodule}_$${QT_ARCH} = $$val_escape(ABI_MODULE_LIBS)"
write_file($$MODULE_PRI, MODULE_PRI_CONT, append)|error()
}
TARGET = $$THE_TARGET

View File

@ -93,7 +93,7 @@ header_module {
DESTDIR = $$MODULE_BASE_OUTDIR/lib
DLLDESTDIR = $$MODULE_BASE_OUTDIR/bin
CONFIG += qmake_cache target_qt
CONFIG += target_qt
QMAKE_DOCS_TARGETDIR = qt$${MODULE}

View File

@ -51,13 +51,12 @@ defineReplace(qtGetExportsForModule) {
return($$result)
}
defineReplace(qtExportLibsForModule) {
defineReplace(qtExportDepsForModule) {
result =
for (lib, QT.$${1}.libraries) {
NAME = $$upper($$lib)
vars = \
QMAKE_DEPENDS_$${NAME}_CC QMAKE_DEPENDS_$${NAME}_LD \
QMAKE_LIBS_$$NAME QMAKE_LIBS_$${NAME}_DEBUG QMAKE_LIBS_$${NAME}_RELEASE \
QMAKE_DEFINES_$$NAME QMAKE_INCDIR_$$NAME
for (var, vars) {
expvar = $$var
@ -71,6 +70,24 @@ defineReplace(qtExportLibsForModule) {
return($$result)
}
defineReplace(qtExportLibsForModule) {
result =
for (lib, QT.$${1}.libraries) {
NAME = $$upper($$lib)
vars = \
QMAKE_LIBS_$$NAME QMAKE_LIBS_$${NAME}_DEBUG QMAKE_LIBS_$${NAME}_RELEASE
for (var, vars) {
expvar = $$var
expvar ~= s/^QMAKE_/QMAKE_EXPORT_/
defined($$expvar, var):equals($$expvar, -): next()
!defined($$expvar, var): expvar = $$var
defined($$expvar, var): \
result += "$$var$${2} = $$val_escape($$expvar)"
}
}
return($$result)
}
!build_pass {
# Create a module .pri file
@ -160,6 +177,7 @@ defineReplace(qtExportLibsForModule) {
"QT.$${MODULE}_private.module_config =$$join(module_build_type, " ", " ")" \
$$qtGetFeaturesForModule($${MODULE}_private) \
"" \
$$qtExportDepsForModule($${MODULE}_private) \
$$qtExportLibsForModule($${MODULE}_private)
write_file($$MODULE_PRIVATE_PRI, MODULE_PRIVATE_PRI_CONT)|error()
}
@ -220,7 +238,10 @@ defineReplace(qtExportLibsForModule) {
}
cache(QT_MODULES, transient)
} # !build_pass
} else:android:!no_private_module:!internal_module {
MODULE_PRIVATE_PRI_CONT = $$qtExportLibsForModule($${MODULE}_private, _$${QT_ARCH})
write_file($$MODULE_PRIVATE_PRI, MODULE_PRIVATE_PRI_CONT, append)|error()
}
# Schedule the regular .pri file for installation
CONFIG += qt_install_module

View File

@ -14,6 +14,8 @@ load(device_config)
QMAKE_CFLAGS += -s WASM_OBJECT_FILES=$$WASM_OBJECT_FILES
QMAKE_CXXFLAGS += -s WASM_OBJECT_FILES=$$WASM_OBJECT_FILES
QMAKE_LFLAGS += -s WASM_OBJECT_FILES=$$WASM_OBJECT_FILES
} else {
EMCC_COMMON_LFLAGS += -s \"BINARYEN_TRAP_MODE=\'clamp\'\"
}
EMTERP_FLAGS = \
@ -29,8 +31,7 @@ EMCC_COMMON_LFLAGS = \
-s USE_WEBGL2=1 \
-s NO_EXIT_RUNTIME=0 \
-s ERROR_ON_UNDEFINED_SYMBOLS=1 \
--bind \
-s \"BINARYEN_TRAP_MODE=\'clamp\'\"
--bind
# The -s arguments can also be used with release builds,
# but are here in debug for clarity.

View File

@ -39,6 +39,11 @@ QMAKE_CXXFLAGS += -Wno-microsoft-enum-value
QMAKE_LINK = lld-link
QMAKE_LIB = llvm-lib /NOLOGO
QMAKE_CXXFLAGS_CXX11 = -std:c++11
QMAKE_CXXFLAGS_CXX14 = -std:c++14
QMAKE_CXXFLAGS_CXX1Z = -std:c++17
QMAKE_CXXFLAGS_CXX2A = -std:c++latest
QMAKE_CFLAGS_LTCG = -flto=thin
QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG
QMAKE_CFLAGS_LTCG_FATOBJECTS = -flto
@ -49,6 +54,4 @@ QMAKE_LFLAGS_LTCG =
QMAKE_CFLAGS_OPTIMIZE_SIZE = /clang:-Oz
QMAKE_CFLAGS_OPTIMIZE_FULL = /clang:-O3
QMAKE_LFLAGS_RELEASE += /OPT:REF,ICF,LBR
load(qt_config)

View File

@ -28,6 +28,7 @@ QOBJS = \
qmetatype.o qsystemerror.o qvariant.o \
quuid.o \
qarraydata.o qbitarray.o qbytearray.o qbytearraymatcher.o \
qcalendar.o qgregoriancalendar.o qromancalendar.o \
qcryptographichash.o qdatetime.o qhash.o qlist.o \
qlocale.o qlocale_tools.o qmap.o qregexp.o qringbuffer.o \
qstringbuilder.o qstring.o qstringlist.o qversionnumber.o \
@ -114,7 +115,10 @@ DEPEND_SRC = \
$(SOURCE_PATH)/src/corelib/text/qstring.cpp \
$(SOURCE_PATH)/src/corelib/text/qstringlist.cpp \
$(SOURCE_PATH)/src/corelib/text/qvsnprintf.cpp \
$(SOURCE_PATH)/src/corelib/time/qcalendar.cpp \
$(SOURCE_PATH)/src/corelib/time/qdatetime.cpp \
$(SOURCE_PATH)/src/corelib/time/qgregoriancalendar.cpp \
$(SOURCE_PATH)/src/corelib/time/qromancalendar.cpp \
$(SOURCE_PATH)/src/corelib/tools/qarraydata.cpp \
$(SOURCE_PATH)/src/corelib/tools/qbitarray.cpp \
$(SOURCE_PATH)/src/corelib/tools/qcryptographichash.cpp \
@ -428,6 +432,15 @@ qfileinfo.o: $(SOURCE_PATH)/src/corelib/io/qfileinfo.cpp
qdatetime.o: $(SOURCE_PATH)/src/corelib/time/qdatetime.cpp
$(CXX) -c -o $@ $(CXXFLAGS) $<
qcalendar.o: $(SOURCE_PATH)/src/corelib/time/qcalendar.cpp
$(CXX) -c -o $@ $(CXXFLAGS) $<
qgregoriancalendar.o: $(SOURCE_PATH)/src/corelib/time/qgregoriancalendar.cpp
$(CXX) -c -o $@ $(CXXFLAGS) $<
qromancalendar.o: $(SOURCE_PATH)/src/corelib/time/qromancalendar.cpp
$(CXX) -c -o $@ $(CXXFLAGS) $<
qstringlist.o: $(SOURCE_PATH)/src/corelib/text/qstringlist.cpp
$(CXX) -c -o $@ $(CXXFLAGS) $<

View File

@ -71,6 +71,7 @@ QTOBJS= \
qbytearray.obj \
qvsnprintf.obj \
qbytearraymatcher.obj \
qcalendar.obj \
qdatetime.obj \
qdir.obj \
qdiriterator.obj \
@ -83,6 +84,7 @@ QTOBJS= \
qfileinfo.obj \
qendian.obj \
qglobal.obj \
qgregoriancalendar.obj \
qhash.obj \
qiodevice.obj \
qringbuffer.obj \
@ -97,6 +99,7 @@ QTOBJS= \
qoperatingsystemversion.obj \
qoperatingsystemversion_win.obj \
qregexp.obj \
qromancalendar.obj \
qutfcodec.obj \
qstring.obj \
qstringlist.obj \

View File

@ -2583,10 +2583,8 @@
\section1 RC_FILE
Specifies the name of the resource file for the application.
The value of this variable is typically handled by
qmake or \l{#QMAKESPEC}{qmake.conf} and rarely
needs to be modified.
Windows only. Specifies the name of the Windows resource file (.rc) for the
target. See \l{Adding Windows Resource Files}.
\target RC_CODEPAGE
\section1 RC_CODEPAGE
@ -2649,7 +2647,9 @@
\section1 RES_FILE
Specifies the name of the compiled Windows resource file for the target.
Windows only. Specifies the name of the Windows resource compiler's output
file for this target. See \l{RC_FILE} and \l{Adding Windows Resource Files}.
The value of this variable is typically handled by
qmake or \l{#QMAKESPEC}{qmake.conf} and rarely
needs to be modified.

View File

@ -764,27 +764,13 @@ MakefileGenerator::init()
ProStringList incDirs = v["DEPENDPATH"] + v["QMAKE_ABSOLUTE_SOURCE_PATH"];
if(project->isActiveConfig("depend_includepath"))
incDirs += v["INCLUDEPATH"];
QList<QMakeLocalFileName> deplist;
QVector<QMakeLocalFileName> deplist;
deplist.reserve(incDirs.size());
for (ProStringList::Iterator it = incDirs.begin(); it != incDirs.end(); ++it)
deplist.append(QMakeLocalFileName((*it).toQString()));
QMakeSourceFileInfo::setDependencyPaths(deplist);
debug_msg(1, "Dependency Directories: %s",
incDirs.join(QString(" :: ")).toLatin1().constData());
//cache info
if(project->isActiveConfig("qmake_cache")) {
QString cache_file;
if(!project->isEmpty("QMAKE_INTERNAL_CACHE_FILE")) {
cache_file = QDir::fromNativeSeparators(project->first("QMAKE_INTERNAL_CACHE_FILE").toQString());
} else {
cache_file = ".qmake.internal.cache";
if(project->isActiveConfig("build_pass"))
cache_file += ".BUILD." + project->first("BUILD_PASS");
}
if(cache_file.indexOf('/') == -1)
cache_file.prepend(Option::output_dir + '/');
QMakeSourceFileInfo::setCacheFile(cache_file);
}
//add to dependency engine
for(x = 0; x < compilers.count(); ++x) {
@ -1839,7 +1825,7 @@ static QStringList splitDeps(const QString &indeps, bool lineMode)
QString MakefileGenerator::resolveDependency(const QDir &outDir, const QString &file)
{
const QList<QMakeLocalFileName> &depdirs = QMakeSourceFileInfo::dependencyPaths();
const QVector<QMakeLocalFileName> &depdirs = QMakeSourceFileInfo::dependencyPaths();
for (const auto &depdir : depdirs) {
const QString &local = depdir.local();
QString lf = outDir.absoluteFilePath(local + '/' + file);
@ -3105,7 +3091,7 @@ MakefileGenerator::findFileForDep(const QMakeLocalFileName &dep, const QMakeLoca
if(Option::output_dir != qmake_getpwd()
&& QDir::isRelativePath(dep.real())) { //is it from the shadow tree
QList<QMakeLocalFileName> depdirs = QMakeSourceFileInfo::dependencyPaths();
QVector<QMakeLocalFileName> depdirs = QMakeSourceFileInfo::dependencyPaths();
depdirs.prepend(fileInfo(file.real()).absoluteDir().path());
QString pwd = qmake_getpwd();
if(pwd.at(pwd.length()-1) != '/')
@ -3456,4 +3442,13 @@ QString MakefileGenerator::shellQuote(const QString &str)
return isWindowsShell() ? IoUtils::shellQuoteWin(str) : IoUtils::shellQuoteUnix(str);
}
/*
* Returns the name of the variable that contains the fully resolved target
* (including DESTDIR) of this generator.
*/
ProKey MakefileGenerator::fullTargetVariable() const
{
return "TARGET";
}
QT_END_NAMESPACE

View File

@ -276,6 +276,7 @@ public:
virtual bool openOutput(QFile &, const QString &build) const;
bool isWindowsShell() const { return Option::dir_sep == QLatin1String("\\"); }
QString shellQuote(const QString &str);
virtual ProKey fullTargetVariable() const;
};
Q_DECLARE_TYPEINFO(MakefileGenerator::Compiler, Q_MOVABLE_TYPE);
Q_DECLARE_OPERATORS_FOR_FLAGS(MakefileGenerator::FileFixifyTypes)

View File

@ -60,21 +60,14 @@ QT_BEGIN_NAMESPACE
inline bool qmake_endOfLine(const char &c) { return (c == '\r' || c == '\n'); }
#endif
//#define QMAKE_USE_CACHE
QMakeLocalFileName::QMakeLocalFileName(const QString &name) : is_null(name.isNull())
QMakeLocalFileName::QMakeLocalFileName(const QString &name)
: real_name(name)
{
if(!name.isEmpty()) {
if(name.at(0) == QLatin1Char('"') && name.at(name.length()-2) == QLatin1Char('"'))
real_name = name.mid(1, name.length()-2);
else
real_name = name;
}
}
const QString
&QMakeLocalFileName::local() const
{
if(!is_null && local_name.isNull())
if (!isNull() && local_name.isNull())
local_name = Option::normalizePath(real_name);
return local_name;
}
@ -199,10 +192,10 @@ void QMakeSourceFileInfo::dependTreeWalker(SourceFile *node, SourceDependChildre
}
}
void QMakeSourceFileInfo::setDependencyPaths(const QList<QMakeLocalFileName> &l)
void QMakeSourceFileInfo::setDependencyPaths(const QVector<QMakeLocalFileName> &l)
{
// Ensure that depdirs does not contain the same paths several times, to minimize the stats
QList<QMakeLocalFileName> ll;
QVector<QMakeLocalFileName> ll;
for (int i = 0; i < l.count(); ++i) {
if (!ll.contains(l.at(i)))
ll.append(l.at(i));
@ -265,19 +258,10 @@ QMakeSourceFileInfo::QMakeSourceFileInfo(const QString &cf)
//buffer
spare_buffer = nullptr;
spare_buffer_size = 0;
//cache
cachefile = cf;
if(!cachefile.isEmpty())
loadCache(cachefile);
}
QMakeSourceFileInfo::~QMakeSourceFileInfo()
{
//cache
if(!cachefile.isEmpty() /*&& files_changed*/)
saveCache(cachefile);
//buffer
if(spare_buffer) {
free(spare_buffer);
@ -290,12 +274,6 @@ QMakeSourceFileInfo::~QMakeSourceFileInfo()
delete includes;
}
void QMakeSourceFileInfo::setCacheFile(const QString &cf)
{
cachefile = cf;
loadCache(cachefile);
}
void QMakeSourceFileInfo::addSourceFiles(const ProStringList &l, uchar seek,
QMakeSourceFileInfo::SourceFileType type)
{
@ -853,8 +831,8 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
}
}
if(!exists) { //path lookup
for(QList<QMakeLocalFileName>::Iterator it = depdirs.begin(); it != depdirs.end(); ++it) {
QMakeLocalFileName f((*it).real() + Option::dir_sep + lfn.real());
for (const QMakeLocalFileName &depdir : qAsConst(depdirs)) {
QMakeLocalFileName f(depdir.real() + Option::dir_sep + lfn.real());
QFileInfo fi(findFileInfo(f));
if(fi.exists() && !fi.isDir()) {
lfn = fixPathForFile(f);
@ -1054,151 +1032,4 @@ bool QMakeSourceFileInfo::findMocs(SourceFile *file)
return true;
}
void QMakeSourceFileInfo::saveCache(const QString &cf)
{
#ifdef QMAKE_USE_CACHE
if(cf.isEmpty())
return;
QFile file(QMakeLocalFileName(cf).local());
if(file.open(QIODevice::WriteOnly)) {
QTextStream stream(&file);
stream << QMAKE_VERSION_STR << endl << endl; //version
{ //cache verification
QMap<QString, QStringList> verify = getCacheVerification();
stream << verify.count() << endl;
for(QMap<QString, QStringList>::iterator it = verify.begin();
it != verify.end(); ++it) {
stream << it.key() << endl << it.value().join(';') << endl;
}
stream << endl;
}
if(files->nodes) {
for(int file = 0; file < files->num_nodes; ++file) {
for(SourceFiles::SourceFileNode *node = files->nodes[file]; node; node = node->next) {
stream << node->file->file.local() << endl; //source
stream << node->file->type << endl; //type
//depends
stream << ";";
if(node->file->deps) {
for(int depend = 0; depend < node->file->deps->used_nodes; ++depend) {
if(depend)
stream << ";";
stream << node->file->deps->children[depend]->file.local();
}
}
stream << endl;
stream << node->file->mocable << endl; //mocable
stream << endl; //just for human readability
}
}
}
stream.flush();
file.close();
}
#else
Q_UNUSED(cf);
#endif
}
void QMakeSourceFileInfo::loadCache(const QString &cf)
{
if(cf.isEmpty())
return;
#ifdef QMAKE_USE_CACHE
QMakeLocalFileName cache_file(cf);
int fd = open(QMakeLocalFileName(cf).local().toLatin1(), O_RDONLY);
if(fd == -1)
return;
QFileInfo cache_fi = findFileInfo(cache_file);
if(!cache_fi.exists() || cache_fi.isDir())
return;
QFile file;
if (!file.open(fd, QIODevice::ReadOnly))
return;
QTextStream stream(&file);
if (stream.readLine() == QMAKE_VERSION_STR) { //version check
stream.skipWhiteSpace();
bool verified = true;
{ //cache verification
QMap<QString, QStringList> verify;
int len = stream.readLine().toInt();
for(int i = 0; i < len; ++i) {
QString var = stream.readLine();
QString val = stream.readLine();
verify.insert(var, val.split(';', QString::SkipEmptyParts));
}
verified = verifyCache(verify);
}
if(verified) {
stream.skipWhiteSpace();
if(!files)
files = new SourceFiles;
while(!stream.atEnd()) {
QString source = stream.readLine();
QString type = stream.readLine();
QString depends = stream.readLine();
QString mocable = stream.readLine();
stream.skipWhiteSpace();
QMakeLocalFileName fn(source);
QFileInfo fi = findFileInfo(fn);
SourceFile *file = files->lookupFile(fn);
if(!file) {
file = new SourceFile;
file->file = fn;
files->addFile(file);
file->type = (SourceFileType)type.toInt();
file->exists = fi.exists();
}
if(fi.exists() && fi.lastModified() < cache_fi.lastModified()) {
if(!file->dep_checked) { //get depends
if(!file->deps)
file->deps = new SourceDependChildren;
file->dep_checked = true;
QStringList depend_list = depends.split(";", QString::SkipEmptyParts);
for(int depend = 0; depend < depend_list.size(); ++depend) {
QMakeLocalFileName dep_fn(depend_list.at(depend));
QFileInfo dep_fi(findFileInfo(dep_fn));
SourceFile *dep = files->lookupFile(dep_fn);
if(!dep) {
dep = new SourceFile;
dep->file = dep_fn;
dep->exists = dep_fi.exists();
dep->type = QMakeSourceFileInfo::TYPE_UNKNOWN;
files->addFile(dep);
}
dep->included_count++;
file->deps->addChild(dep);
}
}
if(!file->moc_checked) { //get mocs
file->moc_checked = true;
file->mocable = mocable.toInt();
}
}
}
}
}
#endif
}
QMap<QString, QStringList> QMakeSourceFileInfo::getCacheVerification()
{
return QMap<QString, QStringList>();
}
bool QMakeSourceFileInfo::verifyCache(const QMap<QString, QStringList> &v)
{
return v == getCacheVerification();
}
QT_END_NAMESPACE

View File

@ -33,6 +33,7 @@
#include <qstringlist.h>
#include <qfileinfo.h>
#include <qvector.h>
QT_BEGIN_NAMESPACE
@ -40,13 +41,14 @@ struct SourceFile;
struct SourceDependChildren;
class SourceFiles;
class QMakeLocalFileName {
bool is_null;
mutable QString real_name, local_name;
class QMakeLocalFileName
{
QString real_name;
mutable QString local_name;
public:
QMakeLocalFileName() : is_null(true) {}
QMakeLocalFileName() = default;
QMakeLocalFileName(const QString &);
bool isNull() const { return is_null; }
bool isNull() const { return real_name.isNull(); }
inline const QString &real() const { return real_name; }
const QString &local() const;
@ -64,7 +66,7 @@ private:
//quick project lookups
SourceFiles *files, *includes;
bool files_changed;
QList<QMakeLocalFileName> depdirs;
QVector<QMakeLocalFileName> depdirs;
QStringList systemIncludes;
//sleezy buffer code
@ -77,9 +79,6 @@ private:
bool findDeps(SourceFile *);
void dependTreeWalker(SourceFile *, SourceDependChildren *);
//cache
QString cachefile;
protected:
virtual QMakeLocalFileName fixPathForFile(const QMakeLocalFileName &, bool forOpen=false);
virtual QMakeLocalFileName findFileForDep(const QMakeLocalFileName &, const QMakeLocalFileName &);
@ -90,8 +89,8 @@ public:
QMakeSourceFileInfo(const QString &cachefile="");
virtual ~QMakeSourceFileInfo();
QList<QMakeLocalFileName> dependencyPaths() const { return depdirs; }
void setDependencyPaths(const QList<QMakeLocalFileName> &);
QVector<QMakeLocalFileName> dependencyPaths() const { return depdirs; }
void setDependencyPaths(const QVector<QMakeLocalFileName> &);
enum DependencyMode { Recursive, NonRecursive };
inline void setDependencyMode(DependencyMode mode) { dep_mode = mode; }
@ -112,12 +111,6 @@ public:
bool mocable(const QString &file);
virtual QMap<QString, QStringList> getCacheVerification();
virtual bool verifyCache(const QMap<QString, QStringList> &);
void setCacheFile(const QString &cachefile); //auto caching
void loadCache(const QString &cf);
void saveCache(const QString &cf);
private:
DependencyMode dep_mode;
};

View File

@ -33,6 +33,10 @@
#include "project.h"
#include "cachekeys.h"
#include <algorithm>
#include <iterator>
#include <utility>
#define BUILDSMETATYPE 1
#define SUBDIRSMETATYPE 2
@ -58,6 +62,7 @@ private:
void clearBuilds();
MakefileGenerator *processBuild(const ProString &);
void accumulateVariableFromBuilds(const ProKey &name, Build *build) const;
void checkForConflictingTargets() const;
public:
@ -186,6 +191,7 @@ BuildsMetaMakefileGenerator::write()
if(!build->makefile) {
ret = false;
} else if(build == glue) {
checkForConflictingTargets();
accumulateVariableFromBuilds("QMAKE_INTERNAL_INCLUDED_FILES", build);
ret = build->makefile->writeProjectMakefile();
} else {
@ -239,6 +245,39 @@ void BuildsMetaMakefileGenerator::accumulateVariableFromBuilds(const ProKey &nam
values.removeDuplicates();
}
void BuildsMetaMakefileGenerator::checkForConflictingTargets() const
{
if (makefiles.count() < 3) {
// Checking for conflicts only makes sense if we have more than one BUILD,
// and the last entry in makefiles is the "glue" Build.
return;
}
using TargetInfo = std::pair<Build *, ProString>;
QVector<TargetInfo> targets;
const int last = makefiles.count() - 1;
targets.resize(last);
for (int i = 0; i < last; ++i) {
Build *b = makefiles.at(i);
auto mkf = b->makefile;
auto prj = mkf->projectFile();
targets[i] = std::make_pair(b, prj->first(mkf->fullTargetVariable()));
}
std::stable_sort(targets.begin(), targets.end(),
[](const TargetInfo &lhs, const TargetInfo &rhs)
{
return lhs.second < rhs.second;
});
for (auto prev = targets.begin(), it = std::next(prev); it != targets.end(); ++prev, ++it) {
if (prev->second == it->second) {
warn_msg(WarnLogic, "Targets of builds '%s' and '%s' conflict: %s.",
qPrintable(prev->first->build),
qPrintable(it->first->build),
qPrintable(prev->second.toQString()));
break;
}
}
}
class SubdirsMetaMakefileGenerator : public MetaMakefileGenerator
{
protected:

View File

@ -215,7 +215,7 @@ ProjectGenerator::init()
}
//setup deplist
QList<QMakeLocalFileName> deplist;
QVector<QMakeLocalFileName> deplist;
{
const ProStringList &d = v["DEPENDPATH"];
for(int i = 0; i < d.size(); ++i)

View File

@ -392,7 +392,7 @@ UnixMakefileGenerator::fixLibFlag(const ProString &lib)
bool
UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
{
QList<QMakeLocalFileName> libdirs, frameworkdirs;
QVector<QMakeLocalFileName> libdirs, frameworkdirs;
int libidx = 0, fwidx = 0;
for (const ProString &dlib : project->values("QMAKE_DEFAULT_LIBDIRS"))
libdirs.append(QMakeLocalFileName(dlib.toQString()));
@ -418,9 +418,8 @@ UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
libdirs.insert(libidx++, f);
} else if(opt.startsWith("-l")) {
QString lib = opt.mid(2);
for (QList<QMakeLocalFileName>::Iterator dep_it = libdirs.begin();
dep_it != libdirs.end(); ++dep_it) {
QString libBase = (*dep_it).local() + '/'
for (const QMakeLocalFileName &libdir : qAsConst(libdirs)) {
QString libBase = libdir.local() + '/'
+ project->first("QMAKE_PREFIX_SHLIB") + lib;
if (linkPrl && processPrlFile(libBase, true))
goto found;

View File

@ -1447,7 +1447,36 @@ UnixMakefileGenerator::libtoolFileName(bool fixify)
void
UnixMakefileGenerator::writeLibtoolFile()
{
auto fixDependencyLibs
= [this](const ProStringList &libs)
{
ProStringList result;
for (auto lib : libs) {
auto fi = fileInfo(lib.toQString());
if (fi.isAbsolute()) {
const QString libDirArg = "-L" + fi.path();
if (!result.contains(libDirArg))
result += libDirArg;
QString namespec = fi.fileName();
int dotPos = namespec.lastIndexOf('.');
if (dotPos != -1 && namespec.startsWith("lib")) {
namespec.truncate(dotPos);
namespec.remove(0, 3);
} else {
debug_msg(1, "Ignoring dependency library %s",
lib.toLatin1().constData());
continue;
}
result += "-l" + namespec;
} else {
result += lib;
}
}
return result;
};
QString fname = libtoolFileName(), lname = fname;
debug_msg(1, "Writing libtool file %s", fname.toLatin1().constData());
mkdir(fileInfo(fname).path());
int slsh = lname.lastIndexOf(Option::dir_sep);
if(slsh != -1)
@ -1485,12 +1514,11 @@ UnixMakefileGenerator::writeLibtoolFile()
<< ".a'\n\n";
t << "# Libraries that this one depends upon.\n";
static const ProKey libVars[] = { "LIBS", "QMAKE_LIBS" };
ProStringList libs;
libs << "LIBS" << "QMAKE_LIBS";
t << "dependency_libs='";
for (ProStringList::ConstIterator it = libs.cbegin(); it != libs.cend(); ++it)
t << fixLibFlags((*it).toKey()).join(' ') << ' ';
t << "'\n\n";
for (auto var : libVars)
libs += fixLibFlags(var);
t << "dependency_libs='" << fixDependencyLibs(libs).join(' ') << "'\n\n";
t << "# Version information for " << lname << "\n";
int maj = project->first("VER_MAJ").toInt();

View File

@ -342,7 +342,11 @@ void MingwMakefileGenerator::writeRcFilePart(QTextStream &t)
if (defines.isEmpty())
defines = ProString(" $(DEFINES)");
t << escapeDependencyPath(var("RES_FILE")) << ": " << escapeDependencyPath(rc_file) << "\n\t"
addSourceFile(rc_file, QMakeSourceFileInfo::SEEK_DEPS);
const QStringList rcDeps = QStringList(rc_file) << dependencies(rc_file);
t << escapeDependencyPath(var("RES_FILE")) << ": "
<< escapeDependencyPaths(rcDeps).join(' ') << "\n\t"
<< var("QMAKE_RC") << " -i " << escapeFilePath(rc_file) << " -o " << fileVar("RES_FILE")
<< incPathStr << defines << "\n\n";
}

View File

@ -300,14 +300,17 @@ inline XmlOutput::xml_output valueTagT( const triState v)
return valueTag(v == _True ? "true" : "false");
}
static QString vcxCommandSeparator()
static QString commandLinesForOutput(QStringList commands)
{
// MSBuild puts the contents of the custom commands into a batch file and calls it.
// As we want every sub-command to be error-checked (as is done by makefile-based
// backends), we insert the checks ourselves, using the undocumented jump target.
static QString cmdSep =
QLatin1String("&#x000D;&#x000A;if errorlevel 1 goto VCEnd&#x000D;&#x000A;");
return cmdSep;
static QString errchk = QStringLiteral("if errorlevel 1 goto VCEnd");
for (int i = commands.count() - 2; i >= 0; --i) {
if (!commands.at(i).startsWith("rem", Qt::CaseInsensitive))
commands.insert(i + 1, errchk);
}
return commands.join('\n');
}
static QString unquote(const QString &value)
@ -1658,7 +1661,7 @@ void VCXProjectWriter::write(XmlOutput &xml, const VCCustomBuildTool &tool)
{
xml << tag("Command")
<< attrTag("Condition", condition)
<< valueTag(tool.CommandLine.join(vcxCommandSeparator()));
<< valueTag(commandLinesForOutput(tool.CommandLine));
}
if ( !tool.Description.isEmpty() )
@ -1712,7 +1715,7 @@ void VCXProjectWriter::write(XmlOutput &xml, const VCEventTool &tool)
{
xml
<< tag(tool.EventName)
<< tag(_Command) << valueTag(tool.CommandLine.join(vcxCommandSeparator()))
<< tag(_Command) << valueTag(commandLinesForOutput(tool.CommandLine))
<< tag(_Message) << valueTag(tool.Description)
<< closetag(tool.EventName);
}

View File

@ -209,7 +209,9 @@ bool VcprojGenerator::writeProjectMakefile()
struct VcsolutionDepend {
QString uuid;
QString vcprojFile, orig_target, target;
QString vcprojFile;
QString projectName;
QString target;
Target targetType;
QStringList dependencies;
};
@ -433,7 +435,8 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash<QSt
Option::qmake_mode = old_mode;
// We assume project filename is [QMAKE_PROJECT_NAME].vcproj
QString vcproj = tmp_vcproj.project->first("QMAKE_PROJECT_NAME") + project->first("VCPROJ_EXTENSION");
const ProString projectName = tmp_vcproj.project->first("QMAKE_PROJECT_NAME");
const QString vcproj = projectName + project->first("VCPROJ_EXTENSION");
QString vcprojDir = Option::output_dir;
// If file doesn't exsist, then maybe the users configuration
@ -445,14 +448,14 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash<QSt
VcsolutionDepend *newDep = new VcsolutionDepend;
newDep->vcprojFile = vcprojDir + Option::dir_sep + vcproj;
newDep->orig_target = tmp_proj.first("QMAKE_ORIG_TARGET").toQString();
newDep->projectName = projectName.toQString();
newDep->target = tmp_proj.first("MSVCPROJ_TARGET").toQString().section(Option::dir_sep, -1);
newDep->targetType = tmp_vcproj.projectTarget;
newDep->uuid = tmp_proj.isEmpty("QMAKE_UUID") ? getProjectUUID(Option::fixPathToLocalOS(vcprojDir + QDir::separator() + vcproj)).toString().toUpper(): tmp_proj.first("QMAKE_UUID").toQString();
// We want to store it as the .lib name.
if (newDep->target.endsWith(".dll"))
newDep->target = newDep->target.left(newDep->target.length()-3) + "lib";
projGuids.insert(newDep->orig_target, newDep->target);
projGuids.insert(newDep->projectName, newDep->target);
if (tmpList.size()) {
const ProStringList depends = tmpList;
@ -591,7 +594,7 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
for (QList<VcsolutionDepend*>::Iterator it = solution_cleanup.begin(); it != solution_cleanup.end(); ++it) {
// ### quoting rules?
t << _slnProjectBeg << _slnMSVCvcprojGUID << _slnProjectMid
<< "\"" << (*it)->orig_target << "\", \"" << (*it)->vcprojFile
<< "\"" << (*it)->projectName << "\", \"" << (*it)->vcprojFile
<< "\", \"" << (*it)->uuid << "\"";
debug_msg(1, "Project %s has dependencies: %s", (*it)->target.toLatin1().constData(), (*it)->dependencies.join(" ").toLatin1().constData());
@ -937,6 +940,15 @@ void VcprojGenerator::initProject()
vcProject.SccProjectName = project->first("SCCPROJECTNAME").toQString();
vcProject.SccLocalPath = project->first("SCCLOCALPATH").toQString();
vcProject.flat_files = project->isActiveConfig("flat");
// Set up the full target path for target conflict checking.
const QChar slash = QLatin1Char('/');
QString destdir = QDir::fromNativeSeparators(var("DESTDIR"));
if (!destdir.endsWith(slash))
destdir.append(slash);
project->values("DEST_TARGET") = ProStringList(destdir
+ project->first("TARGET")
+ project->first("TARGET_EXT"));
}
void VcprojGenerator::initConfiguration()

View File

@ -79,7 +79,7 @@ Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
ProStringList impexts = project->values("QMAKE_LIB_EXTENSIONS");
if (impexts.isEmpty())
impexts = project->values("QMAKE_EXTENSION_STATICLIB");
QList<QMakeLocalFileName> dirs;
QVector<QMakeLocalFileName> dirs;
int libidx = 0;
for (const ProString &dlib : project->values("QMAKE_DEFAULT_LIBDIRS"))
dirs.append(QMakeLocalFileName(dlib.toQString()));
@ -104,8 +104,7 @@ Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
QString lib = arg.toQString();
ProString verovr =
project->first(ProKey("QMAKE_" + lib.toUpper() + "_VERSION_OVERRIDE"));
for (QList<QMakeLocalFileName>::Iterator dir_it = dirs.begin();
dir_it != dirs.end(); ++dir_it) {
for (auto dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
QString cand = (*dir_it).real() + Option::dir_sep + lib;
if (linkPrl && processPrlFile(cand, true)) {
(*it) = cand;
@ -128,8 +127,7 @@ Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
if (processPrlFile(lib, false))
(*it) = lib;
} else {
for (QList<QMakeLocalFileName>::Iterator dir_it = dirs.begin();
dir_it != dirs.end(); ++dir_it) {
for (auto dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
QString cand = (*dir_it).real() + Option::dir_sep + lib;
if (processPrlFile(cand, false)) {
(*it) = cand;
@ -669,6 +667,9 @@ void Win32MakefileGenerator::writeRcFilePart(QTextStream &t)
incPathStr += escapeFilePath(path);
}
addSourceFile(rc_file, QMakeSourceFileInfo::SEEK_DEPS);
const QStringList rcDeps = QStringList(rc_file) << dependencies(rc_file);
// The resource tool may use defines. This might be the same defines passed in as the
// compiler, since you may use these defines in the .rc file itself.
// As the escape syntax for the command line defines for RC is different from that for CL,
@ -680,7 +681,8 @@ void Win32MakefileGenerator::writeRcFilePart(QTextStream &t)
// Also, we need to add the _DEBUG define manually since the compiler defines this symbol
// by itself, and we use it in the automatically created rc file when VERSION is defined
// in the .pro file.
t << escapeDependencyPath(res_file) << ": " << escapeDependencyPath(rc_file) << "\n\t"
t << escapeDependencyPath(res_file) << ": "
<< escapeDependencyPaths(rcDeps).join(' ') << "\n\t"
<< var("QMAKE_RC") << (project->isActiveConfig("debug") ? " -D_DEBUG" : "")
<< defines << incPathStr << " -fo " << escapeFilePath(res_file)
<< ' ' << escapeFilePath(rc_file);
@ -815,4 +817,9 @@ QString Win32MakefileGenerator::getManifestFileForRcFile() const
return QString();
}
ProKey Win32MakefileGenerator::fullTargetVariable() const
{
return "DEST_TARGET";
}
QT_END_NAMESPACE

View File

@ -64,6 +64,9 @@ protected:
void processRcFileVar();
static QString cQuoted(const QString &str);
virtual QString getManifestFileForRcFile() const;
public:
ProKey fullTargetVariable() const override;
};
QT_END_NAMESPACE

Some files were not shown because too many files have changed in this diff Show More