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
a75e79f0
Commit
a75e79f0
authored
Sep 17, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address review comments from @iansf
parent
cf41a633
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
35 deletions
+39
-35
artifacts.dart
packages/flutter_tools/lib/src/artifacts.dart
+2
-0
build.dart
packages/flutter_tools/lib/src/build.dart
+37
-35
No files found.
packages/flutter_tools/lib/src/artifacts.dart
View file @
a75e79f0
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
library
sky_tools
.
artifacts
;
import
'dart:async'
;
import
'dart:async'
;
import
'dart:io'
;
import
'dart:io'
;
...
...
packages/flutter_tools/lib/src/build.dart
View file @
a75e79f0
...
@@ -2,43 +2,45 @@
...
@@ -2,43 +2,45 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
import
'dart:io'
;
library
sky_tools
.
build
;
import
'dart:async'
;
import
'dart:async'
;
import
'dart:io'
;
import
'package:archive/archive.dart'
;
import
'package:archive/archive.dart'
;
import
'package:args/args.dart'
;
import
'package:args/args.dart'
;
import
'package:yaml/yaml.dart'
;
import
'package:yaml/yaml.dart'
;
import
'common.dart'
;
import
'artifacts.dart'
;
import
'artifacts.dart'
;
import
'common.dart'
;
const
String
kSnapshotKey
=
'snapshot_blob.bin'
;
const
String
_
kSnapshotKey
=
'snapshot_blob.bin'
;
const
List
<
String
>
kDensities
=
const
[
'drawable-xxhdpi'
];
const
List
<
String
>
_
kDensities
=
const
[
'drawable-xxhdpi'
];
const
List
<
String
>
kThemes
=
const
[
'white'
,
'black'
];
const
List
<
String
>
_
kThemes
=
const
[
'white'
,
'black'
];
const
List
<
int
>
kSizes
=
const
[
24
];
const
List
<
int
>
_
kSizes
=
const
[
24
];
class
Asset
{
class
_
Asset
{
final
String
base
;
final
String
base
;
final
String
key
;
final
String
key
;
Asset
({
this
.
base
,
this
.
key
});
_
Asset
({
this
.
base
,
this
.
key
});
}
}
Iterable
<
Asset
>
parseAssets
(
Map
manifestDescriptor
,
String
manifestPath
)
sync
*
{
Iterable
<
_Asset
>
_
parseAssets
(
Map
manifestDescriptor
,
String
manifestPath
)
sync
*
{
if
(
manifestDescriptor
==
null
||
!
manifestDescriptor
.
containsKey
(
'assets'
))
if
(
manifestDescriptor
==
null
||
!
manifestDescriptor
.
containsKey
(
'assets'
))
return
;
return
;
String
basePath
=
new
File
(
manifestPath
).
parent
.
path
;
String
basePath
=
new
File
(
manifestPath
).
parent
.
path
;
for
(
String
asset
in
manifestDescriptor
[
'assets'
])
for
(
String
asset
in
manifestDescriptor
[
'assets'
])
yield
new
Asset
(
base:
basePath
,
key:
asset
);
yield
new
_
Asset
(
base:
basePath
,
key:
asset
);
}
}
class
MaterialAsset
{
class
_
MaterialAsset
{
final
String
name
;
final
String
name
;
final
String
density
;
final
String
density
;
final
String
theme
;
final
String
theme
;
final
int
size
;
final
int
size
;
MaterialAsset
(
Map
descriptor
)
_
MaterialAsset
(
Map
descriptor
)
:
name
=
descriptor
[
'name'
],
:
name
=
descriptor
[
'name'
],
density
=
descriptor
[
'density'
],
density
=
descriptor
[
'density'
],
theme
=
descriptor
[
'theme'
],
theme
=
descriptor
[
'theme'
],
...
@@ -52,44 +54,44 @@ class MaterialAsset {
...
@@ -52,44 +54,44 @@ class MaterialAsset {
}
}
}
}
List
generateValues
(
Map
assetDescriptor
,
String
key
,
List
defaults
)
{
List
_
generateValues
(
Map
assetDescriptor
,
String
key
,
List
defaults
)
{
if
(
assetDescriptor
.
containsKey
(
key
))
if
(
assetDescriptor
.
containsKey
(
key
))
return
[
assetDescriptor
[
key
]];
return
[
assetDescriptor
[
key
]];
return
defaults
;
return
defaults
;
}
}
Iterable
<
MaterialAsset
>
generateMaterialAssets
(
Map
assetDescriptor
)
sync
*
{
Iterable
<
_MaterialAsset
>
_
generateMaterialAssets
(
Map
assetDescriptor
)
sync
*
{
Map
currentAssetDescriptor
=
new
Map
.
from
(
assetDescriptor
);
Map
currentAssetDescriptor
=
new
Map
.
from
(
assetDescriptor
);
for
(
String
density
in
generateValues
(
assetDescriptor
,
'density'
,
kDensities
))
{
for
(
String
density
in
_generateValues
(
assetDescriptor
,
'density'
,
_
kDensities
))
{
currentAssetDescriptor
[
'density'
]
=
density
;
currentAssetDescriptor
[
'density'
]
=
density
;
for
(
String
theme
in
generateValues
(
assetDescriptor
,
'theme'
,
kThemes
))
{
for
(
String
theme
in
_generateValues
(
assetDescriptor
,
'theme'
,
_
kThemes
))
{
currentAssetDescriptor
[
'theme'
]
=
theme
;
currentAssetDescriptor
[
'theme'
]
=
theme
;
for
(
int
size
in
generateValues
(
assetDescriptor
,
'size'
,
kSizes
))
{
for
(
int
size
in
_generateValues
(
assetDescriptor
,
'size'
,
_
kSizes
))
{
currentAssetDescriptor
[
'size'
]
=
size
;
currentAssetDescriptor
[
'size'
]
=
size
;
yield
new
MaterialAsset
(
currentAssetDescriptor
);
yield
new
_
MaterialAsset
(
currentAssetDescriptor
);
}
}
}
}
}
}
}
}
Iterable
<
MaterialAsset
>
parseMaterialAssets
(
Map
manifestDescriptor
)
sync
*
{
Iterable
<
_MaterialAsset
>
_
parseMaterialAssets
(
Map
manifestDescriptor
)
sync
*
{
if
(
manifestDescriptor
==
null
||
!
manifestDescriptor
.
containsKey
(
'material-design-icons'
))
if
(
manifestDescriptor
==
null
||
!
manifestDescriptor
.
containsKey
(
'material-design-icons'
))
return
;
return
;
for
(
Map
assetDescriptor
in
manifestDescriptor
[
'material-design-icons'
])
{
for
(
Map
assetDescriptor
in
manifestDescriptor
[
'material-design-icons'
])
{
for
(
MaterialAsset
asset
in
generateMaterialAssets
(
assetDescriptor
))
{
for
(
_MaterialAsset
asset
in
_
generateMaterialAssets
(
assetDescriptor
))
{
yield
asset
;
yield
asset
;
}
}
}
}
}
}
Future
loadManifest
(
String
manifestPath
)
async
{
Future
_
loadManifest
(
String
manifestPath
)
async
{
if
(
manifestPath
==
null
)
if
(
manifestPath
==
null
)
return
null
;
return
null
;
String
manifestDescriptor
=
await
new
File
(
manifestPath
).
readAsString
();
String
manifestDescriptor
=
await
new
File
(
manifestPath
).
readAsString
();
return
loadYaml
(
manifestDescriptor
);
return
loadYaml
(
manifestDescriptor
);
}
}
Future
<
ArchiveFile
>
createFile
(
String
key
,
String
assetBase
)
async
{
Future
<
ArchiveFile
>
_
createFile
(
String
key
,
String
assetBase
)
async
{
File
file
=
new
File
(
'
${assetBase}
/
${key}
'
);
File
file
=
new
File
(
'
${assetBase}
/
${key}
'
);
if
(!
await
file
.
exists
())
if
(!
await
file
.
exists
())
return
null
;
return
null
;
...
@@ -97,7 +99,7 @@ Future<ArchiveFile> createFile(String key, String assetBase) async {
...
@@ -97,7 +99,7 @@ Future<ArchiveFile> createFile(String key, String assetBase) async {
return
new
ArchiveFile
.
noCompress
(
key
,
content
.
length
,
content
);
return
new
ArchiveFile
.
noCompress
(
key
,
content
.
length
,
content
);
}
}
Future
compileSnapshot
(
{
Future
_
compileSnapshot
(
{
String
mainPath
,
String
mainPath
,
String
packageRoot
,
String
packageRoot
,
String
snapshotPath
String
snapshotPath
...
@@ -110,14 +112,14 @@ Future compileSnapshot({
...
@@ -110,14 +112,14 @@ Future compileSnapshot({
]);
]);
}
}
Future
<
ArchiveFile
>
createSnapshotFile
(
String
snapshotPath
)
async
{
Future
<
ArchiveFile
>
_
createSnapshotFile
(
String
snapshotPath
)
async
{
File
file
=
new
File
(
snapshotPath
);
File
file
=
new
File
(
snapshotPath
);
List
<
int
>
content
=
await
file
.
readAsBytes
();
List
<
int
>
content
=
await
file
.
readAsBytes
();
return
new
ArchiveFile
(
kSnapshotKey
,
content
.
length
,
content
);
return
new
ArchiveFile
(
_
kSnapshotKey
,
content
.
length
,
content
);
}
}
class
BuildCommandHandler
extends
CommandHandler
{
class
BuildCommandHandler
extends
CommandHandler
{
BuildCommandHandler
()
:
super
(
'build'
,
'Create a
n
Flutter package.'
);
BuildCommandHandler
()
:
super
(
'build'
,
'Create a Flutter package.'
);
ArgParser
get
parser
{
ArgParser
get
parser
{
ArgParser
parser
=
new
ArgParser
();
ArgParser
parser
=
new
ArgParser
();
...
@@ -139,24 +141,24 @@ class BuildCommandHandler extends CommandHandler {
...
@@ -139,24 +141,24 @@ class BuildCommandHandler extends CommandHandler {
}
}
String
manifestPath
=
results
[
'manifest'
];
String
manifestPath
=
results
[
'manifest'
];
Map
manifestDescriptor
=
await
loadManifest
(
manifestPath
);
Map
manifestDescriptor
=
await
_
loadManifest
(
manifestPath
);
Iterable
<
Asset
>
assets
=
parseAssets
(
manifestDescriptor
,
manifestPath
);
Iterable
<
_Asset
>
assets
=
_
parseAssets
(
manifestDescriptor
,
manifestPath
);
Iterable
<
MaterialAsset
>
materialAssets
=
parseMaterialAssets
(
manifestDescriptor
);
Iterable
<
_MaterialAsset
>
materialAssets
=
_
parseMaterialAssets
(
manifestDescriptor
);
Archive
archive
=
new
Archive
();
Archive
archive
=
new
Archive
();
String
snapshotPath
=
results
[
'snapshot'
];
String
snapshotPath
=
results
[
'snapshot'
];
await
compileSnapshot
(
await
_
compileSnapshot
(
mainPath:
results
[
'main'
],
mainPath:
results
[
'main'
],
packageRoot:
results
[
'package-root'
],
packageRoot:
results
[
'package-root'
],
snapshotPath:
snapshotPath
);
snapshotPath:
snapshotPath
);
archive
.
addFile
(
await
createSnapshotFile
(
snapshotPath
));
archive
.
addFile
(
await
_
createSnapshotFile
(
snapshotPath
));
for
(
Asset
asset
in
assets
)
for
(
_
Asset
asset
in
assets
)
archive
.
addFile
(
await
createFile
(
asset
.
key
,
asset
.
base
));
archive
.
addFile
(
await
_
createFile
(
asset
.
key
,
asset
.
base
));
for
(
MaterialAsset
asset
in
materialAssets
)
{
for
(
_
MaterialAsset
asset
in
materialAssets
)
{
ArchiveFile
file
=
await
createFile
(
asset
.
key
,
results
[
'asset-base'
]);
ArchiveFile
file
=
await
_
createFile
(
asset
.
key
,
results
[
'asset-base'
]);
if
(
file
!=
null
)
if
(
file
!=
null
)
archive
.
addFile
(
file
);
archive
.
addFile
(
file
);
}
}
...
...
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