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
d54bed45
Commit
d54bed45
authored
Nov 15, 2016
by
John McCutchan
Committed by
GitHub
Nov 15, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support specifying a fixed list of assets on the command line (#6857)
parent
fd5a0894
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
3 deletions
+99
-3
asset.dart
packages/flutter_tools/lib/src/asset.dart
+24
-0
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+6
-2
hot.dart
packages/flutter_tools/lib/src/hot.dart
+7
-1
all.dart
packages/flutter_tools/test/all.dart
+2
-0
asset_bundle_test.dart
packages/flutter_tools/test/asset_bundle_test.dart
+60
-0
No files found.
packages/flutter_tools/lib/src/asset.dart
View file @
d54bed45
...
...
@@ -52,9 +52,33 @@ class AssetBundle {
static
const
String
_kFontSetMaterial
=
'material'
;
static
const
String
_kFontSetRoboto
=
'roboto'
;
bool
_fixed
=
false
;
DateTime
_lastBuildTimestamp
;
/// Constructs an [AssetBundle] that gathers the set of assets from the
/// flutter.yaml manifest.
AssetBundle
();
/// Constructs an [AssetBundle] with a fixed set of assets.
/// [projectRoot] The absolute path to the project root.
/// [projectAssets] comma separated list of assets.
AssetBundle
.
fixed
(
String
projectRoot
,
String
projectAssets
)
{
_fixed
=
true
;
if
((
projectRoot
==
null
)
||
(
projectAssets
==
null
))
return
;
List
<
String
>
assets
=
projectAssets
.
split
(
','
);
for
(
String
asset
in
assets
)
{
final
String
assetPath
=
path
.
join
(
projectRoot
,
asset
);
final
String
archivePath
=
asset
;
entries
.
add
(
new
AssetBundleEntry
.
fromFile
(
archivePath
,
new
File
(
assetPath
)));
}
}
bool
needsBuild
({
String
manifestPath:
defaultManifestPath
})
{
if
(
_fixed
)
return
false
;
if
(
_lastBuildTimestamp
==
null
)
return
true
;
...
...
packages/flutter_tools/lib/src/commands/run.dart
View file @
d54bed45
...
...
@@ -63,9 +63,12 @@ class RunCommand extends RunCommandBase {
argParser
.
addOption
(
'packages'
,
hide:
!
verboseHelp
,
help:
'Specify the path to the .packages file.'
);
argParser
.
addOption
(
'project
_
root'
,
argParser
.
addOption
(
'project
-
root'
,
hide:
!
verboseHelp
,
help:
'Specify the project root directory.'
);
argParser
.
addOption
(
'project-assets'
,
hide:
!
verboseHelp
,
help:
'Specify the project assets relative to the root directory.'
);
argParser
.
addFlag
(
'machine'
,
hide:
!
verboseHelp
,
help:
'Handle machine structured JSON command input
\n
'
...
...
@@ -219,8 +222,9 @@ class RunCommand extends RunCommandBase {
debuggingOptions:
options
,
benchmarkMode:
argResults
[
'benchmark'
],
applicationBinary:
argResults
[
'use-application-binary'
],
projectRootPath:
argResults
[
'project
_
root'
],
projectRootPath:
argResults
[
'project
-
root'
],
packagesFilePath:
argResults
[
'packages'
],
projectAssets:
argResults
[
'project-assets'
]
);
}
else
{
runner
=
new
RunAndStayResident
(
...
...
packages/flutter_tools/lib/src/hot.dart
View file @
d54bed45
...
...
@@ -99,6 +99,7 @@ class HotRunner extends ResidentRunner {
this
.
applicationBinary
,
String
projectRootPath
,
String
packagesFilePath
,
String
projectAssets
,
})
:
super
(
device
,
target:
target
,
debuggingOptions:
debuggingOptions
,
...
...
@@ -106,6 +107,10 @@ class HotRunner extends ResidentRunner {
_projectRootPath
=
projectRootPath
??
Directory
.
current
.
path
;
_packagesFilePath
=
packagesFilePath
??
path
.
absolute
(
PackageMap
.
globalPackagesPath
);
if
(
projectAssets
!=
null
)
_bundle
=
new
AssetBundle
.
fixed
(
_projectRootPath
,
projectAssets
);
else
_bundle
=
new
AssetBundle
();
}
ApplicationPackage
_package
;
...
...
@@ -116,7 +121,8 @@ class HotRunner extends ResidentRunner {
bool
get
prebuiltMode
=>
applicationBinary
!=
null
;
Set
<
String
>
_dartDependencies
;
int
_observatoryPort
;
final
AssetBundle
bundle
=
new
AssetBundle
();
AssetBundle
_bundle
;
AssetBundle
get
bundle
=>
_bundle
;
final
bool
benchmarkMode
;
final
Map
<
String
,
int
>
benchmarkData
=
new
Map
<
String
,
int
>();
...
...
packages/flutter_tools/test/all.dart
View file @
d54bed45
...
...
@@ -15,6 +15,7 @@ import 'analyze_duplicate_names_test.dart' as analyze_duplicate_names_test;
import
'analyze_test.dart'
as
analyze_test
;
import
'android_device_test.dart'
as
android_device_test
;
import
'android_sdk_test.dart'
as
android_sdk_test
;
import
'asset_bundle_test.dart'
as
asset_bundle_test
;
import
'application_package_test.dart'
as
application_package_test
;
import
'base_utils_test.dart'
as
base_utils_test
;
import
'channel_test.dart'
as
channel_test
;
...
...
@@ -49,6 +50,7 @@ void main() {
android_device_test
.
main
();
android_sdk_test
.
main
();
application_package_test
.
main
();
asset_bundle_test
.
main
();
base_utils_test
.
main
();
channel_test
.
main
();
config_test
.
main
();
...
...
packages/flutter_tools/test/asset_bundle_test.dart
0 → 100644
View file @
d54bed45
// Copyright 2016 The Chromium 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
'dart:io'
;
import
'dart:convert'
;
import
'package:flutter_tools/src/asset.dart'
;
import
'package:path/path.dart'
as
path
;
import
'package:test/test.dart'
;
void
main
(
)
{
// Create a temporary directory and write a single file into it.
Directory
tempDir
=
Directory
.
systemTemp
.
createTempSync
();
String
projectRoot
=
tempDir
.
path
;
String
assetPath
=
'banana.txt'
;
String
assetContents
=
'banana'
;
File
tempFile
=
new
File
(
path
.
join
(
projectRoot
,
assetPath
));
tempFile
.
parent
.
createSync
(
recursive:
true
);
tempFile
.
writeAsBytesSync
(
UTF8
.
encode
(
assetContents
));
// Fixed asset bundle tests.
group
(
'AssetBundle.fixed'
,
()
{
test
(
'empty strings'
,
()
async
{
expect
(
new
AssetBundle
.
fixed
(
null
,
null
),
isNotNull
);
expect
(
new
AssetBundle
.
fixed
(
''
,
''
),
isNotNull
);
expect
(
new
AssetBundle
.
fixed
(
null
,
null
).
entries
,
isEmpty
);
});
test
(
'does not need a rebuild'
,
()
async
{
expect
(
new
AssetBundle
.
fixed
(
null
,
null
).
needsBuild
(),
isFalse
);
});
test
(
'single entry'
,
()
async
{
AssetBundle
ab
=
new
AssetBundle
.
fixed
(
''
,
'apple.txt'
);
expect
(
ab
.
entries
,
isNotEmpty
);
expect
(
ab
.
entries
.
length
,
1
);
AssetBundleEntry
entry
=
ab
.
entries
.
first
;
expect
(
entry
,
isNotNull
);
expect
(
entry
.
archivePath
,
'apple.txt'
);
});
test
(
'two entries'
,
()
async
{
AssetBundle
ab
=
new
AssetBundle
.
fixed
(
''
,
'apple.txt,packages/flutter_gallery_assets/shrine/products/heels.png'
);
expect
(
ab
.
entries
,
isNotEmpty
);
expect
(
ab
.
entries
.
length
,
2
);
AssetBundleEntry
firstEntry
=
ab
.
entries
.
first
;
expect
(
firstEntry
,
isNotNull
);
expect
(
firstEntry
.
archivePath
,
'apple.txt'
);
AssetBundleEntry
lastEntry
=
ab
.
entries
.
last
;
expect
(
lastEntry
,
isNotNull
);
expect
(
lastEntry
.
archivePath
,
'packages/flutter_gallery_assets/shrine/products/heels.png'
);
});
test
(
'file contents'
,
()
async
{
AssetBundle
ab
=
new
AssetBundle
.
fixed
(
projectRoot
,
assetPath
);
expect
(
ab
.
entries
,
isNotEmpty
);
expect
(
ab
.
entries
.
length
,
1
);
AssetBundleEntry
entry
=
ab
.
entries
.
first
;
expect
(
entry
,
isNotNull
);
expect
(
entry
.
archivePath
,
assetPath
);
expect
(
assetContents
,
UTF8
.
decode
(
entry
.
contentsAsBytes
()));
});
});
}
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