| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | /****************************************************************************
 | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2016-01-15 14:57:40 +01:00
										 |  |  | ** Copyright (C) 2016 The Qt Company Ltd. | 
					
						
							|  |  |  | ** Contact: https://www.qt.io/licensing/
 | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | ** | 
					
						
							|  |  |  | ** This file is part of Qt Creator. | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** 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 | 
					
						
							| 
									
										
										
										
											2016-01-15 14:57:40 +01:00
										 |  |  | ** 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.
 | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2016-01-15 14:57:40 +01:00
										 |  |  | ** GNU General Public License Usage | 
					
						
							|  |  |  | ** Alternatively, this file may be used under the terms of the GNU | 
					
						
							|  |  |  | ** General Public License version 3 as published by the Free Software | 
					
						
							|  |  |  | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT | 
					
						
							|  |  |  | ** 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-3.0.html.
 | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | ** | 
					
						
							|  |  |  | ****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "projectpartbuilder.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  | #include "projectinfo.h"
 | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 17:34:02 +02:00
										 |  |  | #include <projectexplorer/abi.h>
 | 
					
						
							| 
									
										
										
										
											2016-01-18 11:56:54 +01:00
										 |  |  | #include <projectexplorer/headerpath.h>
 | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | #include <projectexplorer/kitinformation.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/projectexplorerconstants.h>
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  | #include <projectexplorer/project.h>
 | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | #include <projectexplorer/target.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace CppTools { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  | class ToolChainImpl : public ToolChainInterface | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  | public: | 
					
						
							|  |  |  |     ToolChainImpl(ProjectExplorer::ToolChain &toolChain, | 
					
						
							|  |  |  |                   const ProjectExplorer::Kit *kit, | 
					
						
							|  |  |  |                   const QStringList &commandLineFlags) | 
					
						
							|  |  |  |         : m_toolChain(toolChain) | 
					
						
							|  |  |  |         , m_kit(kit) | 
					
						
							|  |  |  |         , m_commandLineFlags(commandLineFlags) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  |     Core::Id type() const override | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return m_toolChain.typeId(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  |     bool isMsvc2015Toolchain() const override | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return m_toolChain.targetAbi().osFlavor() == ProjectExplorer::Abi::WindowsMsvc2015Flavor; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  |     unsigned wordWidth() const override | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return m_toolChain.targetAbi().wordWidth(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  |     QString targetTriple() const override | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (type() == ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID) | 
					
						
							|  |  |  |             return QLatin1String("i686-pc-windows-msvc"); | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  |         return m_toolChain.originalTargetTriple(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  |     QByteArray predefinedMacros() const override | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return m_toolChain.predefinedMacros(m_commandLineFlags); | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  |     QList<ProjectExplorer::HeaderPath> systemHeaderPaths() const override | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return m_toolChain.systemHeaderPaths( | 
					
						
							|  |  |  |                     m_commandLineFlags, | 
					
						
							|  |  |  |                     ProjectExplorer::SysRootKitInformation::sysRoot(m_kit)); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  |     ProjectExplorer::WarningFlags warningFlags() const override | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return m_toolChain.warningFlags(m_commandLineFlags); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  |     ProjectExplorer::ToolChain::CompilerFlags compilerFlags() const override | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return m_toolChain.compilerFlags(m_commandLineFlags); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  | private: | 
					
						
							|  |  |  |     ProjectExplorer::ToolChain &m_toolChain; | 
					
						
							|  |  |  |     const ProjectExplorer::Kit *m_kit = nullptr; | 
					
						
							|  |  |  |     const QStringList m_commandLineFlags; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  | class ProjectImpl : public ProjectInterface | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  | public: | 
					
						
							|  |  |  |     ProjectImpl(ProjectExplorer::Project &project) | 
					
						
							|  |  |  |         : m_project(project) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (ProjectExplorer::Target *activeTarget = m_project.activeTarget()) | 
					
						
							|  |  |  |             m_kit = activeTarget->kit(); | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  |     QString displayName() const override | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return m_project.displayName(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-01-18 11:56:54 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  |     QString projectFilePath() const override | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return m_project.projectFilePath().toString(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-01-18 11:56:54 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  |     ToolChainInterfacePtr toolChain(ProjectExplorer::ToolChain::Language language, | 
					
						
							|  |  |  |                                     const QStringList &commandLineFlags) const override | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         using namespace ProjectExplorer; | 
					
						
							| 
									
										
										
										
											2016-04-08 14:19:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  |         if (ProjectExplorer::ToolChain *t = ToolChainKitInformation::toolChain(m_kit, language)) | 
					
						
							|  |  |  |             return ToolChainInterfacePtr(new ToolChainImpl(*t, m_kit, commandLineFlags)); | 
					
						
							| 
									
										
										
										
											2016-04-08 14:19:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  |         return ToolChainInterfacePtr(); | 
					
						
							| 
									
										
										
										
											2016-04-08 14:19:23 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  | private: | 
					
						
							|  |  |  |     ProjectExplorer::Project &m_project; | 
					
						
							|  |  |  |     ProjectExplorer::Kit *m_kit = nullptr; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2016-04-08 14:19:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  | ProjectPartBuilder::ProjectPartBuilder(ProjectInfo &projectInfo) | 
					
						
							|  |  |  |     : BaseProjectPartBuilder(new ProjectImpl(*projectInfo.project().data()), projectInfo) | 
					
						
							| 
									
										
										
										
											2016-01-18 11:56:54 +01:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  | void ProjectPartBuilder::evaluateToolChain(ProjectPart &projectPart, | 
					
						
							|  |  |  |                                            ProjectExplorer::ToolChain &toolChain, | 
					
						
							|  |  |  |                                            const ProjectExplorer::Kit *kit, | 
					
						
							|  |  |  |                                            const QStringList commandLineFlags) | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-12-05 15:24:09 +01:00
										 |  |  |     const ToolChainImpl toolChainImpl(toolChain, kit, commandLineFlags); | 
					
						
							|  |  |  |     BaseProjectPartBuilder::evaluateToolChain(projectPart, toolChainImpl); | 
					
						
							| 
									
										
										
										
											2016-01-11 21:08:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // namespace CppTools
 |