Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
7e05d103
Unverified
Commit
7e05d103
authored
Nov 11, 2021
by
stuartmorgan
Committed by
GitHub
Nov 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for Visual Studio 2022 (#93426)
parent
9cc47c2b
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
125 additions
and
36 deletions
+125
-36
build_windows.dart
packages/flutter_tools/lib/src/windows/build_windows.dart
+23
-11
visual_studio.dart
packages/flutter_tools/lib/src/windows/visual_studio.dart
+13
-0
build_windows_test.dart
...ools/test/commands.shard/hermetic/build_windows_test.dart
+57
-25
visual_studio_test.dart
..._tools/test/general.shard/windows/visual_studio_test.dart
+32
-0
No files found.
packages/flutter_tools/lib/src/windows/build_windows.dart
View file @
7e05d103
...
...
@@ -20,11 +20,6 @@ import '../migrations/cmake_custom_command_migration.dart';
import
'install_manifest.dart'
;
import
'visual_studio.dart'
;
// From https://cmake.org/cmake/help/v3.14/manual/cmake-generators.7.html#visual-studio-generators
// This may need to become a getter on VisualStudio in the future to support
// future major versions of Visual Studio.
const
String
_cmakeVisualStudioGeneratorIdentifier
=
'Visual Studio 16 2019'
;
/// Update the string when non-backwards compatible changes are made to the UWP template.
const
int
kCurrentUwpTemplateVersion
=
0
;
...
...
@@ -61,7 +56,8 @@ Future<void> buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, {
processManager:
globals
.
processManager
,
);
final
String
?
cmakePath
=
visualStudio
.
cmakePath
;
if
(
cmakePath
==
null
)
{
final
String
?
cmakeGenerator
=
visualStudio
.
cmakeGenerator
;
if
(
cmakePath
==
null
||
cmakeGenerator
==
null
)
{
throwToolExit
(
'Unable to find suitable Visual Studio toolchain. '
'Please run `flutter doctor` for more details.'
);
}
...
...
@@ -72,7 +68,12 @@ Future<void> buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, {
'Building Windows application...'
,
);
try
{
await
_runCmakeGeneration
(
cmakePath
,
buildDirectory
,
windowsProject
.
cmakeFile
.
parent
);
await
_runCmakeGeneration
(
cmakePath:
cmakePath
,
generator:
cmakeGenerator
,
buildDir:
buildDirectory
,
sourceDir:
windowsProject
.
cmakeFile
.
parent
,
);
await
_runBuild
(
cmakePath
,
buildDirectory
,
buildModeName
);
}
finally
{
status
.
cancel
();
...
...
@@ -152,7 +153,8 @@ Future<void> buildWindowsUwp(WindowsUwpProject windowsProject, BuildInfo buildIn
processManager:
globals
.
processManager
,
);
final
String
?
cmakePath
=
visualStudio
.
cmakePath
;
if
(
cmakePath
==
null
)
{
final
String
?
cmakeGenerator
=
visualStudio
.
cmakeGenerator
;
if
(
cmakePath
==
null
||
cmakeGenerator
==
null
)
{
throwToolExit
(
'Unable to find suitable Visual Studio toolchain. '
'Please run `flutter doctor` for more details.'
);
}
...
...
@@ -165,7 +167,12 @@ Future<void> buildWindowsUwp(WindowsUwpProject windowsProject, BuildInfo buildIn
// The Cmake re-entrant build does not work for UWP, so the flutter build is
// run in advance.
await
_runFlutterBuild
(
buildDirectory
,
buildInfo
,
target
);
await
_runCmakeGeneration
(
cmakePath
,
buildDirectory
,
windowsProject
.
cmakeFile
.
parent
);
await
_runCmakeGeneration
(
cmakePath:
cmakePath
,
generator:
cmakeGenerator
,
buildDir:
buildDirectory
,
sourceDir:
windowsProject
.
cmakeFile
.
parent
,
);
await
_runBuild
(
cmakePath
,
buildDirectory
,
buildModeName
,
install:
false
);
}
finally
{
status
.
cancel
();
...
...
@@ -232,7 +239,12 @@ Future<void> _runFlutterBuild(Directory buildDirectory, BuildInfo buildInfo, Str
}
}
Future
<
void
>
_runCmakeGeneration
(
String
cmakePath
,
Directory
buildDir
,
Directory
sourceDir
)
async
{
Future
<
void
>
_runCmakeGeneration
({
required
String
cmakePath
,
required
String
generator
,
required
Directory
buildDir
,
required
Directory
sourceDir
,
})
async
{
final
Stopwatch
sw
=
Stopwatch
()..
start
();
await
buildDir
.
create
(
recursive:
true
);
...
...
@@ -246,7 +258,7 @@ Future<void> _runCmakeGeneration(String cmakePath, Directory buildDir, Directory
'-B'
,
buildDir
.
path
,
'-G'
,
_cmakeVisualStudioGeneratorIdentifie
r
,
generato
r
,
],
trace:
true
,
);
...
...
packages/flutter_tools/lib/src/windows/visual_studio.dart
View file @
7e05d103
...
...
@@ -167,6 +167,19 @@ class VisualStudio {
]);
}
/// The generator string to pass to CMake to select this Visual Studio
/// version.
String
?
get
cmakeGenerator
{
// From https://cmake.org/cmake/help/v3.22/manual/cmake-generators.7.html#visual-studio-generators
switch
(
_majorVersion
)
{
case
17
:
return
'Visual Studio 17 2022'
;
case
16
:
default
:
return
'Visual Studio 16 2019'
;
}
}
/// The major version of the Visual Studio install, as an integer.
int
?
get
_majorVersion
=>
fullVersion
!=
null
?
int
.
tryParse
(
fullVersion
!.
split
(
'.'
)[
0
])
:
null
;
...
...
packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart
View file @
7e05d103
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/windows/visual_studio_test.dart
View file @
7e05d103
...
...
@@ -39,6 +39,20 @@ const Map<String, dynamic> _defaultResponse = <String, dynamic>{
},
};
// A minimum version of a response where a VS 2022 installation was found.
const
Map
<
String
,
dynamic
>
_vs2022Response
=
<
String
,
dynamic
>{
'installationPath'
:
visualStudioPath
,
'displayName'
:
'Visual Studio Community 2022'
,
'installationVersion'
:
'17.0.31903.59'
,
'isRebootRequired'
:
false
,
'isComplete'
:
true
,
'isLaunchable'
:
true
,
'isPrerelease'
:
false
,
'catalog'
:
<
String
,
dynamic
>{
'productDisplayVersion'
:
'17.0.0'
,
},
};
// A minimum version of a response where a Build Tools installation was found.
const
Map
<
String
,
dynamic
>
_defaultBuildToolsResponse
=
<
String
,
dynamic
>{
'installationPath'
:
visualStudioPath
,
...
...
@@ -732,6 +746,7 @@ void main() {
expect
(
visualStudio
.
isAtLeastMinimumVersion
,
true
);
expect
(
visualStudio
.
hasNecessaryComponents
,
true
);
expect
(
visualStudio
.
cmakePath
,
equals
(
cmakePath
));
expect
(
visualStudio
.
cmakeGenerator
,
equals
(
'Visual Studio 16 2019'
));
});
testWithoutContext
(
'Everything returns good values when Build Tools is present with all components'
,
()
{
...
...
@@ -755,6 +770,23 @@ void main() {
expect
(
visualStudio
.
cmakePath
,
equals
(
cmakePath
));
});
testWithoutContext
(
'properties return the right value for Visual Studio 2022'
,
()
{
final
VisualStudioFixture
fixture
=
setUpVisualStudio
();
final
VisualStudio
visualStudio
=
fixture
.
visualStudio
;
setMockCompatibleVisualStudioInstallation
(
_vs2022Response
,
fixture
.
fileSystem
,
fixture
.
processManager
,
);
expect
(
visualStudio
.
isInstalled
,
true
);
expect
(
visualStudio
.
isAtLeastMinimumVersion
,
true
);
expect
(
visualStudio
.
hasNecessaryComponents
,
true
);
expect
(
visualStudio
.
cmakePath
,
equals
(
cmakePath
));
expect
(
visualStudio
.
cmakeGenerator
,
equals
(
'Visual Studio 17 2022'
));
});
testWithoutContext
(
'Metadata is for compatible version when latest is missing components'
,
()
{
final
VisualStudioFixture
fixture
=
setUpVisualStudio
();
final
VisualStudio
visualStudio
=
fixture
.
visualStudio
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment