aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Costa <miguel.costa@qt.io>2022-10-19 15:04:13 +0200
committerMiguel Costa <miguel.costa@qt.io>2022-11-07 11:11:02 +0000
commit80a0aa34d13ecba65ecbf1f6bb5de4ca91fceeab (patch)
tree4ceed77315999b63cb7f250476d090f895a80977
parent69cac4cc7fc712ed3cf4fdfb525690e865ac6a03 (diff)
Add support for ARM64
Qt versions targeting MSVC/ARM64 are now supported. Previously, an error would be generated when attempting to add an ARM64 build to the list of Qt versions. Fixes: QTVSADDINBUG-938 Change-Id: I977141eef1e39c65b4ef965c233019655d1b5776 Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
-rw-r--r--QtMSBuild/QtMsBuild/qt_vars.targets4
-rw-r--r--QtVsTools.Core/HelperFunctions.cs41
-rw-r--r--QtVsTools.Core/QMake.cs15
-rw-r--r--QtVsTools.Core/QtConfig.cs21
-rw-r--r--QtVsTools.Core/VersionInformation.cs16
-rw-r--r--QtVsTools.Package/Options/QtVersionsTable.cs2
-rw-r--r--QtVsTools.Wizards/ProjectWizard/ConfigPage.xaml.cs35
7 files changed, 100 insertions, 34 deletions
diff --git a/QtMSBuild/QtMsBuild/qt_vars.targets b/QtMSBuild/QtMsBuild/qt_vars.targets
index 9ea5205f..c0eda6cc 100644
--- a/QtMSBuild/QtMsBuild/qt_vars.targets
+++ b/QtMSBuild/QtMsBuild/qt_vars.targets
@@ -67,7 +67,9 @@
<!--// Check if qmake is in the tools path -->
<Error Condition="'$(QtToolsPath)' == ''" Text="There's no Qt version assigned to project $(MSBuildProjectFile) for configuration $(Configuration)/$(Platform).&#xA;Please set a Qt installation in 'Project|Properties|Configuration Properties|Qt Project Settings|Qt Installation'."/>
<Error
- Condition="'$(ApplicationType)' != 'Linux' AND !Exists('$(QtToolsPath)\qmake.exe')"
+ Condition="'$(ApplicationType)' != 'Linux'
+ AND !Exists('$(QtToolsPath)\qmake.exe')
+ AND !Exists('$(QtToolsPath)\qmake.bat')"
Text="qmake not found in $(QtToolsPath) when building project $(MSBuildProjectFile)"/>
<!--// Ensure C++ compiler in PATH -->
diff --git a/QtVsTools.Core/HelperFunctions.cs b/QtVsTools.Core/HelperFunctions.cs
index 1700818c..2dca52ae 100644
--- a/QtVsTools.Core/HelperFunctions.cs
+++ b/QtVsTools.Core/HelperFunctions.cs
@@ -1441,26 +1441,41 @@ namespace QtVsTools.Core
QtVersionManager.The().GetDefaultVersion());
}
- string vcPath = VCPath;
- if (vcPath == "")
+ if (string.IsNullOrEmpty(VCPath))
return false;
+ // Select vcvars script according to host and target platforms
bool osIs64Bit = System.Environment.Is64BitOperatingSystem;
- bool qtIs64Bit = VersionInfo.is64Bit();
-
string comspecPath = Environment.GetEnvironmentVariable("COMSPEC");
string vcVarsCmd = "";
- string vcVarsArg = "";
- if (osIs64Bit && qtIs64Bit)
- vcVarsCmd = Path.Combine(vcPath, @"Auxiliary\Build\vcvars64.bat");
- else if (osIs64Bit /* && !QtIs64Bit */)
- vcVarsCmd = Path.Combine(vcPath, @"Auxiliary\Build\vcvarsamd64_x86.bat");
- else if (/* !OsIs64Bit && */ qtIs64Bit)
- vcVarsCmd = Path.Combine(vcPath, @"Auxiliary\Build\vcvarsx86_amd64.bat");
- else /* !OsIs64Bit && !QtIs64Bit */
- vcVarsCmd = Path.Combine(vcPath, @"Auxiliary\Build\vcvars32.bat");
+ switch (VersionInfo.platform()) {
+ case Platform.x86:
+ vcVarsCmd = Path.Combine(VCPath, osIs64Bit
+ ? @"Auxiliary\Build\vcvarsamd64_x86.bat"
+ : @"Auxiliary\Build\vcvars32.bat");
+ break;
+ case Platform.x64:
+ vcVarsCmd = Path.Combine(VCPath, osIs64Bit
+ ? @"Auxiliary\Build\vcvars64.bat"
+ : @"Auxiliary\Build\vcvarsx86_amd64.bat");
+ break;
+ case Platform.arm64:
+ vcVarsCmd = Path.Combine(VCPath, osIs64Bit
+ ? @"Auxiliary\Build\vcvarsamd64_arm64.bat"
+ : @"Auxiliary\Build\vcvarsx86_arm64.bat");
+ if (!File.Exists(vcVarsCmd)) {
+ vcVarsCmd = Path.Combine(VCPath, osIs64Bit
+ ? @"Auxiliary\Build\vcvars64.bat"
+ : @"Auxiliary\Build\vcvarsx86_amd64.bat");
+ }
+ break;
+ }
Messages.Print($"vcvars: {vcVarsCmd}");
+ if (!File.Exists(vcVarsCmd)) {
+ Messages.Print($"vcvars: NOT FOUND");
+ return false;
+ }
// Run vcvars and print environment variables
StringBuilder stdOut = new StringBuilder();
diff --git a/QtVsTools.Core/QMake.cs b/QtVsTools.Core/QMake.cs
index d26a5da8..0bf0caef 100644
--- a/QtVsTools.Core/QMake.cs
+++ b/QtVsTools.Core/QMake.cs
@@ -65,6 +65,10 @@ namespace QtVsTools.Core
var qmakePath = Path.Combine(QtVersion.qtDir, "bin", "qmake.exe");
if (!File.Exists(qmakePath))
qmakePath = Path.Combine(QtVersion.qtDir, "qmake.exe");
+ if (!File.Exists(qmakePath))
+ qmakePath = Path.Combine(QtVersion.qtDir, "bin", "qmake.bat");
+ if (!File.Exists(qmakePath))
+ qmakePath = Path.Combine(QtVersion.qtDir, "qmake.bat");
return qmakePath;
}
}
@@ -198,15 +202,18 @@ namespace QtVsTools.Core
public static bool Exists(string path)
{
var possibleQMakePaths = new[] {
- // Path points to qmake.exe
+ // Path points to qmake.exe or qmake.bat
path,
- // Path points to folder containing qmake.exe
+ // Path points to folder containing qmake.exe or qmake.bat
Path.Combine(path, "qmake.exe"),
- // Path points to folder containing bin\qmake.exe
+ Path.Combine(path, "qmake.bat"),
+ // Path points to folder containing bin\qmake.exe or bin\qmake.bat
Path.Combine(path, "bin", "qmake.exe"),
+ Path.Combine(path, "bin", "qmake.bat"),
};
return possibleQMakePaths.Where(p => File.Exists(p)
- && Path.GetFileName(p).Equals("qmake.exe", StringComparison.OrdinalIgnoreCase))
+ && (Path.GetFileName(p).Equals("qmake.exe", StringComparison.OrdinalIgnoreCase)
+ || Path.GetFileName(p).Equals("qmake.bat", StringComparison.OrdinalIgnoreCase)))
.Any();
}
}
diff --git a/QtVsTools.Core/QtConfig.cs b/QtVsTools.Core/QtConfig.cs
index 93ca8252..5d272883 100644
--- a/QtVsTools.Core/QtConfig.cs
+++ b/QtVsTools.Core/QtConfig.cs
@@ -39,6 +39,13 @@ namespace QtVsTools.Core
Shared
}
+ public enum Platform
+ {
+ x86,
+ x64,
+ arm64
+ }
+
/// <summary>
/// A very simple reader for the qconfig.pri file.
/// </summary>
@@ -48,7 +55,7 @@ namespace QtVsTools.Core
public string LibInfix { get; }
- public bool Is64Bit { get; }
+ public Platform Platform { get; }
public string Namespace { get; }
@@ -108,7 +115,17 @@ namespace QtVsTools.Core
} else if (name == "QT_LIBINFIX") {
LibInfix = data;
} else if (name == "QT_ARCH") {
- Is64Bit = (data == "x86_64");
+ switch (data) {
+ case "x86_64":
+ Platform= Platform.x64;
+ break;
+ case "arm64":
+ Platform = Platform.arm64;
+ break;
+ default:
+ Platform = Platform.x86;
+ break;
+ }
} else if (name == "QT_NAMESPACE") {
Namespace = data;
} else if (name == "QT_VERSION") {
diff --git a/QtVsTools.Core/VersionInformation.cs b/QtVsTools.Core/VersionInformation.cs
index c9e3a191..a6a83cf2 100644
--- a/QtVsTools.Core/VersionInformation.cs
+++ b/QtVsTools.Core/VersionInformation.cs
@@ -241,7 +241,17 @@ namespace QtVsTools.Core
{
if (qmakeConf == null)
qmakeConf = new QMakeConf(this, qmakeQuery);
- vsPlatformName = (is64Bit()) ? @"x64" : @"Win32";
+ switch (platform()) {
+ case Platform.x86:
+ vsPlatformName = "Win32";
+ break;
+ case Platform.x64:
+ vsPlatformName = "x64";
+ break;
+ case Platform.arm64:
+ vsPlatformName = "ARM64";
+ break;
+ }
}
private string Locate_qglobal_h()
@@ -274,11 +284,11 @@ namespace QtVsTools.Core
throw new QtVSException("qglobal.h not found");
}
- public bool is64Bit()
+ public Platform platform()
{
if (qtConfig == null)
qtConfig = new QtConfig(qtDir);
- return qtConfig.Is64Bit;
+ return qtConfig.Platform;
}
public bool isWinRT()
diff --git a/QtVsTools.Package/Options/QtVersionsTable.cs b/QtVsTools.Package/Options/QtVersionsTable.cs
index da1c8fbc..38f3595d 100644
--- a/QtVsTools.Package/Options/QtVersionsTable.cs
+++ b/QtVsTools.Package/Options/QtVersionsTable.cs
@@ -498,7 +498,7 @@ namespace QtVsTools.Options
AddExtension = false,
CheckFileExists = true,
CheckPathExists = true,
- Filter = "qmake Executable|qmake.exe",
+ Filter = "qmake|qmake.exe;qmake.bat",
Title = "Qt VS Tools - Select qmake.exe"
};
if (openFileDialog.ShowDialog() == true) {
diff --git a/QtVsTools.Wizards/ProjectWizard/ConfigPage.xaml.cs b/QtVsTools.Wizards/ProjectWizard/ConfigPage.xaml.cs
index 511aa3fd..f3984f0c 100644
--- a/QtVsTools.Wizards/ProjectWizard/ConfigPage.xaml.cs
+++ b/QtVsTools.Wizards/ProjectWizard/ConfigPage.xaml.cs
@@ -184,9 +184,14 @@ namespace QtVsTools.Wizards.ProjectWizard
Target = defaultQtVersionInfo.isWinRT()
? ProjectTargets.WindowsStore.Cast<string>()
: ProjectTargets.Windows.Cast<string>(),
- Platform = defaultQtVersionInfo.is64Bit()
- ? ProjectPlatforms.X64.Cast<string>()
- : ProjectPlatforms.Win32.Cast<string>(),
+ Platform
+ = defaultQtVersionInfo.platform() == Platform.x86
+ ? ProjectPlatforms.Win32.Cast<string>()
+ : defaultQtVersionInfo.platform() == Platform.x64
+ ? ProjectPlatforms.X64.Cast<string>()
+ : defaultQtVersionInfo.platform() == Platform.arm64
+ ? ProjectPlatforms.ARM64.Cast<string>()
+ : string.Empty,
Modules = qtModules.ToDictionary((Module m) => m.Name),
},
new Config {
@@ -197,9 +202,14 @@ namespace QtVsTools.Wizards.ProjectWizard
Target = defaultQtVersionInfo.isWinRT()
? ProjectTargets.WindowsStore.Cast<string>()
: ProjectTargets.Windows.Cast<string>(),
- Platform = defaultQtVersionInfo.is64Bit()
- ? ProjectPlatforms.X64.Cast<string>()
- : ProjectPlatforms.Win32.Cast<string>(),
+ Platform
+ = defaultQtVersionInfo.platform() == Platform.x86
+ ? ProjectPlatforms.Win32.Cast<string>()
+ : defaultQtVersionInfo.platform() == Platform.x64
+ ? ProjectPlatforms.X64.Cast<string>()
+ : defaultQtVersionInfo.platform() == Platform.arm64
+ ? ProjectPlatforms.ARM64.Cast<string>()
+ : string.Empty,
Modules = qtModules.ToDictionary((Module m) => m.Name),
}
};
@@ -307,7 +317,7 @@ namespace QtVsTools.Wizards.ProjectWizard
} else if (comboBoxQtVersion.Text == QT_VERSION_BROWSE) {
var openFileDialog = new OpenFileDialog
{
- Filter = "qmake (qmake.exe)|qmake.exe"
+ Filter = "qmake|qmake.exe;qmake.bat"
};
if (openFileDialog.ShowDialog() == true) {
IEnumerable<string> binPath = Path.GetDirectoryName(openFileDialog.FileName)
@@ -341,9 +351,14 @@ namespace QtVsTools.Wizards.ProjectWizard
config.Target = config.QtVersion.isWinRT()
? ProjectTargets.WindowsStore.Cast<string>()
: ProjectTargets.Windows.Cast<string>();
- config.Platform = config.QtVersion.is64Bit()
- ? ProjectPlatforms.X64.Cast<string>()
- : ProjectPlatforms.Win32.Cast<string>();
+ config.Platform
+ = config.QtVersion.platform() == Platform.x86
+ ? ProjectPlatforms.Win32.Cast<string>()
+ : config.QtVersion.platform() == Platform.x64
+ ? ProjectPlatforms.X64.Cast<string>()
+ : config.QtVersion.platform() == Platform.arm64
+ ? ProjectPlatforms.ARM64.Cast<string>()
+ : string.Empty;
config.Modules =
QtModules.Instance.GetAvailableModules(config.QtVersion.qtMajor)
.Where((QtModule mi) => mi.Selectable)