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
c5fdb82d
Unverified
Commit
c5fdb82d
authored
Apr 09, 2021
by
Jonah Williams
Committed by
GitHub
Apr 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] treat win32 plugins as uwp plugins (#80131)
parent
f09eb8af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
120 additions
and
38 deletions
+120
-38
plugins.dart
packages/flutter_tools/lib/src/plugins.dart
+46
-38
plugins_test.dart
...lutter_tools/test/general.shard/windows/plugins_test.dart
+74
-0
No files found.
packages/flutter_tools/lib/src/plugins.dart
View file @
c5fdb82d
...
@@ -15,6 +15,7 @@ import 'base/error_handling_io.dart';
...
@@ -15,6 +15,7 @@ import 'base/error_handling_io.dart';
import
'base/file_system.dart'
;
import
'base/file_system.dart'
;
import
'base/os.dart'
;
import
'base/os.dart'
;
import
'base/platform.dart'
;
import
'base/platform.dart'
;
import
'base/template.dart'
;
import
'base/version.dart'
;
import
'base/version.dart'
;
import
'convert.dart'
;
import
'convert.dart'
;
import
'dart/package_map.dart'
;
import
'dart/package_map.dart'
;
...
@@ -23,10 +24,9 @@ import 'globals.dart' as globals;
...
@@ -23,10 +24,9 @@ import 'globals.dart' as globals;
import
'platform_plugins.dart'
;
import
'platform_plugins.dart'
;
import
'project.dart'
;
import
'project.dart'
;
void
_renderTemplateToFile
(
String
template
,
dynamic
context
,
String
filePath
)
{
void
_renderTemplateToFile
(
String
template
,
dynamic
context
,
File
file
,
TemplateRenderer
templateRenderer
)
{
final
String
renderedTemplate
=
globals
.
templateRenderer
final
String
renderedTemplate
=
templateRenderer
.
renderString
(
template
,
context
,
htmlEscapeValues:
false
);
.
renderString
(
template
,
context
,
htmlEscapeValues:
false
);
final
File
file
=
globals
.
fs
.
file
(
filePath
);
file
.
createSync
(
recursive:
true
);
file
.
createSync
(
recursive:
true
);
file
.
writeAsStringSync
(
renderedTemplate
);
file
.
writeAsStringSync
(
renderedTemplate
);
}
}
...
@@ -690,7 +690,8 @@ Future<void> _writeAndroidPluginRegistrant(FlutterProject project, List<Plugin>
...
@@ -690,7 +690,8 @@ Future<void> _writeAndroidPluginRegistrant(FlutterProject project, List<Plugin>
_renderTemplateToFile
(
_renderTemplateToFile
(
templateContent
,
templateContent
,
templateContext
,
templateContext
,
registryPath
,
globals
.
fs
.
file
(
registryPath
),
globals
.
templateRenderer
,
);
);
}
}
...
@@ -910,22 +911,25 @@ Future<void> _writeIOSPluginRegistrant(FlutterProject project, List<Plugin> plug
...
@@ -910,22 +911,25 @@ Future<void> _writeIOSPluginRegistrant(FlutterProject project, List<Plugin> plug
'
plugins
': iosPlugins,
'
plugins
': iosPlugins,
};
};
if (project.isModule) {
if (project.isModule) {
final
String registryDirectory = project.ios.pluginRegistrantHost.path
;
final
Directory registryDirectory = project.ios.pluginRegistrantHost
;
_renderTemplateToFile(
_renderTemplateToFile(
_pluginRegistrantPodspecTemplate,
_pluginRegistrantPodspecTemplate,
context,
context,
globals.fs.path.join(registryDirectory, '
FlutterPluginRegistrant
.
podspec
'),
registryDirectory.childFile('
FlutterPluginRegistrant
.
podspec
'),
globals.templateRenderer,
);
);
}
}
_renderTemplateToFile(
_renderTemplateToFile(
_objcPluginRegistryHeaderTemplate,
_objcPluginRegistryHeaderTemplate,
context,
context,
project.ios.pluginRegistrantHeader.path,
project.ios.pluginRegistrantHeader,
globals.templateRenderer,
);
);
_renderTemplateToFile(
_renderTemplateToFile(
_objcPluginRegistryImplementationTemplate,
_objcPluginRegistryImplementationTemplate,
context,
context,
project.ios.pluginRegistrantImplementation.path,
project.ios.pluginRegistrantImplementation,
globals.templateRenderer,
);
);
}
}
...
@@ -936,10 +940,11 @@ Future<void> _writeIOSPluginRegistrant(FlutterProject project, List<Plugin> plug
...
@@ -936,10 +940,11 @@ Future<void> _writeIOSPluginRegistrant(FlutterProject project, List<Plugin> plug
/// designed to be included by the main CMakeLists.txt, so it relative to
/// designed to be included by the main CMakeLists.txt, so it relative to
/// that file, rather than the generated file.
/// that file, rather than the generated file.
String
_cmakeRelativePluginSymlinkDirectoryPath
(
CmakeBasedProject
project
)
{
String
_cmakeRelativePluginSymlinkDirectoryPath
(
CmakeBasedProject
project
)
{
final
FileSystem
fileSystem
=
project
.
pluginSymlinkDirectory
.
fileSystem
;
final
String
makefileDirPath
=
project
.
cmakeFile
.
parent
.
absolute
.
path
;
final
String
makefileDirPath
=
project
.
cmakeFile
.
parent
.
absolute
.
path
;
// CMake always uses posix-style path separators, regardless of the platform.
// CMake always uses posix-style path separators, regardless of the platform.
final
path
.
Context
cmakePathContext
=
path
.
Context
(
style:
path
.
Style
.
posix
);
final
path
.
Context
cmakePathContext
=
path
.
Context
(
style:
path
.
Style
.
posix
);
final
List
<
String
>
relativePathComponents
=
globals
.
fs
.
path
.
split
(
globals
.
fs
.
path
.
relative
(
final
List
<
String
>
relativePathComponents
=
fileSystem
.
path
.
split
(
fileSystem
.
path
.
relative
(
project
.
pluginSymlinkDirectory
.
absolute
.
path
,
project
.
pluginSymlinkDirectory
.
absolute
.
path
,
from:
makefileDirPath
,
from:
makefileDirPath
,
));
));
...
@@ -955,28 +960,30 @@ Future<void> _writeLinuxPluginFiles(FlutterProject project, List<Plugin> plugins
...
@@ -955,28 +960,30 @@ Future<void> _writeLinuxPluginFiles(FlutterProject project, List<Plugin> plugins
'pluginsDir'
:
_cmakeRelativePluginSymlinkDirectoryPath
(
project
.
linux
),
'pluginsDir'
:
_cmakeRelativePluginSymlinkDirectoryPath
(
project
.
linux
),
};
};
await
_writeLinuxPluginRegistrant
(
project
.
linux
.
managedDirectory
,
context
);
await
_writeLinuxPluginRegistrant
(
project
.
linux
.
managedDirectory
,
context
);
await
_writePluginCmakefile
(
project
.
linux
.
generatedPluginCmakeFile
,
context
);
await
_writePluginCmakefile
(
project
.
linux
.
generatedPluginCmakeFile
,
context
,
globals
.
templateRenderer
);
}
}
Future
<
void
>
_writeLinuxPluginRegistrant
(
Directory
destination
,
Map
<
String
,
dynamic
>
templateContext
)
async
{
Future
<
void
>
_writeLinuxPluginRegistrant
(
Directory
destination
,
Map
<
String
,
dynamic
>
templateContext
)
async
{
final
String
registryDirectory
=
destination
.
path
;
_renderTemplateToFile
(
_renderTemplateToFile
(
_linuxPluginRegistryHeaderTemplate
,
_linuxPluginRegistryHeaderTemplate
,
templateContext
,
templateContext
,
globals
.
fs
.
path
.
join
(
registryDirectory
,
'generated_plugin_registrant.h'
),
destination
.
childFile
(
'generated_plugin_registrant.h'
),
globals
.
templateRenderer
,
);
);
_renderTemplateToFile
(
_renderTemplateToFile
(
_linuxPluginRegistryImplementationTemplate
,
_linuxPluginRegistryImplementationTemplate
,
templateContext
,
templateContext
,
globals
.
fs
.
path
.
join
(
registryDirectory
,
'generated_plugin_registrant.cc'
),
destination
.
childFile
(
'generated_plugin_registrant.cc'
),
globals
.
templateRenderer
,
);
);
}
}
Future
<
void
>
_writePluginCmakefile
(
File
destinationFile
,
Map
<
String
,
dynamic
>
templateContext
)
async
{
Future
<
void
>
_writePluginCmakefile
(
File
destinationFile
,
Map
<
String
,
dynamic
>
templateContext
,
TemplateRenderer
templateRenderer
)
async
{
_renderTemplateToFile
(
_renderTemplateToFile
(
_pluginCmakefileTemplate
,
_pluginCmakefileTemplate
,
templateContext
,
templateContext
,
destinationFile
.
path
,
destinationFile
,
templateRenderer
,
);
);
}
}
...
@@ -988,11 +995,11 @@ Future<void> _writeMacOSPluginRegistrant(FlutterProject project, List<Plugin> pl
...
@@ -988,11 +995,11 @@ Future<void> _writeMacOSPluginRegistrant(FlutterProject project, List<Plugin> pl
'framework'
:
'FlutterMacOS'
,
'framework'
:
'FlutterMacOS'
,
'plugins'
:
macosPlugins
,
'plugins'
:
macosPlugins
,
};
};
final
String
registryDirectory
=
project
.
macos
.
managedDirectory
.
path
;
_renderTemplateToFile
(
_renderTemplateToFile
(
_swiftPluginRegistryTemplate
,
_swiftPluginRegistryTemplate
,
context
,
context
,
globals
.
fs
.
path
.
join
(
registryDirectory
,
'GeneratedPluginRegistrant.swift'
),
project
.
macos
.
managedDirectory
.
childFile
(
'GeneratedPluginRegistrant.swift'
),
globals
.
templateRenderer
,
);
);
}
}
...
@@ -1012,7 +1019,8 @@ List<Plugin> _filterNativePlugins(List<Plugin> plugins, String platformKey) {
...
@@ -1012,7 +1019,8 @@ List<Plugin> _filterNativePlugins(List<Plugin> plugins, String platformKey) {
}).
toList
();
}).
toList
();
}
}
Future
<
void
>
_writeWindowsPluginFiles
(
FlutterProject
project
,
List
<
Plugin
>
plugins
)
async
{
@visibleForTesting
Future
<
void
>
writeWindowsPluginFiles
(
FlutterProject
project
,
List
<
Plugin
>
plugins
,
TemplateRenderer
templateRenderer
)
async
{
final
List
<
Plugin
>
nativePlugins
=
_filterNativePlugins
(
plugins
,
WindowsPlugin
.
kConfigKey
);
final
List
<
Plugin
>
nativePlugins
=
_filterNativePlugins
(
plugins
,
WindowsPlugin
.
kConfigKey
);
final
List
<
Map
<
String
,
dynamic
>>
windowsPlugins
=
_extractPlatformMaps
(
nativePlugins
,
WindowsPlugin
.
kConfigKey
);
final
List
<
Map
<
String
,
dynamic
>>
windowsPlugins
=
_extractPlatformMaps
(
nativePlugins
,
WindowsPlugin
.
kConfigKey
);
final
Map
<
String
,
dynamic
>
context
=
<
String
,
dynamic
>{
final
Map
<
String
,
dynamic
>
context
=
<
String
,
dynamic
>{
...
@@ -1020,36 +1028,37 @@ Future<void> _writeWindowsPluginFiles(FlutterProject project, List<Plugin> plugi
...
@@ -1020,36 +1028,37 @@ Future<void> _writeWindowsPluginFiles(FlutterProject project, List<Plugin> plugi
'plugins'
:
windowsPlugins
,
'plugins'
:
windowsPlugins
,
'pluginsDir'
:
_cmakeRelativePluginSymlinkDirectoryPath
(
project
.
windows
),
'pluginsDir'
:
_cmakeRelativePluginSymlinkDirectoryPath
(
project
.
windows
),
};
};
await
_writeCppPluginRegistrant
(
project
.
windows
.
managedDirectory
,
context
);
await
_writeCppPluginRegistrant
(
project
.
windows
.
managedDirectory
,
context
,
templateRenderer
);
await
_writePluginCmakefile
(
project
.
windows
.
generatedPluginCmakeFile
,
context
);
await
_writePluginCmakefile
(
project
.
windows
.
generatedPluginCmakeFile
,
context
,
templateRenderer
);
}
}
/// The tooling
does not currently support any UWP plugins.
/// The tooling
currently treats UWP and win32 as identical for the
///
///
purposes of tooling support and initial UWP bootstrap.
/// Always generates an empty file to satisfy the cmake template.
@visibleForTesting
Future
<
void
>
_writeWindowsUwpPluginFiles
(
FlutterProject
project
,
List
<
Plugin
>
plugins
)
async
{
Future
<
void
>
writeWindowsUwpPluginFiles
(
FlutterProject
project
,
List
<
Plugin
>
plugins
,
TemplateRenderer
templateRenderer
)
async
{
final
List
<
Plugin
>
nativePlugins
=
<
Plugin
>[]
;
final
List
<
Plugin
>
nativePlugins
=
_filterNativePlugins
(
plugins
,
WindowsPlugin
.
kConfigKey
)
;
final
List
<
Map
<
String
,
dynamic
>>
windowsPlugins
=
_extractPlatformMaps
(
nativePlugins
,
WindowsPlugin
.
kConfigKey
);
final
List
<
Map
<
String
,
dynamic
>>
windowsPlugins
=
_extractPlatformMaps
(
nativePlugins
,
WindowsPlugin
.
kConfigKey
);
final
Map
<
String
,
dynamic
>
context
=
<
String
,
dynamic
>{
final
Map
<
String
,
dynamic
>
context
=
<
String
,
dynamic
>{
'os'
:
'windows'
,
'os'
:
'windows'
,
'plugins'
:
windowsPlugins
,
'plugins'
:
windowsPlugins
,
'pluginsDir'
:
_cmakeRelativePluginSymlinkDirectoryPath
(
project
.
windowsUwp
),
'pluginsDir'
:
_cmakeRelativePluginSymlinkDirectoryPath
(
project
.
windowsUwp
),
};
};
await
_writeCppPluginRegistrant
(
project
.
windowsUwp
.
managedDirectory
,
context
);
await
_writeCppPluginRegistrant
(
project
.
windowsUwp
.
managedDirectory
,
context
,
templateRenderer
);
await
_writePluginCmakefile
(
project
.
windowsUwp
.
generatedPluginCmakeFile
,
context
);
await
_writePluginCmakefile
(
project
.
windowsUwp
.
generatedPluginCmakeFile
,
context
,
templateRenderer
);
}
}
Future
<
void
>
_writeCppPluginRegistrant
(
Directory
destination
,
Map
<
String
,
dynamic
>
templateContext
)
async
{
Future
<
void
>
_writeCppPluginRegistrant
(
Directory
destination
,
Map
<
String
,
dynamic
>
templateContext
,
TemplateRenderer
templateRenderer
)
async
{
final
String
registryDirectory
=
destination
.
path
;
_renderTemplateToFile
(
_renderTemplateToFile
(
_cppPluginRegistryHeaderTemplate
,
_cppPluginRegistryHeaderTemplate
,
templateContext
,
templateContext
,
globals
.
fs
.
path
.
join
(
registryDirectory
,
'generated_plugin_registrant.h'
),
destination
.
childFile
(
'generated_plugin_registrant.h'
),
templateRenderer
,
);
);
_renderTemplateToFile
(
_renderTemplateToFile
(
_cppPluginRegistryImplementationTemplate
,
_cppPluginRegistryImplementationTemplate
,
templateContext
,
templateContext
,
globals
.
fs
.
path
.
join
(
registryDirectory
,
'generated_plugin_registrant.cc'
),
destination
.
childFile
(
'generated_plugin_registrant.cc'
),
templateRenderer
,
);
);
}
}
...
@@ -1058,16 +1067,15 @@ Future<void> _writeWebPluginRegistrant(FlutterProject project, List<Plugin> plug
...
@@ -1058,16 +1067,15 @@ Future<void> _writeWebPluginRegistrant(FlutterProject project, List<Plugin> plug
final
Map
<
String
,
dynamic
>
context
=
<
String
,
dynamic
>{
final
Map
<
String
,
dynamic
>
context
=
<
String
,
dynamic
>{
'plugins'
:
webPlugins
,
'plugins'
:
webPlugins
,
};
};
final
String
registryDirectory
=
project
.
web
.
libDirectory
.
path
;
final
File
pluginFile
=
project
.
web
.
libDirectory
.
childFile
(
'generated_plugin_registrant.dart'
);
final
String
filePath
=
globals
.
fs
.
path
.
join
(
registryDirectory
,
'generated_plugin_registrant.dart'
);
if
(
webPlugins
.
isEmpty
)
{
if
(
webPlugins
.
isEmpty
)
{
final
File
file
=
globals
.
fs
.
file
(
filePath
);
return
ErrorHandlingFileSystem
.
deleteIfExists
(
pluginFile
);
return
ErrorHandlingFileSystem
.
deleteIfExists
(
file
);
}
else
{
}
else
{
_renderTemplateToFile
(
_renderTemplateToFile
(
_dartPluginRegistryTemplate
,
_dartPluginRegistryTemplate
,
context
,
context
,
filePath
,
pluginFile
,
globals
.
templateRenderer
,
);
);
}
}
}
}
...
@@ -1221,10 +1229,10 @@ Future<void> injectPlugins(
...
@@ -1221,10 +1229,10 @@ Future<void> injectPlugins(
await
_writeMacOSPluginRegistrant
(
project
,
plugins
);
await
_writeMacOSPluginRegistrant
(
project
,
plugins
);
}
}
if
(
windowsPlatform
)
{
if
(
windowsPlatform
)
{
await
_writeWindowsPluginFiles
(
project
,
plugins
);
await
writeWindowsPluginFiles
(
project
,
plugins
,
globals
.
templateRenderer
);
}
}
if
(
winUwpPlatform
)
{
if
(
winUwpPlatform
)
{
await
_writeWindowsUwpPluginFiles
(
project
,
plugins
);
await
writeWindowsUwpPluginFiles
(
project
,
plugins
,
globals
.
templateRenderer
);
}
}
if
(!
project
.
isModule
)
{
if
(!
project
.
isModule
)
{
final
List
<
XcodeBasedProject
>
darwinProjects
=
<
XcodeBasedProject
>[
final
List
<
XcodeBasedProject
>
darwinProjects
=
<
XcodeBasedProject
>[
...
...
packages/flutter_tools/test/general.shard/windows/plugins_test.dart
0 → 100644
View file @
c5fdb82d
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:file_testing/file_testing.dart'
;
import
'package:flutter_tools/src/base/template.dart'
;
import
'package:flutter_tools/src/isolated/mustache_template.dart'
;
import
'package:flutter_tools/src/platform_plugins.dart'
;
import
'package:flutter_tools/src/plugins.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'../../src/common.dart'
;
const
TemplateRenderer
renderer
=
MustacheTemplateRenderer
();
void
main
(
)
{
testWithoutContext
(
'injects Win32 plugins'
,
()
async
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
setUpProject
(
fileSystem
);
final
FlutterProject
flutterProject
=
FlutterProject
.
fromDirectoryTest
(
fileSystem
.
currentDirectory
);
await
writeWindowsPluginFiles
(
flutterProject
,
<
Plugin
>[
Plugin
(
name:
'test'
,
path:
'foo'
,
platforms:
const
<
String
,
PluginPlatform
>{
WindowsPlugin
.
kConfigKey
:
WindowsPlugin
(
name:
'test'
,
pluginClass:
'Foo'
)},
dependencies:
<
String
>[],
),
],
renderer
);
final
Directory
managed
=
flutterProject
.
windows
.
managedDirectory
;
expect
(
flutterProject
.
windows
.
generatedPluginCmakeFile
,
exists
);
expect
(
managed
.
childFile
(
'generated_plugin_registrant.h'
),
exists
);
expect
(
managed
.
childFile
(
'generated_plugin_registrant.cc'
).
readAsStringSync
(),
contains
(
'#include <test/foo.h>'
),
);
});
testWithoutContext
(
'UWP injects Win32 plugins'
,
()
async
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
setUpProject
(
fileSystem
);
final
FlutterProject
flutterProject
=
FlutterProject
.
fromDirectoryTest
(
fileSystem
.
currentDirectory
);
await
writeWindowsUwpPluginFiles
(
flutterProject
,
<
Plugin
>[
Plugin
(
name:
'test'
,
path:
'foo'
,
platforms:
const
<
String
,
PluginPlatform
>{
WindowsPlugin
.
kConfigKey
:
WindowsPlugin
(
name:
'test'
,
pluginClass:
'Foo'
)},
dependencies:
<
String
>[],
),
],
renderer
);
final
Directory
managed
=
flutterProject
.
windowsUwp
.
managedDirectory
;
expect
(
flutterProject
.
windowsUwp
.
generatedPluginCmakeFile
,
exists
);
expect
(
managed
.
childFile
(
'generated_plugin_registrant.h'
),
exists
);
expect
(
managed
.
childFile
(
'generated_plugin_registrant.cc'
).
readAsStringSync
(),
contains
(
'#include <test/foo.h>'
),
);
});
}
void
setUpProject
(
FileSystem
fileSystem
)
{
fileSystem
.
file
(
'pubspec.yaml'
).
createSync
();
fileSystem
.
file
(
'winuwp/project_version'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'0'
);
}
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