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
3b5668c9
Unverified
Commit
3b5668c9
authored
Feb 27, 2020
by
Jonah Williams
Committed by
GitHub
Feb 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] hide usage of package:mustache behind interface (#51500)
parent
08d079f6
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
43 additions
and
66 deletions
+43
-66
executable.dart
packages/flutter_tools/lib/executable.dart
+5
-2
template.dart
packages/flutter_tools/lib/src/base/template.dart
+11
-0
mustache_template.dart
...flutter_tools/lib/src/build_runner/mustache_template.dart
+17
-0
assets.dart
...es/flutter_tools/lib/src/build_system/targets/assets.dart
+0
-44
globals.dart
packages/flutter_tools/lib/src/globals.dart
+4
-0
plugins.dart
packages/flutter_tools/lib/src/plugins.dart
+2
-3
template.dart
packages/flutter_tools/lib/src/template.dart
+1
-3
assets_test.dart
.../test/general.shard/build_system/targets/assets_test.dart
+0
-14
context.dart
packages/flutter_tools/test/src/context.dart
+3
-0
No files found.
packages/flutter_tools/lib/executable.dart
View file @
3b5668c9
...
...
@@ -6,13 +6,14 @@ import 'dart:async';
import
'runner.dart'
as
runner
;
import
'src/base/context.dart'
;
import
'src/base/template.dart'
;
// The build_runner code generation is provided here to make it easier to
// avoid introducing the dependency into google3. Not all build* packages
// are synced internally.
import
'src/build_runner/build_runner.dart'
;
import
'src/build_runner/mustache_template.dart'
;
import
'src/build_runner/resident_web_runner.dart'
;
import
'src/build_runner/web_compilation_delegate.dart'
;
import
'src/codegen.dart'
;
import
'src/commands/analyze.dart'
;
import
'src/commands/assemble.dart'
;
...
...
@@ -110,8 +111,10 @@ Future<void> main(List<String> args) async {
// the build runner packages are not synced internally.
CodeGenerator:
()
=>
const
BuildRunner
(),
WebCompilationProxy:
()
=>
BuildRunnerWebCompilationProxy
(),
// The web runner is not supported in
ternally
because it depends
// The web runner is not supported in
google3
because it depends
// on dwds.
WebRunnerFactory:
()
=>
DwdsWebRunnerFactory
(),
// The mustache dependency is different in google3
TemplateRenderer:
()
=>
const
MustacheTemplateRenderer
(),
});
}
packages/flutter_tools/lib/src/base/template.dart
0 → 100644
View file @
3b5668c9
// 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.
/// An indirection around our mustache templating system to avoid a
/// dependency on mustache..
abstract
class
TemplateRenderer
{
const
TemplateRenderer
();
String
renderString
(
String
template
,
dynamic
context
,
{
bool
htmlEscapeValues
=
false
});
}
packages/flutter_tools/lib/src/build_runner/mustache_template.dart
0 → 100644
View file @
3b5668c9
// 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.
import
'package:mustache/mustache.dart'
;
import
'../base/template.dart'
;
/// An indirection around mustache use to allow google3 to use a different dependency.
class
MustacheTemplateRenderer
extends
TemplateRenderer
{
const
MustacheTemplateRenderer
();
@override
String
renderString
(
String
template
,
dynamic
context
,
{
bool
htmlEscapeValues
=
false
})
{
return
Template
(
template
,
htmlEscapeValues:
htmlEscapeValues
).
renderString
(
context
);
}
}
packages/flutter_tools/lib/src/build_system/targets/assets.dart
View file @
3b5668c9
...
...
@@ -8,8 +8,6 @@ import '../../asset.dart';
import
'../../base/file_system.dart'
;
import
'../../devfs.dart'
;
import
'../../globals.dart'
as
globals
;
import
'../../plugins.dart'
;
import
'../../project.dart'
;
import
'../build_system.dart'
;
import
'../depfile.dart'
;
import
'dart.dart'
;
...
...
@@ -119,45 +117,3 @@ class CopyAssets extends Target {
);
}
}
/// Rewrites the `.flutter-plugins` file of [project] based on the plugin
/// dependencies declared in `pubspec.yaml`.
// TODO(jonahwiliams): this should be per platform and located in build
// outputs.
class
FlutterPlugins
extends
Target
{
const
FlutterPlugins
();
@override
String
get
name
=>
'flutter_plugins'
;
@override
List
<
Target
>
get
dependencies
=>
const
<
Target
>[];
@override
List
<
Source
>
get
inputs
=>
const
<
Source
>[
Source
.
pattern
(
'{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/assets.dart'
),
Source
.
pattern
(
'{PROJECT_DIR}/pubspec.yaml'
),
];
@override
List
<
Source
>
get
outputs
=>
const
<
Source
>[
Source
.
pattern
(
'{PROJECT_DIR}/.flutter-plugins'
),
];
@override
Future
<
void
>
build
(
Environment
environment
)
async
{
// The pubspec may change for reasons other than plugins changing, so we compare
// the manifest before writing. Some hosting build systems use timestamps
// so we need to be careful to avoid tricking them into doing more work than
// necessary.
final
FlutterProject
project
=
FlutterProject
.
fromDirectory
(
environment
.
projectDir
);
final
List
<
Plugin
>
plugins
=
findPlugins
(
project
);
final
String
pluginManifest
=
plugins
.
map
<
String
>((
Plugin
p
)
=>
'
${p.name}
=
${globals.fsUtils.escapePath(p.path)}
'
)
.
join
(
'
\n
'
);
final
File
flutterPluginsFile
=
environment
.
projectDir
.
childFile
(
'.flutter-plugins'
);
if
(!
flutterPluginsFile
.
existsSync
()
||
flutterPluginsFile
.
readAsStringSync
()
!=
pluginManifest
)
{
flutterPluginsFile
.
writeAsStringSync
(
pluginManifest
);
}
}
}
packages/flutter_tools/lib/src/globals.dart
View file @
3b5668c9
...
...
@@ -17,6 +17,7 @@ import 'base/io.dart';
import
'base/logger.dart'
;
import
'base/net.dart'
;
import
'base/os.dart'
;
import
'base/template.dart'
;
import
'base/terminal.dart'
;
import
'base/user_messages.dart'
;
import
'cache.dart'
;
...
...
@@ -160,3 +161,6 @@ PlistParser _defaultInstance;
/// The [ChromeLauncher] instance.
ChromeLauncher
get
chromeLauncher
=>
context
.
get
<
ChromeLauncher
>();
/// The global template renderer
TemplateRenderer
get
templateRenderer
=>
context
.
get
<
TemplateRenderer
>();
packages/flutter_tools/lib/src/plugins.dart
View file @
3b5668c9
...
...
@@ -5,7 +5,6 @@
import
'dart:async'
;
import
'package:meta/meta.dart'
;
import
'package:mustache/mustache.dart'
as
mustache
;
import
'package:yaml/yaml.dart'
;
import
'android/gradle.dart'
;
...
...
@@ -23,8 +22,8 @@ import 'windows/property_sheet.dart';
import
'windows/visual_studio_solution_utils.dart'
;
void
_renderTemplateToFile
(
String
template
,
dynamic
context
,
String
filePath
)
{
final
String
renderedTemplate
=
mustache
.
Template
(
template
,
htmlEscapeValues:
false
).
renderString
(
context
);
final
String
renderedTemplate
=
globals
.
templateRenderer
.
renderString
(
template
,
context
,
htmlEscapeValues:
false
);
final
File
file
=
globals
.
fs
.
file
(
filePath
);
file
.
createSync
(
recursive:
true
);
file
.
writeAsStringSync
(
renderedTemplate
);
...
...
packages/flutter_tools/lib/src/template.dart
View file @
3b5668c9
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:mustache/mustache.dart'
as
mustache
;
import
'base/common.dart'
;
import
'base/file_system.dart'
;
import
'cache.dart'
;
...
...
@@ -182,7 +180,7 @@ class Template {
if
(
sourceFile
.
path
.
endsWith
(
templateExtension
))
{
final
String
templateContents
=
sourceFile
.
readAsStringSync
();
final
String
renderedContents
=
mustache
.
Template
(
templateContents
).
renderString
(
context
);
final
String
renderedContents
=
globals
.
templateRenderer
.
renderString
(
templateContents
,
context
);
finalDestinationFile
.
writeAsStringSync
(
renderedContents
);
...
...
packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart
View file @
3b5668c9
...
...
@@ -90,18 +90,4 @@ flutter:
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
Platform:
()
=>
platform
,
});
testUsingContext
(
'FlutterPlugins updates required files as needed'
,
()
async
{
fileSystem
.
file
(
'pubspec.yaml'
)
..
writeAsStringSync
(
'name: foo
\n
dependencies:
\n
foo: any
\n
'
);
await
const
FlutterPlugins
().
build
(
Environment
.
test
(
fileSystem
.
currentDirectory
,
));
expect
(
fileSystem
.
file
(
'.flutter-plugins'
),
exists
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
}
packages/flutter_tools/test/src/context.dart
View file @
3b5668c9
...
...
@@ -14,8 +14,10 @@ import 'package:flutter_tools/src/base/logger.dart';
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/base/process.dart'
;
import
'package:flutter_tools/src/base/signals.dart'
;
import
'package:flutter_tools/src/base/template.dart'
;
import
'package:flutter_tools/src/base/terminal.dart'
;
import
'package:flutter_tools/src/base/time.dart'
;
import
'package:flutter_tools/src/build_runner/mustache_template.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/context_runner.dart'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
...
...
@@ -129,6 +131,7 @@ void testUsingContext(
Signals:
()
=>
FakeSignals
(),
Pub:
()
=>
ThrowingPub
(),
// prevent accidentally using pub.
GitHubTemplateCreator:
()
=>
MockGitHubTemplateCreator
(),
TemplateRenderer:
()
=>
const
MustacheTemplateRenderer
(),
},
body:
()
{
final
String
flutterRoot
=
getFlutterRoot
();
...
...
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