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
55a1ba76
Unverified
Commit
55a1ba76
authored
Aug 28, 2019
by
Jonah Williams
Committed by
GitHub
Aug 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use output dir instead of specific paths in assemble rules (#39274)
parent
1ba5f799
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
93 additions
and
43 deletions
+93
-43
macos_assemble.sh
packages/flutter_tools/bin/macos_assemble.sh
+1
-0
build_system.dart
...ages/flutter_tools/lib/src/build_system/build_system.dart
+13
-1
source.dart
packages/flutter_tools/lib/src/build_system/source.dart
+4
-0
macos.dart
...ges/flutter_tools/lib/src/build_system/targets/macos.dart
+17
-25
assemble.dart
packages/flutter_tools/lib/src/commands/assemble.dart
+13
-0
build_system_test.dart
...ls/test/general.shard/build_system/build_system_test.dart
+1
-0
filecache_test.dart
...tools/test/general.shard/build_system/filecache_test.dart
+1
-0
source_test.dart
...er_tools/test/general.shard/build_system/source_test.dart
+12
-0
assets_test.dart
.../test/general.shard/build_system/targets/assets_test.dart
+2
-0
dart_test.dart
...ls/test/general.shard/build_system/targets/dart_test.dart
+3
-0
linux_test.dart
...s/test/general.shard/build_system/targets/linux_test.dart
+1
-0
macos_test.dart
...s/test/general.shard/build_system/targets/macos_test.dart
+8
-12
windows_test.dart
...test/general.shard/build_system/targets/windows_test.dart
+1
-0
assemble_test.dart
...tter_tools/test/general.shard/commands/assemble_test.dart
+16
-5
No files found.
packages/flutter_tools/bin/macos_assemble.sh
View file @
55a1ba76
...
@@ -72,4 +72,5 @@ RunCommand "${FLUTTER_ROOT}/bin/flutter" --suppress-analytics \
...
@@ -72,4 +72,5 @@ RunCommand "${FLUTTER_ROOT}/bin/flutter" --suppress-analytics \
-dBuildMode
=
"
${
build_mode
}
"
\
-dBuildMode
=
"
${
build_mode
}
"
\
--build-inputs
=
"
${
build_inputs_path
}
"
\
--build-inputs
=
"
${
build_inputs_path
}
"
\
--build-outputs
=
"
${
build_outputs_path
}
"
\
--build-outputs
=
"
${
build_outputs_path
}
"
\
--output
=
"
${
ephemeral_dir
}
"
\
"
${
build_mode
}
_macos_bundle_flutter_assets"
"
${
build_mode
}
_macos_bundle_flutter_assets"
packages/flutter_tools/lib/src/build_system/build_system.dart
View file @
55a1ba76
...
@@ -349,6 +349,7 @@ class Environment {
...
@@ -349,6 +349,7 @@ class Environment {
/// defaults based on it.
/// defaults based on it.
factory
Environment
({
factory
Environment
({
@required
Directory
projectDir
,
@required
Directory
projectDir
,
@required
Directory
outputDir
,
Directory
buildDir
,
Directory
buildDir
,
Map
<
String
,
String
>
defines
=
const
<
String
,
String
>{},
Map
<
String
,
String
>
defines
=
const
<
String
,
String
>{},
})
{
})
{
...
@@ -371,6 +372,7 @@ class Environment {
...
@@ -371,6 +372,7 @@ class Environment {
final
Directory
rootBuildDir
=
buildDir
??
projectDir
.
childDirectory
(
'build'
);
final
Directory
rootBuildDir
=
buildDir
??
projectDir
.
childDirectory
(
'build'
);
final
Directory
buildDirectory
=
rootBuildDir
.
childDirectory
(
buildPrefix
);
final
Directory
buildDirectory
=
rootBuildDir
.
childDirectory
(
buildPrefix
);
return
Environment
.
_
(
return
Environment
.
_
(
outputDir:
outputDir
,
projectDir:
projectDir
,
projectDir:
projectDir
,
buildDir:
buildDirectory
,
buildDir:
buildDirectory
,
rootBuildDir:
rootBuildDir
,
rootBuildDir:
rootBuildDir
,
...
@@ -381,6 +383,7 @@ class Environment {
...
@@ -381,6 +383,7 @@ class Environment {
}
}
Environment
.
_
({
Environment
.
_
({
@required
this
.
outputDir
,
@required
this
.
projectDir
,
@required
this
.
projectDir
,
@required
this
.
buildDir
,
@required
this
.
buildDir
,
@required
this
.
rootBuildDir
,
@required
this
.
rootBuildDir
,
...
@@ -401,6 +404,9 @@ class Environment {
...
@@ -401,6 +404,9 @@ class Environment {
/// The [Source] value which is substituted with a path to the flutter root.
/// The [Source] value which is substituted with a path to the flutter root.
static
const
String
kFlutterRootDirectory
=
'{FLUTTER_ROOT}'
;
static
const
String
kFlutterRootDirectory
=
'{FLUTTER_ROOT}'
;
/// The [Source] value which is substituted with a path to [outputDir].
static
const
String
kOutputDirectory
=
'{OUTPUT_DIR}'
;
/// The `PROJECT_DIR` environment variable.
/// The `PROJECT_DIR` environment variable.
///
///
/// This should be root of the flutter project where a pubspec and dart files
/// This should be root of the flutter project where a pubspec and dart files
...
@@ -424,6 +430,11 @@ class Environment {
...
@@ -424,6 +430,11 @@ class Environment {
/// Defaults to to the value of [Cache.flutterRoot].
/// Defaults to to the value of [Cache.flutterRoot].
final
Directory
flutterRootDir
;
final
Directory
flutterRootDir
;
/// The `OUTPUT_DIR` environment variable.
///
/// Must be provided to configure the output location for the final artifacts.
final
Directory
outputDir
;
/// Additional configuration passed to the build targets.
/// Additional configuration passed to the build targets.
///
///
/// Setting values here forces a unique build directory to be chosen
/// Setting values here forces a unique build directory to be chosen
...
@@ -464,6 +475,7 @@ class BuildSystem {
...
@@ -464,6 +475,7 @@ class BuildSystem {
{
BuildSystemConfig
buildSystemConfig
=
const
BuildSystemConfig
()
}
{
BuildSystemConfig
buildSystemConfig
=
const
BuildSystemConfig
()
}
)
async
{
)
async
{
environment
.
buildDir
.
createSync
(
recursive:
true
);
environment
.
buildDir
.
createSync
(
recursive:
true
);
environment
.
outputDir
.
createSync
(
recursive:
true
);
// Load file hash store from previous builds.
// Load file hash store from previous builds.
final
FileHashStore
fileCache
=
FileHashStore
(
environment
)
final
FileHashStore
fileCache
=
FileHashStore
(
environment
)
...
@@ -482,7 +494,7 @@ class BuildSystem {
...
@@ -482,7 +494,7 @@ class BuildSystem {
}
}
// TODO(jonahwilliams): this is a bit of a hack, due to various parts of
// TODO(jonahwilliams): this is a bit of a hack, due to various parts of
// the flutter tool writing these files unconditionally. Since Xcode uses
// the flutter tool writing these files unconditionally. Since Xcode uses
// timestamps to track files, this leads to unecessary rebuilds if they
// timestamps to track files, this leads to un
n
ecessary rebuilds if they
// are included. Once all the places that write these files have been
// are included. Once all the places that write these files have been
// tracked down and moved into assemble, these checks should be removable.
// tracked down and moved into assemble, these checks should be removable.
// We also remove files under .dart_tool, since these are intermediaries
// We also remove files under .dart_tool, since these are intermediaries
...
...
packages/flutter_tools/lib/src/build_system/source.dart
View file @
55a1ba76
...
@@ -71,6 +71,10 @@ class SourceVisitor {
...
@@ -71,6 +71,10 @@ class SourceVisitor {
segments
.
addAll
(
segments
.
addAll
(
fs
.
path
.
split
(
environment
.
flutterRootDir
.
absolute
.
path
));
fs
.
path
.
split
(
environment
.
flutterRootDir
.
absolute
.
path
));
break
;
break
;
case
Environment
.
kOutputDirectory
:
segments
.
addAll
(
fs
.
path
.
split
(
environment
.
outputDir
.
resolveSymbolicLinksSync
()));
break
;
default
:
default
:
throw
InvalidPatternException
(
pattern
);
throw
InvalidPatternException
(
pattern
);
}
}
...
...
packages/flutter_tools/lib/src/build_system/targets/macos.dart
View file @
55a1ba76
...
@@ -15,12 +15,11 @@ import '../../build_info.dart';
...
@@ -15,12 +15,11 @@ import '../../build_info.dart';
import
'../../devfs.dart'
;
import
'../../devfs.dart'
;
import
'../../globals.dart'
;
import
'../../globals.dart'
;
import
'../../macos/xcode.dart'
;
import
'../../macos/xcode.dart'
;
import
'../../project.dart'
;
import
'../build_system.dart'
;
import
'../build_system.dart'
;
import
'../exceptions.dart'
;
import
'../exceptions.dart'
;
import
'dart.dart'
;
import
'dart.dart'
;
const
String
_kOutputPrefix
=
'{
PROJECT_DIR}/macos/Flutter/ephemeral
/FlutterMacOS.framework'
;
const
String
_kOutputPrefix
=
'{
OUTPUT_DIR}
/FlutterMacOS.framework'
;
/// The copying logic for flutter assets in macOS.
/// The copying logic for flutter assets in macOS.
// TODO(jonahwilliams): remove once build planning lands.
// TODO(jonahwilliams): remove once build planning lands.
...
@@ -51,8 +50,7 @@ class MacOSAssetBehavior extends SourceBehavior {
...
@@ -51,8 +50,7 @@ class MacOSAssetBehavior extends SourceBehavior {
manifestPath:
environment
.
projectDir
.
childFile
(
'pubspec.yaml'
).
path
,
manifestPath:
environment
.
projectDir
.
childFile
(
'pubspec.yaml'
).
path
,
packagesPath:
environment
.
projectDir
.
childFile
(
'.packages'
).
path
,
packagesPath:
environment
.
projectDir
.
childFile
(
'.packages'
).
path
,
);
);
final
FlutterProject
flutterProject
=
FlutterProject
.
fromDirectory
(
environment
.
projectDir
);
final
String
prefix
=
fs
.
path
.
join
(
environment
.
outputDir
.
path
,
final
String
prefix
=
fs
.
path
.
join
(
flutterProject
.
macos
.
ephemeralDirectory
.
path
,
'App.framework'
,
'Versions'
,
'A'
,
'Resources'
,
'flutter_assets'
);
'App.framework'
,
'Versions'
,
'A'
,
'Resources'
,
'flutter_assets'
);
final
List
<
File
>
results
=
<
File
>[];
final
List
<
File
>
results
=
<
File
>[];
for
(
String
key
in
assetBundle
.
entries
.
keys
)
{
for
(
String
key
in
assetBundle
.
entries
.
keys
)
{
...
@@ -65,7 +63,7 @@ class MacOSAssetBehavior extends SourceBehavior {
...
@@ -65,7 +63,7 @@ class MacOSAssetBehavior extends SourceBehavior {
/// Copy the macOS framework to the correct copy dir by invoking 'cp -R'.
/// Copy the macOS framework to the correct copy dir by invoking 'cp -R'.
///
///
/// This class is abstract to share logic between the three conrete
/// This class is abstract to share logic between the three con
c
rete
/// implementations. The shelling out is done to avoid complications with
/// implementations. The shelling out is done to avoid complications with
/// preserving special files (e.g., symbolic links) in the framework structure.
/// preserving special files (e.g., symbolic links) in the framework structure.
///
///
...
@@ -121,9 +119,8 @@ abstract class UnpackMacOS extends Target {
...
@@ -121,9 +119,8 @@ abstract class UnpackMacOS extends Target {
}
}
final
BuildMode
buildMode
=
getBuildModeForName
(
environment
.
defines
[
kBuildMode
]);
final
BuildMode
buildMode
=
getBuildModeForName
(
environment
.
defines
[
kBuildMode
]);
final
String
basePath
=
artifacts
.
getArtifactPath
(
Artifact
.
flutterMacOSFramework
,
mode:
buildMode
);
final
String
basePath
=
artifacts
.
getArtifactPath
(
Artifact
.
flutterMacOSFramework
,
mode:
buildMode
);
final
FlutterProject
flutterProject
=
FlutterProject
.
fromDirectory
(
environment
.
projectDir
);
final
Directory
targetDirectory
=
environment
final
Directory
targetDirectory
=
flutterProject
.
macos
.
outputDir
.
ephemeralDirectory
.
childDirectory
(
'FlutterMacOS.framework'
);
.
childDirectory
(
'FlutterMacOS.framework'
);
if
(
targetDirectory
.
existsSync
())
{
if
(
targetDirectory
.
existsSync
())
{
targetDirectory
.
deleteSync
(
recursive:
true
);
targetDirectory
.
deleteSync
(
recursive:
true
);
...
@@ -247,7 +244,6 @@ class CompileMacOSFramework extends Target {
...
@@ -247,7 +244,6 @@ class CompileMacOSFramework extends Target {
if
(
buildMode
==
BuildMode
.
debug
)
{
if
(
buildMode
==
BuildMode
.
debug
)
{
throw
Exception
(
'precompiled macOS framework only supported in release/profile builds.'
);
throw
Exception
(
'precompiled macOS framework only supported in release/profile builds.'
);
}
}
final
FlutterProject
flutterProject
=
FlutterProject
.
fromDirectory
(
environment
.
projectDir
);
final
int
result
=
await
AOTSnapshotter
(
reportTimings:
false
).
build
(
final
int
result
=
await
AOTSnapshotter
(
reportTimings:
false
).
build
(
bitcode:
false
,
bitcode:
false
,
buildMode:
buildMode
,
buildMode:
buildMode
,
...
@@ -255,7 +251,7 @@ class CompileMacOSFramework extends Target {
...
@@ -255,7 +251,7 @@ class CompileMacOSFramework extends Target {
outputPath:
environment
.
buildDir
.
path
,
outputPath:
environment
.
buildDir
.
path
,
platform:
TargetPlatform
.
darwin_x64
,
platform:
TargetPlatform
.
darwin_x64
,
darwinArch:
DarwinArch
.
x86_64
,
darwinArch:
DarwinArch
.
x86_64
,
packagesPath:
flutterProject
.
packagesFile
.
path
packagesPath:
environment
.
projectDir
.
childFile
(
'.packages'
).
path
,
);
);
if
(
result
!=
0
)
{
if
(
result
!=
0
)
{
throw
Exception
(
'gen shapshot failed.'
);
throw
Exception
(
'gen shapshot failed.'
);
...
@@ -298,11 +294,11 @@ abstract class MacOSBundleFlutterAssets extends Target {
...
@@ -298,11 +294,11 @@ abstract class MacOSBundleFlutterAssets extends Target {
@override
@override
List
<
Source
>
get
outputs
=>
const
<
Source
>[
List
<
Source
>
get
outputs
=>
const
<
Source
>[
Source
.
behavior
(
MacOSAssetBehavior
()),
Source
.
behavior
(
MacOSAssetBehavior
()),
Source
.
pattern
(
'{
PROJECT_DIR}/macos/Flutter/ephemeral
/App.framework/Versions/A/App'
),
Source
.
pattern
(
'{
OUTPUT_DIR}
/App.framework/Versions/A/App'
),
Source
.
pattern
(
'{
PROJECT_DIR}/macos/Flutter/ephemeral
/App.framework/Versions/A/Resources/Info.plist'
),
Source
.
pattern
(
'{
OUTPUT_DIR}
/App.framework/Versions/A/Resources/Info.plist'
),
Source
.
pattern
(
'{
PROJECT_DIR}/macos/Flutter/ephemeral
/App.framework/Versions/A/Resources/flutter_assets/AssetManifest.json'
),
Source
.
pattern
(
'{
OUTPUT_DIR}
/App.framework/Versions/A/Resources/flutter_assets/AssetManifest.json'
),
Source
.
pattern
(
'{
PROJECT_DIR}/macos/Flutter/ephemeral
/App.framework/Versions/A/Resources/flutter_assets/FontManifest.json'
),
Source
.
pattern
(
'{
OUTPUT_DIR}
/App.framework/Versions/A/Resources/flutter_assets/FontManifest.json'
),
Source
.
pattern
(
'{
PROJECT_DIR}/macos/Flutter/ephemeral
/App.framework/Versions/A/Resources/flutter_assets/LICENSE'
),
Source
.
pattern
(
'{
OUTPUT_DIR}
/App.framework/Versions/A/Resources/flutter_assets/LICENSE'
),
];
];
@override
@override
...
@@ -311,9 +307,8 @@ abstract class MacOSBundleFlutterAssets extends Target {
...
@@ -311,9 +307,8 @@ abstract class MacOSBundleFlutterAssets extends Target {
throw
MissingDefineException
(
kBuildMode
,
'compile_macos_framework'
);
throw
MissingDefineException
(
kBuildMode
,
'compile_macos_framework'
);
}
}
final
BuildMode
buildMode
=
getBuildModeForName
(
environment
.
defines
[
kBuildMode
]);
final
BuildMode
buildMode
=
getBuildModeForName
(
environment
.
defines
[
kBuildMode
]);
final
FlutterProject
flutterProject
=
FlutterProject
.
fromDirectory
(
environment
.
projectDir
);
final
Directory
frameworkRootDirectory
=
environment
final
Directory
frameworkRootDirectory
=
flutterProject
.
macos
.
outputDir
.
ephemeralDirectory
.
childDirectory
(
'App.framework'
);
.
childDirectory
(
'App.framework'
);
final
Directory
outputDirectory
=
frameworkRootDirectory
final
Directory
outputDirectory
=
frameworkRootDirectory
.
childDirectory
(
'Versions'
)
.
childDirectory
(
'Versions'
)
...
@@ -420,7 +415,6 @@ abstract class MacOSBundleFlutterAssets extends Target {
...
@@ -420,7 +415,6 @@ abstract class MacOSBundleFlutterAssets extends Target {
if
(!
currentVersion
.
existsSync
())
{
if
(!
currentVersion
.
existsSync
())
{
final
String
linkPath
=
fs
.
path
.
relative
(
outputDirectory
.
path
,
final
String
linkPath
=
fs
.
path
.
relative
(
outputDirectory
.
path
,
from:
outputDirectory
.
parent
.
path
);
from:
outputDirectory
.
parent
.
path
);
print
(
linkPath
);
currentVersion
.
createSync
(
'
$linkPath${fs.path.separator}
'
);
currentVersion
.
createSync
(
'
$linkPath${fs.path.separator}
'
);
}
}
// Create symlink to current resources.
// Create symlink to current resources.
...
@@ -429,7 +423,6 @@ abstract class MacOSBundleFlutterAssets extends Target {
...
@@ -429,7 +423,6 @@ abstract class MacOSBundleFlutterAssets extends Target {
if
(!
currentResources
.
existsSync
())
{
if
(!
currentResources
.
existsSync
())
{
final
String
linkPath
=
fs
.
path
.
relative
(
fs
.
path
.
join
(
currentVersion
.
path
,
'Resources'
),
final
String
linkPath
=
fs
.
path
.
relative
(
fs
.
path
.
join
(
currentVersion
.
path
,
'Resources'
),
from:
frameworkRootDirectory
.
path
);
from:
frameworkRootDirectory
.
path
);
print
(
linkPath
);
currentResources
.
createSync
(
linkPath
);
currentResources
.
createSync
(
linkPath
);
}
}
// Create symlink to current binary.
// Create symlink to current binary.
...
@@ -438,12 +431,11 @@ abstract class MacOSBundleFlutterAssets extends Target {
...
@@ -438,12 +431,11 @@ abstract class MacOSBundleFlutterAssets extends Target {
if
(!
currentFramework
.
existsSync
())
{
if
(!
currentFramework
.
existsSync
())
{
final
String
linkPath
=
fs
.
path
.
relative
(
fs
.
path
.
join
(
currentVersion
.
path
,
'App'
),
final
String
linkPath
=
fs
.
path
.
relative
(
fs
.
path
.
join
(
currentVersion
.
path
,
'App'
),
from:
frameworkRootDirectory
.
path
);
from:
frameworkRootDirectory
.
path
);
print
(
linkPath
);
currentFramework
.
createSync
(
linkPath
);
currentFramework
.
createSync
(
linkPath
);
}
}
}
on
FileSystemException
{
}
on
FileSystemException
{
throw
Exception
(
'Failed to create symlinks for framework. try removing '
throw
Exception
(
'Failed to create symlinks for framework. try removing '
'the "
${
flutterProject.macos.ephemeralDirectory
.path}
" directory and rerunning'
);
'the "
${
environment.outputDir
.path}
" directory and rerunning'
);
}
}
}
}
}
}
...
@@ -473,9 +465,9 @@ class DebugMacOSBundleFlutterAssets extends MacOSBundleFlutterAssets {
...
@@ -473,9 +465,9 @@ class DebugMacOSBundleFlutterAssets extends MacOSBundleFlutterAssets {
@override
@override
List
<
Source
>
get
outputs
=>
<
Source
>[
List
<
Source
>
get
outputs
=>
<
Source
>[
...
super
.
outputs
,
...
super
.
outputs
,
const
Source
.
pattern
(
'{
PROJECT_DIR}/macos/Flutter/ephemeral
/App.framework/Versions/A/Resources/flutter_assets/kernel_blob.bin'
),
const
Source
.
pattern
(
'{
OUTPUT_DIR}
/App.framework/Versions/A/Resources/flutter_assets/kernel_blob.bin'
),
const
Source
.
pattern
(
'{
PROJECT_DIR}/macos/Flutter/ephemeral
/App.framework/Versions/A/Resources/flutter_assets/vm_snapshot_data'
),
const
Source
.
pattern
(
'{
OUTPUT_DIR}
/App.framework/Versions/A/Resources/flutter_assets/vm_snapshot_data'
),
const
Source
.
pattern
(
'{
PROJECT_DIR}/macos/Flutter/ephemeral
/App.framework/Versions/A/Resources/flutter_assets/isolate_snapshot_data'
),
const
Source
.
pattern
(
'{
OUTPUT_DIR}
/App.framework/Versions/A/Resources/flutter_assets/isolate_snapshot_data'
),
];
];
}
}
...
...
packages/flutter_tools/lib/src/commands/assemble.dart
View file @
55a1ba76
...
@@ -54,6 +54,10 @@ class AssembleCommand extends FlutterCommand {
...
@@ -54,6 +54,10 @@ class AssembleCommand extends FlutterCommand {
'separated file containing all outputs used will be written after a build.'
'separated file containing all outputs used will be written after a build.'
' This file is not included as a build input or output. This file is not'
' This file is not included as a build input or output. This file is not'
' written if the build fails for any reason.'
);
' written if the build fails for any reason.'
);
argParser
.
addOption
(
'output'
,
abbr:
'o'
,
help:
'A directory where output '
'files will be written. Must be either absolute or relative from the '
'root of the current Flutter project.'
,
);
argParser
.
addOption
(
argParser
.
addOption
(
'resource-pool-size'
,
'resource-pool-size'
,
help:
'The maximum number of concurrent tasks the build system will run.'
help:
'The maximum number of concurrent tasks the build system will run.'
...
@@ -83,7 +87,16 @@ class AssembleCommand extends FlutterCommand {
...
@@ -83,7 +87,16 @@ class AssembleCommand extends FlutterCommand {
/// The environmental configuration for a build invocation.
/// The environmental configuration for a build invocation.
Environment
get
environment
{
Environment
get
environment
{
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
String
output
=
argResults
[
'output'
];
if
(
output
==
null
)
{
throwToolExit
(
'--output directory is required for assemble.'
);
}
// If path is relative, make it absolute from flutter project.
if
(
fs
.
path
.
isRelative
(
output
))
{
output
=
fs
.
path
.
join
(
flutterProject
.
directory
.
path
,
output
);
}
final
Environment
result
=
Environment
(
final
Environment
result
=
Environment
(
outputDir:
fs
.
directory
(
output
),
buildDir:
flutterProject
.
directory
buildDir:
flutterProject
.
directory
.
childDirectory
(
'.dart_tool'
)
.
childDirectory
(
'.dart_tool'
)
.
childDirectory
(
'flutter_build'
),
.
childDirectory
(
'flutter_build'
),
...
...
packages/flutter_tools/test/general.shard/build_system/build_system_test.dart
View file @
55a1ba76
...
@@ -92,6 +92,7 @@ void main() {
...
@@ -92,6 +92,7 @@ void main() {
testbed
=
Testbed
(
testbed
=
Testbed
(
setup:
()
{
setup:
()
{
environment
=
Environment
(
environment
=
Environment
(
outputDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
);
);
fs
.
file
(
'foo.dart'
)
fs
.
file
(
'foo.dart'
)
...
...
packages/flutter_tools/test/general.shard/build_system/filecache_test.dart
View file @
55a1ba76
...
@@ -18,6 +18,7 @@ void main() {
...
@@ -18,6 +18,7 @@ void main() {
testbed
=
Testbed
(
setup:
()
{
testbed
=
Testbed
(
setup:
()
{
fs
.
directory
(
'build'
).
createSync
();
fs
.
directory
(
'build'
).
createSync
();
environment
=
Environment
(
environment
=
Environment
(
outputDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
);
);
environment
.
buildDir
.
createSync
(
recursive:
true
);
environment
.
buildDir
.
createSync
(
recursive:
true
);
...
...
packages/flutter_tools/test/general.shard/build_system/source_test.dart
View file @
55a1ba76
...
@@ -21,7 +21,10 @@ void main() {
...
@@ -21,7 +21,10 @@ void main() {
setUp
(()
{
setUp
(()
{
testbed
=
Testbed
(
setup:
()
{
testbed
=
Testbed
(
setup:
()
{
fs
.
directory
(
'cache'
).
createSync
();
fs
.
directory
(
'cache'
).
createSync
();
final
Directory
outputs
=
fs
.
directory
(
'outputs'
)
..
createSync
();
environment
=
Environment
(
environment
=
Environment
(
outputDir:
outputs
,
projectDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
buildDir:
fs
.
directory
(
'build'
),
buildDir:
fs
.
directory
(
'build'
),
);
);
...
@@ -45,6 +48,15 @@ void main() {
...
@@ -45,6 +48,15 @@ void main() {
expect
(
visitor
.
sources
.
single
.
path
,
fs
.
path
.
absolute
(
'foo'
));
expect
(
visitor
.
sources
.
single
.
path
,
fs
.
path
.
absolute
(
'foo'
));
}));
}));
test
(
'can substitute {OUTPUT_DIR}/foo'
,
()
=>
testbed
.
run
(()
{
fs
.
file
(
'foo'
).
createSync
();
const
Source
fooSource
=
Source
.
pattern
(
'{OUTPUT_DIR}/foo'
);
fooSource
.
accept
(
visitor
);
expect
(
visitor
.
sources
.
single
.
path
,
fs
.
path
.
absolute
(
fs
.
path
.
join
(
'outputs'
,
'foo'
)));
}));
test
(
'can substitute {BUILD_DIR}/bar'
,
()
=>
testbed
.
run
(()
{
test
(
'can substitute {BUILD_DIR}/bar'
,
()
=>
testbed
.
run
(()
{
final
String
path
=
fs
.
path
.
join
(
environment
.
buildDir
.
path
,
'bar'
);
final
String
path
=
fs
.
path
.
join
(
environment
.
buildDir
.
path
,
'bar'
);
fs
.
file
(
path
).
createSync
();
fs
.
file
(
path
).
createSync
();
...
...
packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart
View file @
55a1ba76
...
@@ -17,6 +17,7 @@ void main() {
...
@@ -17,6 +17,7 @@ void main() {
setUp
(()
{
setUp
(()
{
testbed
=
Testbed
(
setup:
()
{
testbed
=
Testbed
(
setup:
()
{
environment
=
Environment
(
environment
=
Environment
(
outputDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
);
);
fs
.
file
(
fs
.
path
.
join
(
'packages'
,
'flutter_tools'
,
'lib'
,
'src'
,
fs
.
file
(
fs
.
path
.
join
(
'packages'
,
'flutter_tools'
,
'lib'
,
'src'
,
...
@@ -71,6 +72,7 @@ flutter:
...
@@ -71,6 +72,7 @@ flutter:
..
writeAsStringSync
(
'name: foo
\n
dependencies:
\n
foo: any
\n
'
);
..
writeAsStringSync
(
'name: foo
\n
dependencies:
\n
foo: any
\n
'
);
await
const
FlutterPlugins
().
build
(<
File
>[],
Environment
(
await
const
FlutterPlugins
().
build
(<
File
>[],
Environment
(
outputDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
));
));
...
...
packages/flutter_tools/test/general.shard/build_system/targets/dart_test.dart
View file @
55a1ba76
...
@@ -39,6 +39,7 @@ void main() {
...
@@ -39,6 +39,7 @@ void main() {
mockProcessManager
=
MockProcessManager
();
mockProcessManager
=
MockProcessManager
();
testbed
=
Testbed
(
setup:
()
{
testbed
=
Testbed
(
setup:
()
{
androidEnvironment
=
Environment
(
androidEnvironment
=
Environment
(
outputDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
defines:
<
String
,
String
>{
defines:
<
String
,
String
>{
kBuildMode:
getNameForBuildMode
(
BuildMode
.
profile
),
kBuildMode:
getNameForBuildMode
(
BuildMode
.
profile
),
...
@@ -46,6 +47,7 @@ void main() {
...
@@ -46,6 +47,7 @@ void main() {
}
}
);
);
iosEnvironment
=
Environment
(
iosEnvironment
=
Environment
(
outputDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
defines:
<
String
,
String
>{
defines:
<
String
,
String
>{
kBuildMode:
getNameForBuildMode
(
BuildMode
.
profile
),
kBuildMode:
getNameForBuildMode
(
BuildMode
.
profile
),
...
@@ -158,6 +160,7 @@ flutter_tools:lib/''');
...
@@ -158,6 +160,7 @@ flutter_tools:lib/''');
});
});
await
const
KernelSnapshot
().
build
(<
File
>[],
Environment
(
await
const
KernelSnapshot
().
build
(<
File
>[],
Environment
(
outputDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
defines:
<
String
,
String
>{
defines:
<
String
,
String
>{
kBuildMode:
'debug'
,
kBuildMode:
'debug'
,
...
...
packages/flutter_tools/test/general.shard/build_system/targets/linux_test.dart
View file @
55a1ba76
...
@@ -31,6 +31,7 @@ void main() {
...
@@ -31,6 +31,7 @@ void main() {
testbed
=
Testbed
(
setup:
()
{
testbed
=
Testbed
(
setup:
()
{
Cache
.
flutterRoot
=
''
;
Cache
.
flutterRoot
=
''
;
environment
=
Environment
(
environment
=
Environment
(
outputDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
);
);
fs
.
file
(
'bin/cache/artifacts/engine/linux-x64/libflutter_linux_glfw.so'
).
createSync
(
recursive:
true
);
fs
.
file
(
'bin/cache/artifacts/engine/linux-x64/libflutter_linux_glfw.so'
).
createSync
(
recursive:
true
);
...
...
packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart
View file @
55a1ba76
...
@@ -21,7 +21,7 @@ import '../../../src/common.dart';
...
@@ -21,7 +21,7 @@ import '../../../src/common.dart';
import
'../../../src/testbed.dart'
;
import
'../../../src/testbed.dart'
;
const
String
_kInputPrefix
=
'bin/cache/artifacts/engine/darwin-x64/FlutterMacOS.framework'
;
const
String
_kInputPrefix
=
'bin/cache/artifacts/engine/darwin-x64/FlutterMacOS.framework'
;
const
String
_kOutputPrefix
=
'
macos/Flutter/ephemeral/
FlutterMacOS.framework'
;
const
String
_kOutputPrefix
=
'FlutterMacOS.framework'
;
final
List
<
File
>
inputs
=
<
File
>[
final
List
<
File
>
inputs
=
<
File
>[
fs
.
file
(
'
$_kInputPrefix
/FlutterMacOS'
),
fs
.
file
(
'
$_kInputPrefix
/FlutterMacOS'
),
...
@@ -68,6 +68,7 @@ void main() {
...
@@ -68,6 +68,7 @@ void main() {
'vmservice_io.dart'
)).
createSync
(
recursive:
true
);
'vmservice_io.dart'
)).
createSync
(
recursive:
true
);
environment
=
Environment
(
environment
=
Environment
(
outputDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
defines:
<
String
,
String
>{
defines:
<
String
,
String
>{
kBuildMode:
'debug'
,
kBuildMode:
'debug'
,
...
@@ -126,13 +127,11 @@ void main() {
...
@@ -126,13 +127,11 @@ void main() {
'isolate_snapshot.bin'
)).
createSync
(
recursive:
true
);
'isolate_snapshot.bin'
)).
createSync
(
recursive:
true
);
fs
.
file
(
fs
.
path
.
join
(
environment
.
buildDir
.
path
,
'App.framework'
,
'App'
))
fs
.
file
(
fs
.
path
.
join
(
environment
.
buildDir
.
path
,
'App.framework'
,
'App'
))
..
createSync
(
recursive:
true
);
..
createSync
(
recursive:
true
);
final
String
frameworkPath
=
fs
.
path
.
join
(
environment
.
projectDir
.
path
,
'macos'
,
'Flutter'
,
'ephemeral'
,
'App.framework'
);
final
String
inputKernel
=
fs
.
path
.
join
(
environment
.
buildDir
.
path
,
'app.dill'
);
final
String
inputKernel
=
fs
.
path
.
join
(
environment
.
buildDir
.
path
,
'app.dill'
);
fs
.
directory
(
frameworkPath
).
createSync
(
recursive:
true
);
final
String
outputKernel
=
fs
.
path
.
join
(
'App.framework'
,
'Versions'
,
'A'
,
'Resources'
,
final
String
outputKernel
=
fs
.
path
.
join
(
frameworkPath
,
'Versions'
,
'A'
,
'Resources'
,
'flutter_assets'
,
'kernel_blob.bin'
);
'flutter_assets'
,
'kernel_blob.bin'
);
final
String
outputPlist
=
fs
.
path
.
join
(
frameworkPath
,
'Versions'
,
'A'
,
'Resources'
,
final
String
outputPlist
=
fs
.
path
.
join
(
'App.framework'
,
'Versions'
,
'A'
,
'Resources'
,
'Info.plist'
);
'Info.plist'
);
fs
.
file
(
inputKernel
)
fs
.
file
(
inputKernel
)
..
createSync
(
recursive:
true
)
..
createSync
(
recursive:
true
)
...
@@ -151,14 +150,11 @@ void main() {
...
@@ -151,14 +150,11 @@ void main() {
'isolate_snapshot.bin'
)).
createSync
(
recursive:
true
);
'isolate_snapshot.bin'
)).
createSync
(
recursive:
true
);
fs
.
file
(
fs
.
path
.
join
(
environment
.
buildDir
.
path
,
'App.framework'
,
'App'
))
fs
.
file
(
fs
.
path
.
join
(
environment
.
buildDir
.
path
,
'App.framework'
,
'App'
))
..
createSync
(
recursive:
true
);
..
createSync
(
recursive:
true
);
final
String
frameworkPath
=
fs
.
path
.
join
(
environment
.
projectDir
.
path
,
final
String
outputKernel
=
fs
.
path
.
join
(
'App.framework'
,
'Resources'
,
'macos'
,
'Flutter'
,
'ephemeral'
,
'App.framework'
);
fs
.
directory
(
frameworkPath
).
createSync
(
recursive:
true
);
final
String
outputKernel
=
fs
.
path
.
join
(
frameworkPath
,
'Resources'
,
'flutter_assets'
,
'kernel_blob.bin'
);
'flutter_assets'
,
'kernel_blob.bin'
);
final
String
precompiledVm
=
fs
.
path
.
join
(
frameworkPath
,
'Resources'
,
final
String
precompiledVm
=
fs
.
path
.
join
(
'App.framework'
,
'Resources'
,
'flutter_assets'
,
'vm_snapshot_data'
);
'flutter_assets'
,
'vm_snapshot_data'
);
final
String
precompiledIsolate
=
fs
.
path
.
join
(
frameworkPath
,
'Resources'
,
final
String
precompiledIsolate
=
fs
.
path
.
join
(
'App.framework'
,
'Resources'
,
'flutter_assets'
,
'isolate_snapshot_data'
);
'flutter_assets'
,
'isolate_snapshot_data'
);
await
const
ProfileMacOSBundleFlutterAssets
().
build
(<
File
>[],
environment
..
defines
[
kBuildMode
]
=
'profile'
);
await
const
ProfileMacOSBundleFlutterAssets
().
build
(<
File
>[],
environment
..
defines
[
kBuildMode
]
=
'profile'
);
...
...
packages/flutter_tools/test/general.shard/build_system/targets/windows_test.dart
View file @
55a1ba76
...
@@ -32,6 +32,7 @@ void main() {
...
@@ -32,6 +32,7 @@ void main() {
when
(
platform
.
pathSeparator
).
thenReturn
(
r'\'
);
when
(
platform
.
pathSeparator
).
thenReturn
(
r'\'
);
testbed
=
Testbed
(
setup:
()
{
testbed
=
Testbed
(
setup:
()
{
environment
=
Environment
(
environment
=
Environment
(
outputDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
projectDir:
fs
.
currentDirectory
,
);
);
fs
.
file
(
r'C:\bin\cache\artifacts\engine\windows-x64\flutter_export.h'
).
createSync
(
recursive:
true
);
fs
.
file
(
r'C:\bin\cache\artifacts\engine\windows-x64\flutter_export.h'
).
createSync
(
recursive:
true
);
...
...
packages/flutter_tools/test/general.shard/commands/assemble_test.dart
View file @
55a1ba76
...
@@ -36,12 +36,22 @@ void main() {
...
@@ -36,12 +36,22 @@ void main() {
return
BuildResult
(
success:
true
);
return
BuildResult
(
success:
true
);
});
});
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
AssembleCommand
());
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
AssembleCommand
());
await
commandRunner
.
run
(<
String
>[
'assemble'
,
'debug_macos_bundle_flutter_assets'
]);
await
commandRunner
.
run
(<
String
>[
'assemble'
,
'
-o Output'
,
'
debug_macos_bundle_flutter_assets'
]);
final
BufferLogger
bufferLogger
=
logger
;
final
BufferLogger
bufferLogger
=
logger
;
expect
(
bufferLogger
.
statusText
.
trim
(),
'build succeeded.'
);
expect
(
bufferLogger
.
statusText
.
trim
(),
'build succeeded.'
);
}));
}));
test
(
'Throws ToolExit if not provided with output'
,
()
=>
testbed
.
run
(()
async
{
when
(
mockBuildSystem
.
build
(
any
,
any
,
buildSystemConfig:
anyNamed
(
'buildSystemConfig'
)))
.
thenAnswer
((
Invocation
invocation
)
async
{
return
BuildResult
(
success:
true
);
});
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
AssembleCommand
());
expect
(
commandRunner
.
run
(<
String
>[
'assemble'
,
'debug_macos_bundle_flutter_assets'
]),
throwsA
(
isInstanceOf
<
ToolExit
>()));
}));
test
(
'Throws ToolExit if called with non-existent rule'
,
()
=>
testbed
.
run
(()
async
{
test
(
'Throws ToolExit if called with non-existent rule'
,
()
=>
testbed
.
run
(()
async
{
when
(
mockBuildSystem
.
build
(
any
,
any
,
buildSystemConfig:
anyNamed
(
'buildSystemConfig'
)))
when
(
mockBuildSystem
.
build
(
any
,
any
,
buildSystemConfig:
anyNamed
(
'buildSystemConfig'
)))
.
thenAnswer
((
Invocation
invocation
)
async
{
.
thenAnswer
((
Invocation
invocation
)
async
{
...
@@ -49,8 +59,9 @@ void main() {
...
@@ -49,8 +59,9 @@ void main() {
});
});
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
AssembleCommand
());
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
AssembleCommand
());
expect
(
commandRunner
.
run
(<
String
>[
'assemble'
,
'undefined'
]),
throwsA
(
isInstanceOf
<
ToolExit
>()));
expect
(
commandRunner
.
run
(<
String
>[
'assemble'
,
'
-o Output'
,
'
undefined'
]),
throwsA
(
isInstanceOf
<
ToolExit
>()));
}));
}));
test
(
'Only writes input and output files when the values change'
,
()
=>
testbed
.
run
(()
async
{
test
(
'Only writes input and output files when the values change'
,
()
=>
testbed
.
run
(()
async
{
when
(
mockBuildSystem
.
build
(
any
,
any
,
buildSystemConfig:
anyNamed
(
'buildSystemConfig'
)))
when
(
mockBuildSystem
.
build
(
any
,
any
,
buildSystemConfig:
anyNamed
(
'buildSystemConfig'
)))
.
thenAnswer
((
Invocation
invocation
)
async
{
.
thenAnswer
((
Invocation
invocation
)
async
{
...
@@ -62,7 +73,7 @@ void main() {
...
@@ -62,7 +73,7 @@ void main() {
});
});
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
AssembleCommand
());
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
AssembleCommand
());
await
commandRunner
.
run
(<
String
>[
'assemble'
,
'--build-outputs=outputs'
,
'--build-inputs=inputs'
,
'debug_macos_bundle_flutter_assets'
]);
await
commandRunner
.
run
(<
String
>[
'assemble'
,
'-
o Output'
,
'-
-build-outputs=outputs'
,
'--build-inputs=inputs'
,
'debug_macos_bundle_flutter_assets'
]);
final
File
inputs
=
fs
.
file
(
'inputs'
);
final
File
inputs
=
fs
.
file
(
'inputs'
);
final
File
outputs
=
fs
.
file
(
'outputs'
);
final
File
outputs
=
fs
.
file
(
'outputs'
);
...
@@ -72,7 +83,7 @@ void main() {
...
@@ -72,7 +83,7 @@ void main() {
final
DateTime
theDistantPast
=
DateTime
(
1991
,
8
,
23
);
final
DateTime
theDistantPast
=
DateTime
(
1991
,
8
,
23
);
inputs
.
setLastModifiedSync
(
theDistantPast
);
inputs
.
setLastModifiedSync
(
theDistantPast
);
outputs
.
setLastModifiedSync
(
theDistantPast
);
outputs
.
setLastModifiedSync
(
theDistantPast
);
await
commandRunner
.
run
(<
String
>[
'assemble'
,
'--build-outputs=outputs'
,
'--build-inputs=inputs'
,
'debug_macos_bundle_flutter_assets'
]);
await
commandRunner
.
run
(<
String
>[
'assemble'
,
'-
o Output'
,
'-
-build-outputs=outputs'
,
'--build-inputs=inputs'
,
'debug_macos_bundle_flutter_assets'
]);
expect
(
inputs
.
lastModifiedSync
(),
theDistantPast
);
expect
(
inputs
.
lastModifiedSync
(),
theDistantPast
);
expect
(
outputs
.
lastModifiedSync
(),
theDistantPast
);
expect
(
outputs
.
lastModifiedSync
(),
theDistantPast
);
...
@@ -85,7 +96,7 @@ void main() {
...
@@ -85,7 +96,7 @@ void main() {
inputFiles:
<
File
>[
fs
.
file
(
'foo'
),
fs
.
file
(
'fizz'
)..
createSync
()],
inputFiles:
<
File
>[
fs
.
file
(
'foo'
),
fs
.
file
(
'fizz'
)..
createSync
()],
outputFiles:
<
File
>[
fs
.
file
(
'bar'
),
fs
.
file
(
fs
.
path
.
join
(
'.dart_tool'
,
'fizz2'
))..
createSync
(
recursive:
true
)]);
outputFiles:
<
File
>[
fs
.
file
(
'bar'
),
fs
.
file
(
fs
.
path
.
join
(
'.dart_tool'
,
'fizz2'
))..
createSync
(
recursive:
true
)]);
});
});
await
commandRunner
.
run
(<
String
>[
'assemble'
,
'--build-outputs=outputs'
,
'--build-inputs=inputs'
,
'debug_macos_bundle_flutter_assets'
]);
await
commandRunner
.
run
(<
String
>[
'assemble'
,
'-
o Output'
,
'-
-build-outputs=outputs'
,
'--build-inputs=inputs'
,
'debug_macos_bundle_flutter_assets'
]);
expect
(
inputs
.
readAsStringSync
(),
contains
(
'foo'
));
expect
(
inputs
.
readAsStringSync
(),
contains
(
'foo'
));
expect
(
inputs
.
readAsStringSync
(),
contains
(
'fizz'
));
expect
(
inputs
.
readAsStringSync
(),
contains
(
'fizz'
));
...
...
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