1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the qmake application of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 
29 #ifndef MSVC_VCPROJ_H
30 #define MSVC_VCPROJ_H
31 
32 #include "winmakefile.h"
33 #include "msvc_objectmodel.h"
34 
35 QT_BEGIN_NAMESPACE
36 
37 enum Target {
38     Application,
39     SharedLib,
40     StaticLib
41 };
42 
43 class QUuid;
44 struct VcsolutionDepend;
45 class VcprojGenerator : public Win32MakefileGenerator
46 {
47     bool is64Bit;
48     bool writeVcprojParts(QTextStream &);
49 
50     bool writeMakefile(QTextStream &) override;
51     bool writeProjectMakefile() override;
52 
53     void init() override;
54 
55 public:
56     VcprojGenerator();
57     ~VcprojGenerator();
58 
59     QString defaultMakefile() const;
60     QString precompH, precompHFilename, precompSource,
61             precompObj, precompPch;
62     bool autogenPrecompSource;
63     static bool hasBuiltinCompiler(const QString &file);
64 
65     QHash<QString, QStringList> extraCompilerSources;
66     QHash<QString, QString> extraCompilerOutputs;
67     const QString customBuildToolFilterFileSuffix;
68     bool usePCH;
69     bool pchIsCFile = false;
70     VCProjectWriter *projectWriter;
71 
72     using Win32MakefileGenerator::callExtraCompilerDependCommand;
73 
74 protected:
75     virtual VCProjectWriter *createProjectWriter();
doDepends()76     bool doDepends() const override { return false; } // Never necessary
77     using Win32MakefileGenerator::replaceExtraCompilerVariables;
78     QString replaceExtraCompilerVariables(const QString &, const QStringList &, const QStringList &, ReplaceFor) override;
79     QString extraCompilerName(const ProString &extraCompiler, const QStringList &inputs,
80                               const QStringList &outputs);
supportsMetaBuild()81     bool supportsMetaBuild() override { return true; }
supportsMergedBuilds()82     bool supportsMergedBuilds() override { return true; }
83     bool mergeBuildProject(MakefileGenerator *other) override;
84 
85     bool openOutput(QFile &file, const QString &build) const override;
86 
87     virtual void initProject();
88     void initConfiguration();
89     void initCompilerTool();
90     void initLinkerTool();
91     void initLibrarianTool();
92     void initManifestTool();
93     void initResourceTool();
94     void initIDLTool();
95     void initCustomBuildTool();
96     void initPreBuildEventTools();
97     void initPostBuildEventTools();
98     void initDeploymentTool();
99     void initWinDeployQtTool();
100     void initPreLinkEventTools();
101     void initRootFiles();
102     void initSourceFiles();
103     void initHeaderFiles();
104     void initGeneratedFiles();
105     void initTranslationFiles();
106     void initFormFiles();
107     void initResourceFiles();
108     void initDeploymentFiles();
109     void initDistributionFiles();
110     void initLexYaccFiles();
111     void initExtraCompilerOutputs();
112 
113     void writeSubDirs(QTextStream &t); // Called from VCXProj backend
114     QUuid getProjectUUID(const QString &filename=QString()); // Called from VCXProj backend
115 
116     Target projectTarget;
117 
118     // Used for single project
119     VCProjectSingleConfig vcProject;
120 
121     // Holds all configurations for glue (merged) project
122     QList<VcprojGenerator*> mergedProjects;
123 
124 private:
125     ProStringList collectDependencies(QMakeProject *proj, QHash<QString, QString> &projLookup,
126                                       QHash<QString, QString> &projGuids,
127                                       QHash<VcsolutionDepend *, QStringList> &extraSubdirs,
128                                       QHash<QString, VcsolutionDepend*> &solution_depends,
129                                       QList<VcsolutionDepend*> &solution_cleanup,
130                                       QTextStream &t,
131                                       QHash<QString, ProStringList> &subdirProjectLookup,
132                                       const ProStringList &allDependencies = ProStringList());
133     QUuid increaseUUID(const QUuid &id);
134     QString retrievePlatformToolSet() const;
135     bool isStandardSuffix(const QString &suffix) const;
136     ProString firstInputFileName(const ProString &extraCompilerName) const;
137     QString firstExpandedOutputFileName(const ProString &extraCompilerName);
138     void createCustomBuildToolFakeFile(const QString &cbtFilePath, const QString &realOutFilePath);
139     bool otherFiltersContain(const QString &fileName) const;
140     friend class VCFilter;
141 };
142 
defaultMakefile()143 inline QString VcprojGenerator::defaultMakefile() const
144 {
145     return project->first("TARGET") + project->first("VCPROJ_EXTENSION");
146 }
147 
148 QT_END_NAMESPACE
149 
150 #endif // MSVC_VCPROJ_H
151