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
525855d5
Commit
525855d5
authored
Jan 22, 2020
by
Dan Field
Committed by
Flutter GitHub Bot
Jan 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
download font-subset (#49234)
parent
f0a175f4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
136 additions
and
10 deletions
+136
-10
artifacts.dart
packages/flutter_tools/lib/src/artifacts.dart
+18
-8
cache.dart
packages/flutter_tools/lib/src/cache.dart
+32
-1
cache_test.dart
packages/flutter_tools/test/general.shard/cache_test.dart
+86
-1
No files found.
packages/flutter_tools/lib/src/artifacts.dart
View file @
525855d5
...
...
@@ -62,17 +62,19 @@ enum Artifact {
// Fuchsia artifacts from the engine prebuilts.
fuchsiaKernelCompiler
,
fuchsiaFlutterRunner
,
/// Tools related to subsetting or icon font files.
fontSubset
,
constFinder
,
}
String
_artifactToFileName
(
Artifact
artifact
,
[
TargetPlatform
platform
,
BuildMode
mode
])
{
final
String
exe
=
platform
==
TargetPlatform
.
windows_x64
?
'.exe'
:
''
;
switch
(
artifact
)
{
case
Artifact
.
genSnapshot
:
return
'gen_snapshot'
;
case
Artifact
.
flutterTester
:
if
(
platform
==
TargetPlatform
.
windows_x64
)
{
return
'flutter_tester.exe'
;
}
return
'flutter_tester'
;
return
'flutter_tester
$exe
'
;
case
Artifact
.
snapshotDart
:
return
'snapshot.dart'
;
case
Artifact
.
flutterFramework
:
...
...
@@ -98,10 +100,7 @@ String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMo
case
Artifact
.
frontendServerSnapshotForEngineDartSdk
:
return
'frontend_server.dart.snapshot'
;
case
Artifact
.
engineDartBinary
:
if
(
platform
==
TargetPlatform
.
windows_x64
)
{
return
'dart.exe'
;
}
return
'dart'
;
return
'dart
$exe
'
;
case
Artifact
.
dart2jsSnapshot
:
return
'dart2js.dart.snapshot'
;
case
Artifact
.
dartdevcSnapshot
:
...
...
@@ -140,6 +139,10 @@ String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMo
final
String
jitOrAot
=
mode
.
isJit
?
'_jit'
:
'_aot'
;
final
String
productOrNo
=
mode
.
isRelease
?
'_product'
:
''
;
return
'flutter
$jitOrAot${productOrNo}
_runner-0.far'
;
case
Artifact
.
fontSubset
:
return
'font-subset
$exe
'
;
case
Artifact
.
constFinder
:
return
'const_finder.dart.snapshot'
;
}
assert
(
false
,
'Invalid artifact
$artifact
.'
);
return
null
;
...
...
@@ -366,6 +369,9 @@ class CachedArtifacts extends Artifacts {
case
Artifact
.
skyEnginePath
:
final
Directory
dartPackageDirectory
=
_cache
.
getCacheDir
(
'pkg'
);
return
_fileSystem
.
path
.
join
(
dartPackageDirectory
.
path
,
_artifactToFileName
(
artifact
));
case
Artifact
.
fontSubset
:
case
Artifact
.
constFinder
:
return
_cache
.
getArtifactDirectory
(
'font-subset'
).
childFile
(
_artifactToFileName
(
artifact
,
platform
,
mode
)).
path
;
default
:
assert
(
false
,
'Artifact
$artifact
not available for platform
$platform
.'
);
return
null
;
...
...
@@ -538,6 +544,10 @@ class LocalEngineArtifacts extends Artifacts {
final
String
jitOrAot
=
mode
.
isJit
?
'_jit'
:
'_aot'
;
final
String
productOrNo
=
mode
.
isRelease
?
'_product'
:
''
;
return
_fileSystem
.
path
.
join
(
engineOutPath
,
'flutter
$jitOrAot${productOrNo}
_runner-0.far'
);
case
Artifact
.
fontSubset
:
return
_fileSystem
.
path
.
join
(
_hostEngineOutPath
,
artifactFileName
);
case
Artifact
.
constFinder
:
return
_fileSystem
.
path
.
join
(
_hostEngineOutPath
,
'gen'
,
artifactFileName
);
}
assert
(
false
,
'Invalid artifact
$artifact
.'
);
return
null
;
...
...
packages/flutter_tools/lib/src/cache.dart
View file @
525855d5
...
...
@@ -124,6 +124,7 @@ class Cache {
for
(
final
String
artifactName
in
IosUsbArtifacts
.
artifactNames
)
{
_artifacts
.
add
(
IosUsbArtifacts
(
artifactName
,
this
));
}
_artifacts
.
add
(
FontSubsetArtifacts
(
this
));
}
else
{
_artifacts
.
addAll
(
artifacts
);
}
...
...
@@ -709,7 +710,10 @@ abstract class EngineCachedArtifact extends CachedArtifact {
final
String
cacheDir
=
toolsDir
[
0
];
final
String
urlPath
=
toolsDir
[
1
];
final
Directory
dir
=
globals
.
fs
.
directory
(
globals
.
fs
.
path
.
join
(
location
.
path
,
cacheDir
));
await
_downloadZipArchive
(
'Downloading
$cacheDir
tools...'
,
Uri
.
parse
(
url
+
urlPath
),
dir
);
// Avoid printing things like 'Downloading linux-x64 tools...' multiple times.
final
String
friendlyName
=
urlPath
.
replaceAll
(
'/artifacts.zip'
,
''
).
replaceAll
(
'.zip'
,
''
);
await
_downloadZipArchive
(
'Downloading
$friendlyName
tools...'
,
Uri
.
parse
(
url
+
urlPath
),
dir
);
_makeFilesExecutable
(
dir
);
...
...
@@ -1176,6 +1180,33 @@ class MacOSFuchsiaSDKArtifacts extends _FuchsiaSDKArtifacts {
}
}
/// Cached artifacts for font subsetting.
class
FontSubsetArtifacts
extends
EngineCachedArtifact
{
FontSubsetArtifacts
(
Cache
cache
)
:
super
(
artifactName
,
cache
,
DevelopmentArtifact
.
universal
);
static
const
String
artifactName
=
'font-subset'
;
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
const
Map
<
String
,
List
<
String
>>
artifacts
=
<
String
,
List
<
String
>>
{
'macos'
:
<
String
>[
'darwin-x64'
,
'darwin-x64/
$artifactName
.zip'
],
'linux'
:
<
String
>[
'linux-x64'
,
'linux-x64/
$artifactName
.zip'
],
'windows'
:
<
String
>[
'windows-x64'
,
'windows-x64/
$artifactName
.zip'
],
};
final
List
<
String
>
binaryDirs
=
artifacts
[
globals
.
platform
.
operatingSystem
];
if
(
binaryDirs
==
null
)
{
throwToolExit
(
'Unsupported operating system:
${globals.platform.operatingSystem}
'
);
}
return
<
List
<
String
>>[
binaryDirs
];
}
@override
List
<
String
>
getLicenseDirs
()
=>
const
<
String
>[];
@override
List
<
String
>
getPackageDirs
()
=>
const
<
String
>[];
}
/// Cached iOS/USB binary artifacts.
class
IosUsbArtifacts
extends
CachedArtifact
{
IosUsbArtifacts
(
String
name
,
Cache
cache
)
:
super
(
...
...
packages/flutter_tools/test/general.shard/cache_test.dart
View file @
525855d5
...
...
@@ -278,17 +278,19 @@ void main() {
MemoryFileSystem
memoryFileSystem
;
MockCache
mockCache
;
MockOperatingSystemUtils
mockOperatingSystemUtils
;
MockHttpClient
mockHttpClient
;
setUp
(()
{
fakeHttpClient
=
FakeHttpClient
();
mockHttpClient
=
MockHttpClient
();
fakePlatform
=
FakePlatform
()..
environment
=
const
<
String
,
String
>{};
memoryFileSystem
=
MemoryFileSystem
();
mockCache
=
MockCache
();
mockOperatingSystemUtils
=
MockOperatingSystemUtils
();
when
(
mockOperatingSystemUtils
.
verifyZip
(
any
)).
thenReturn
(
true
);
});
testUsingContext
(
'makes binary dirs readable and executable by all'
,
()
async
{
when
(
mockOperatingSystemUtils
.
verifyZip
(
any
)).
thenReturn
(
true
);
final
Directory
artifactDir
=
globals
.
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_cache_test_artifact.'
);
final
Directory
downloadDir
=
globals
.
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_cache_test_download.'
);
when
(
mockCache
.
getArtifactDirectory
(
any
)).
thenReturn
(
artifactDir
);
...
...
@@ -316,6 +318,47 @@ void main() {
OperatingSystemUtils:
()
=>
mockOperatingSystemUtils
,
Platform:
()
=>
fakePlatform
,
});
testUsingContext
(
'prints a friendly name when downloading'
,
()
async
{
when
(
mockOperatingSystemUtils
.
verifyZip
(
any
)).
thenReturn
(
false
);
final
MockHttpClientRequest
httpClientRequest
=
MockHttpClientRequest
();
final
MockHttpClientResponse
httpClientResponse
=
MockHttpClientResponse
();
when
(
httpClientResponse
.
statusCode
).
thenReturn
(
200
);
when
(
httpClientRequest
.
close
()).
thenAnswer
((
_
)
async
=>
httpClientResponse
);
when
(
mockHttpClient
.
getUrl
(
any
)).
thenAnswer
((
_
)
async
=>
httpClientRequest
);
final
Directory
artifactDir
=
globals
.
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_cache_test_artifact.'
);
final
Directory
downloadDir
=
globals
.
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_cache_test_download.'
);
when
(
mockCache
.
getArtifactDirectory
(
any
)).
thenReturn
(
artifactDir
);
when
(
mockCache
.
getDownloadDir
()).
thenReturn
(
downloadDir
);
final
FakeCachedArtifact
artifact
=
FakeCachedArtifact
(
cache:
mockCache
,
binaryDirs:
<
List
<
String
>>[
<
String
>[
'bin_dir'
,
'darwin-x64/artifacts.zip'
],
<
String
>[
'font-subset'
,
'darwin-x64/font-subset.zip'
],
],
requiredArtifacts:
DevelopmentArtifact
.
universal
,
);
await
artifact
.
updateInner
();
expect
(
testLogger
.
statusText
,
isNotNull
);
expect
(
testLogger
.
statusText
,
isNotEmpty
);
expect
(
testLogger
.
statusText
.
split
(
'
\n
'
),
<
String
>[
'Downloading darwin-x64 tools...'
,
'Downloading darwin-x64/font-subset tools...'
,
''
,
],
);
},
overrides:
<
Type
,
Generator
>{
Cache:
()
=>
mockCache
,
FileSystem:
()
=>
memoryFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
HttpClientFactory:
()
=>
()
=>
mockHttpClient
,
OperatingSystemUtils:
()
=>
mockOperatingSystemUtils
,
Platform:
()
=>
fakePlatform
,
});
});
group
(
'AndroidMavenArtifacts'
,
()
{
...
...
@@ -446,6 +489,45 @@ void main() {
]);
});
},
skip:
!
globals
.
platform
.
isLinux
);
testUsingContext
(
'FontSubset in univeral artifacts'
,
()
{
final
MockCache
mockCache
=
MockCache
();
final
FontSubsetArtifacts
artifacts
=
FontSubsetArtifacts
(
mockCache
);
expect
(
artifacts
.
developmentArtifact
,
DevelopmentArtifact
.
universal
);
});
testUsingContext
(
'FontSubset artifacts on linux'
,
()
{
final
MockCache
mockCache
=
MockCache
();
final
FontSubsetArtifacts
artifacts
=
FontSubsetArtifacts
(
mockCache
);
expect
(
artifacts
.
getBinaryDirs
(),
<
List
<
String
>>[<
String
>[
'linux-x64'
,
'linux-x64/font-subset.zip'
]]);
},
overrides:
<
Type
,
Generator
>
{
Platform:
()
=>
FakePlatform
()..
operatingSystem
=
'linux'
,
});
testUsingContext
(
'FontSubset artifacts on windows'
,
()
{
final
MockCache
mockCache
=
MockCache
();
final
FontSubsetArtifacts
artifacts
=
FontSubsetArtifacts
(
mockCache
);
expect
(
artifacts
.
getBinaryDirs
(),
<
List
<
String
>>[<
String
>[
'windows-x64'
,
'windows-x64/font-subset.zip'
]]);
},
overrides:
<
Type
,
Generator
>
{
Platform:
()
=>
FakePlatform
()..
operatingSystem
=
'windows'
,
});
testUsingContext
(
'FontSubset artifacts on macos'
,
()
{
final
MockCache
mockCache
=
MockCache
();
final
FontSubsetArtifacts
artifacts
=
FontSubsetArtifacts
(
mockCache
);
expect
(
artifacts
.
getBinaryDirs
(),
<
List
<
String
>>[<
String
>[
'darwin-x64'
,
'darwin-x64/font-subset.zip'
]]);
},
overrides:
<
Type
,
Generator
>
{
Platform:
()
=>
FakePlatform
()..
operatingSystem
=
'macos'
,
});
testUsingContext
(
'FontSubset artifacts on fuchsia'
,
()
{
final
MockCache
mockCache
=
MockCache
();
final
FontSubsetArtifacts
artifacts
=
FontSubsetArtifacts
(
mockCache
);
expect
(()
=>
artifacts
.
getBinaryDirs
(),
throwsToolExit
(
message:
'Unsupported operating system:
${globals.platform.operatingSystem}
'
));
},
overrides:
<
Type
,
Generator
>
{
Platform:
()
=>
FakePlatform
()..
operatingSystem
=
'fuchsia'
,
});
}
class
FakeCachedArtifact
extends
EngineCachedArtifact
{
...
...
@@ -513,3 +595,6 @@ class MockCache extends Mock implements Cache {}
class
MockOperatingSystemUtils
extends
Mock
implements
OperatingSystemUtils
{}
class
MockPlatform
extends
Mock
implements
Platform
{}
class
MockVersionedPackageResolver
extends
Mock
implements
VersionedPackageResolver
{}
class
MockHttpClientRequest
extends
Mock
implements
HttpClientRequest
{}
class
MockHttpClientResponse
extends
Mock
implements
HttpClientResponse
{}
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