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
75079684
Commit
75079684
authored
Apr 08, 2016
by
Devon Carew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move services to using cache.dart (#3211)
parent
65b36f13
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
87 deletions
+38
-87
flutter_analysis_options
packages/flutter_tools/flutter_analysis_options
+1
-1
artifacts.dart
packages/flutter_tools/lib/src/artifacts.dart
+8
-75
cache.dart
packages/flutter_tools/lib/src/cache.dart
+24
-4
run_mojo.dart
packages/flutter_tools/lib/src/commands/run_mojo.dart
+2
-4
skia.dart
packages/flutter_tools/lib/src/commands/skia.dart
+1
-0
services.dart
packages/flutter_tools/lib/src/services.dart
+1
-2
zip.dart
packages/flutter_tools/lib/src/zip.dart
+1
-1
No files found.
packages/flutter_tools/flutter_analysis_options
View file @
75079684
...
...
@@ -4,7 +4,7 @@
# to opt-in to all desired lints (https://github.com/dart-lang/sdk/issues/25843).
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
# This file is the .analy
z
is_options file used by "flutter analyze".
# This file is the .analy
s
is_options file used by "flutter analyze".
# It isn't named that because otherwise editors like Atom would try
# to use it, and that wouldn't work because it enables things that
# need to be silenced, in particular, public_member_api_docs.
...
...
packages/flutter_tools/lib/src/artifacts.dart
View file @
75079684
...
...
@@ -2,10 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:io'
;
import
'package:archive/archive.dart'
;
import
'package:path/path.dart'
as
path
;
import
'base/process.dart'
;
...
...
@@ -179,86 +177,21 @@ class ArtifactStore {
return
_engineRevision
;
}
static
Directory
getBaseCacheDir
()
{
if
(
flutterRoot
==
null
)
{
printError
(
'FLUTTER_ROOT not specified. Cannot find artifact cache.'
);
throw
new
ProcessExit
(
2
);
}
Directory
cacheDir
=
new
Directory
(
path
.
join
(
flutterRoot
,
'bin'
,
'cache'
,
'artifacts'
));
if
(!
cacheDir
.
existsSync
())
{
printError
(
'
${cacheDir.path}
does not exist. Cannot find artifact cache.'
);
throw
new
ProcessExit
(
2
);
}
return
cacheDir
;
static
Directory
_getBaseCacheDir
()
{
return
new
Directory
(
path
.
join
(
flutterRoot
,
'bin'
,
'cache'
,
'artifacts'
));
}
// TODO(devoncarew): There are 5 call-sites of this (run_mojo, build_apk, the
// test command, toolchain, setup_xcodeproj); move them over to using
// something from `cache.dart`.
static
String
getPath
(
Artifact
artifact
)
{
File
cachedFile
=
new
File
(
path
.
join
(
getBaseCacheDir
().
path
,
'engine'
,
artifact
.
platform
,
artifact
.
fileName
)
)
;
File
cachedFile
=
new
File
(
path
.
join
(
_getBaseCacheDir
().
path
,
'engine'
,
artifact
.
platform
,
artifact
.
fileName
)
);
if
(!
cachedFile
.
existsSync
())
{
printError
(
'File not found in the platform artifacts:
${cachedFile.path}
'
);
throw
new
ProcessExit
(
2
);
}
return
cachedFile
.
path
;
}
/// Download a file from the given URL and return the bytes.
static
Future
<
List
<
int
>>
_downloadFile
(
Uri
url
)
async
{
printStatus
(
'Downloading
$url
.'
);
HttpClient
httpClient
=
new
HttpClient
();
HttpClientRequest
request
=
await
httpClient
.
getUrl
(
url
);
HttpClientResponse
response
=
await
request
.
close
();
printTrace
(
'Received response statusCode=
${response.statusCode}
'
);
if
(
response
.
statusCode
!=
200
)
throw
new
Exception
(
response
.
reasonPhrase
);
BytesBuilder
responseBody
=
new
BytesBuilder
(
copy:
false
);
await
for
(
List
<
int
>
chunk
in
response
)
responseBody
.
add
(
chunk
);
return
responseBody
.
takeBytes
();
}
/// Download a file from the given url and write it to the cache.
/// If [unzip] is true, treat the url as a zip file, and unzip it to the
/// directory given.
static
Future
<
Null
>
_downloadFileToCache
(
Uri
url
,
FileSystemEntity
cachedFile
,
bool
unzip
)
async
{
if
(!
cachedFile
.
parent
.
existsSync
())
cachedFile
.
parent
.
createSync
(
recursive:
true
);
List
<
int
>
fileBytes
=
await
_downloadFile
(
url
);
if
(
unzip
)
{
if
(
cachedFile
is
Directory
&&
!
cachedFile
.
existsSync
())
cachedFile
.
createSync
(
recursive:
true
);
Archive
archive
=
new
ZipDecoder
().
decodeBytes
(
fileBytes
);
for
(
ArchiveFile
archiveFile
in
archive
)
{
File
subFile
=
new
File
(
path
.
join
(
cachedFile
.
path
,
archiveFile
.
name
));
subFile
.
writeAsBytesSync
(
archiveFile
.
content
,
flush:
true
);
}
}
else
{
File
asFile
=
new
File
(
cachedFile
.
path
);
asFile
.
writeAsBytesSync
(
fileBytes
,
flush:
true
);
}
}
static
Future
<
String
>
getThirdPartyFile
(
String
urlStr
,
String
cacheSubdir
,
bool
unzip
)
async
{
Uri
url
=
Uri
.
parse
(
urlStr
);
Directory
baseDir
=
getBaseCacheDir
();
Directory
cacheDir
=
new
Directory
(
path
.
join
(
baseDir
.
path
,
'third_party'
,
cacheSubdir
));
File
cachedFile
=
new
File
(
path
.
join
(
cacheDir
.
path
,
url
.
pathSegments
[
url
.
pathSegments
.
length
-
1
]));
if
(!
cachedFile
.
existsSync
())
{
try
{
await
_downloadFileToCache
(
url
,
cachedFile
,
unzip
);
}
catch
(
e
)
{
printError
(
'Failed to fetch third-party artifact:
$url
:
$e
'
);
throw
new
ProcessExit
(
2
);
}
}
return
cachedFile
.
path
;
}
}
packages/flutter_tools/lib/src/cache.dart
View file @
75079684
...
...
@@ -14,6 +14,7 @@ import 'base/os.dart';
import
'base/process.dart'
;
import
'globals.dart'
;
/// A warpper around the `bin/cache/` directory.
class
Cache
{
static
Cache
get
instance
=>
context
[
Cache
]
??
(
context
[
Cache
]
=
new
Cache
());
...
...
@@ -52,6 +53,29 @@ class Cache {
stampFile
.
writeAsStringSync
(
version
);
}
Future
<
String
>
getThirdPartyFile
(
String
urlStr
,
String
serviceName
,
{
bool
unzip:
false
})
async
{
Uri
url
=
Uri
.
parse
(
urlStr
);
Directory
thirdPartyDir
=
getArtifactDirectory
(
'third_party'
);
Directory
serviceDir
=
new
Directory
(
path
.
join
(
thirdPartyDir
.
path
,
serviceName
));
if
(!
serviceDir
.
existsSync
())
serviceDir
.
createSync
(
recursive:
true
);
File
cachedFile
=
new
File
(
path
.
join
(
serviceDir
.
path
,
url
.
pathSegments
.
last
));
if
(!
cachedFile
.
existsSync
())
{
try
{
await
_downloadFileToCache
(
url
,
cachedFile
,
unzip
);
}
catch
(
e
)
{
printError
(
'Failed to fetch third-party artifact
$url
:
$e
'
);
throw
e
;
}
}
return
cachedFile
.
path
;
}
Future
<
Null
>
updateAll
()
async
{
MaterialFonts
materialFonts
=
new
MaterialFonts
(
cache
);
if
(!
materialFonts
.
isUpToDate
())
...
...
@@ -133,10 +157,6 @@ class MaterialFonts {
}
}
// TODO(devoncarew): Move the services download to here.
// gs://flutter_infra/flutter/ed3014b3d337d025393bd894ffa2897e05d43e91/firebase/
// gs://flutter_infra/flutter/ed3014b3d337d025393bd894ffa2897e05d43e91/gcm/
class
FlutterEngine
{
FlutterEngine
(
this
.
cache
);
...
...
packages/flutter_tools/lib/src/commands/run_mojo.dart
View file @
75079684
...
...
@@ -105,9 +105,8 @@ class RunMojoCommand extends FlutterCommand {
flutterPath
=
_makePathAbsolute
(
localPath
);
}
if
(
argResults
[
'android'
])
{
if
(
argResults
[
'android'
])
args
.
add
(
'--android'
);
}
final
Uri
appUri
=
Uri
.
parse
(
targetApp
);
if
(
appUri
.
scheme
.
isEmpty
||
appUri
.
scheme
==
'file'
)
{
...
...
@@ -141,9 +140,8 @@ class RunMojoCommand extends FlutterCommand {
args
.
add
(
'--verbose'
);
}
if
(
argResults
[
'checked'
])
{
if
(
argResults
[
'checked'
])
args
.
add
(
'--args-for=mojo:flutter --enable-checked-mode'
);
}
args
.
addAll
(
argResults
.
rest
);
printStatus
(
'
$args
'
);
...
...
packages/flutter_tools/lib/src/commands/skia.dart
View file @
75079684
...
...
@@ -4,6 +4,7 @@
import
'dart:async'
;
import
'dart:io'
;
import
'package:http/http.dart'
as
http
;
import
'../base/common.dart'
;
...
...
packages/flutter_tools/lib/src/services.dart
View file @
75079684
...
...
@@ -9,7 +9,6 @@ import 'dart:io';
import
'package:path/path.dart'
as
path
;
import
'package:yaml/yaml.dart'
;
import
'artifacts.dart'
;
import
'globals.dart'
;
import
'package_map.dart'
;
...
...
@@ -75,7 +74,7 @@ Future<String> getServiceFromUrl(
return
url
.
replaceAll
(
'android-sdk:'
,
'
${androidSdk.directory}
/'
);
}
else
if
(
url
.
startsWith
(
"http"
))
{
// It's a regular file to download.
return
await
ArtifactStore
.
getThirdPartyFile
(
url
,
serviceName
,
unzip
);
return
await
cache
.
getThirdPartyFile
(
url
,
serviceName
,
unzip:
unzip
);
}
else
{
// Assume url is a path relative to the service's root dir.
return
path
.
join
(
rootDir
,
url
);
...
...
packages/flutter_tools/lib/src/zip.dart
View file @
75079684
...
...
@@ -2,8 +2,8 @@
// 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'
show
UTF8
;
import
'dart:io'
;
import
'package:archive/archive.dart'
;
import
'package:path/path.dart'
as
path
;
...
...
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