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
0e2f66e9
Unverified
Commit
0e2f66e9
authored
Mar 18, 2021
by
Jenn Magder
Committed by
GitHub
Mar 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parse engine src path from an absolute --local-engine (#78496)
parent
8364140e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
162 additions
and
41 deletions
+162
-41
local_engine.dart
packages/flutter_tools/lib/src/runner/local_engine.dart
+71
-41
local_engine_test.dart
...er_tools/test/general.shard/runner/local_engine_test.dart
+91
-0
No files found.
packages/flutter_tools/lib/src/runner/local_engine.dart
View file @
0e2f66e9
...
...
@@ -54,45 +54,8 @@ class LocalEngineLocator {
if
(
engineSourcePath
==
null
&&
localEngine
!=
null
)
{
try
{
final
PackageConfig
packageConfig
=
await
loadPackageConfigWithLogging
(
_fileSystem
.
file
(
// TODO(jonahwilliams): update to package_config
packagePath
??
_fileSystem
.
path
.
join
(
'.packages'
),
),
logger:
_logger
,
throwOnError:
false
,
);
// Skip if sky_engine is the version in bin/cache.
Uri
engineUri
=
packageConfig
[
kFlutterEnginePackageName
]?.
packageUriRoot
;
final
String
cachedPath
=
_fileSystem
.
path
.
join
(
_flutterRoot
,
'bin'
,
'cache'
,
'pkg'
,
kFlutterEnginePackageName
,
'lib'
);
if
(
engineUri
!=
null
&&
_fileSystem
.
identicalSync
(
cachedPath
,
engineUri
.
path
))
{
_logger
.
printTrace
(
'Local engine auto-detection sky_engine in
$packagePath
is the same version in bin/cache.'
);
engineUri
=
null
;
}
// If sky_engine is specified and the engineSourcePath not set, try to
// determine the engineSourcePath by sky_engine setting. A typical engine Uri
// looks like:
// file://flutter-engine-local-path/src/out/host_debug_unopt/gen/dart-pkg/sky_engine/lib/
if
(
engineUri
?.
path
!=
null
)
{
engineSourcePath
=
_fileSystem
.
directory
(
engineUri
.
path
)
?.
parent
?.
parent
?.
parent
?.
parent
?.
parent
?.
parent
?.
path
;
if
(
engineSourcePath
!=
null
&&
(
engineSourcePath
==
_fileSystem
.
path
.
dirname
(
engineSourcePath
)
||
engineSourcePath
.
isEmpty
))
{
engineSourcePath
=
null
;
throwToolExit
(
_userMessages
.
runnerNoEngineSrcDir
(
kFlutterEnginePackageName
,
kFlutterEngineEnvironmentVariableName
,
),
exitCode:
2
,
);
}
}
engineSourcePath
=
_findEngineSourceByLocalEngine
(
localEngine
);
engineSourcePath
??=
await
_findEngineSourceByPackageConfig
(
packagePath
);
}
on
FileSystemException
catch
(
e
)
{
_logger
.
printTrace
(
'Local engine auto-detection file exception:
$e
'
);
engineSourcePath
=
null
;
...
...
@@ -113,12 +76,79 @@ class LocalEngineLocator {
if
(
engineSourcePath
!=
null
)
{
_logger
.
printTrace
(
'Local engine source at
$engineSourcePath
'
);
return
_findEngineBuildPath
(
localEngine
,
engineSourcePath
);
}
else
if
(
localEngine
!=
null
)
{
_logger
.
printTrace
(
'Could not find engine source for
$localEngine
, skipping'
);
}
if
(
localEngine
!=
null
)
{
throwToolExit
(
_userMessages
.
runnerNoEngineSrcDir
(
kFlutterEnginePackageName
,
kFlutterEngineEnvironmentVariableName
,
),
exitCode:
2
,
);
}
return
null
;
}
String
_findEngineSourceByLocalEngine
(
String
localEngine
)
{
// When the local engine is an absolute path to a variant inside the
// out directory, parse the engine source.
// --local-engine /path/to/cache/builder/src/out/host_debug_unopt
if
(
_fileSystem
.
path
.
isAbsolute
(
localEngine
))
{
final
Directory
localEngineDirectory
=
_fileSystem
.
directory
(
localEngine
);
final
Directory
outDirectory
=
localEngineDirectory
?.
parent
;
final
Directory
srcDirectory
=
outDirectory
?.
parent
;
if
(
localEngineDirectory
.
existsSync
()
&&
outDirectory
?.
basename
==
'out'
&&
srcDirectory
?.
basename
==
'src'
)
{
_logger
.
printTrace
(
'Parsed engine source from local engine as
${srcDirectory.path}
.'
);
return
srcDirectory
.
path
;
}
}
return
null
;
}
Future
<
String
>
_findEngineSourceByPackageConfig
(
String
packagePath
)
async
{
final
PackageConfig
packageConfig
=
await
loadPackageConfigWithLogging
(
_fileSystem
.
file
(
// TODO(jonahwilliams): update to package_config
packagePath
??
_fileSystem
.
path
.
join
(
'.packages'
),
),
logger:
_logger
,
throwOnError:
false
,
);
// Skip if sky_engine is the version in bin/cache.
Uri
engineUri
=
packageConfig
[
kFlutterEnginePackageName
]?.
packageUriRoot
;
final
String
cachedPath
=
_fileSystem
.
path
.
join
(
_flutterRoot
,
'bin'
,
'cache'
,
'pkg'
,
kFlutterEnginePackageName
,
'lib'
);
if
(
engineUri
!=
null
&&
_fileSystem
.
identicalSync
(
cachedPath
,
engineUri
.
path
))
{
_logger
.
printTrace
(
'Local engine auto-detection sky_engine in
$packagePath
is the same version in bin/cache.'
);
engineUri
=
null
;
}
// If sky_engine is specified and the engineSourcePath not set, try to
// determine the engineSourcePath by sky_engine setting. A typical engine Uri
// looks like:
// file://flutter-engine-local-path/src/out/host_debug_unopt/gen/dart-pkg/sky_engine/lib/
String
engineSourcePath
;
if
(
engineUri
?.
path
!=
null
)
{
engineSourcePath
=
_fileSystem
.
directory
(
engineUri
.
path
)
?.
parent
?.
parent
?.
parent
?.
parent
?.
parent
?.
parent
?.
path
;
if
(
engineSourcePath
!=
null
&&
(
engineSourcePath
==
_fileSystem
.
path
.
dirname
(
engineSourcePath
)
||
engineSourcePath
.
isEmpty
))
{
engineSourcePath
=
null
;
throwToolExit
(
_userMessages
.
runnerNoEngineSrcDir
(
kFlutterEnginePackageName
,
kFlutterEngineEnvironmentVariableName
,
),
exitCode:
2
,
);
}
}
return
engineSourcePath
;
}
// Determine the host engine directory associated with the local engine:
// Strip '_sim_' since there are no host simulator builds.
String
_getHostEngineBasename
(
String
localEngineBasename
)
{
...
...
packages/flutter_tools/test/general.shard/runner/local_engine_test.dart
View file @
0e2f66e9
...
...
@@ -96,6 +96,79 @@ void main() {
expect
(
logger
.
traceText
,
contains
(
'Local engine source at /arbitrary/engine/src'
));
});
testWithoutContext
(
'works if --local-engine is specified and --local-engine-src-path '
'is determined by --local-engine'
,
()
async
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
Directory
localEngine
=
fileSystem
.
directory
(
'
$kArbitraryEngineRoot
/src/out/ios_debug/'
)
..
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'
$kArbitraryEngineRoot
/src/out/host_debug/'
).
createSync
(
recursive:
true
);
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
LocalEngineLocator
localEngineLocator
=
LocalEngineLocator
(
fileSystem:
fileSystem
,
flutterRoot:
'flutter/flutter'
,
logger:
logger
,
userMessages:
UserMessages
(),
platform:
FakePlatform
(
environment:
<
String
,
String
>{}),
);
expect
(
await
localEngineLocator
.
findEnginePath
(
null
,
localEngine
.
path
,
null
),
matchesEngineBuildPaths
(
hostEngine:
'/arbitrary/engine/src/out/host_debug'
,
targetEngine:
'/arbitrary/engine/src/out/ios_debug'
,
),
);
expect
(
logger
.
traceText
,
contains
(
'Parsed engine source from local engine as /arbitrary/engine/src'
));
expect
(
logger
.
traceText
,
contains
(
'Local engine source at /arbitrary/engine/src'
));
});
testWithoutContext
(
'works if local engine is host engine'
,
()
async
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
Directory
localEngine
=
fileSystem
.
directory
(
'
$kArbitraryEngineRoot
/src/out/host_debug/'
)
..
createSync
(
recursive:
true
);
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
LocalEngineLocator
localEngineLocator
=
LocalEngineLocator
(
fileSystem:
fileSystem
,
flutterRoot:
'flutter/flutter'
,
logger:
logger
,
userMessages:
UserMessages
(),
platform:
FakePlatform
(
environment:
<
String
,
String
>{}),
);
expect
(
await
localEngineLocator
.
findEnginePath
(
null
,
localEngine
.
path
,
null
),
matchesEngineBuildPaths
(
hostEngine:
'/arbitrary/engine/src/out/host_debug'
,
targetEngine:
'/arbitrary/engine/src/out/host_debug'
,
),
);
expect
(
logger
.
traceText
,
contains
(
'Local engine source at /arbitrary/engine/src'
));
});
testWithoutContext
(
'fails if host_debug does not exist'
,
()
async
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
Directory
localEngine
=
fileSystem
.
directory
(
'
$kArbitraryEngineRoot
/src/out/ios_debug/'
)
..
createSync
(
recursive:
true
);
final
LocalEngineLocator
localEngineLocator
=
LocalEngineLocator
(
fileSystem:
fileSystem
,
flutterRoot:
'flutter/flutter'
,
logger:
BufferLogger
.
test
(),
userMessages:
UserMessages
(),
platform:
FakePlatform
(
environment:
<
String
,
String
>{}),
);
await
expectToolExitLater
(
localEngineLocator
.
findEnginePath
(
null
,
localEngine
.
path
,
null
),
contains
(
'No Flutter engine build found at /arbitrary/engine/src/out/host_debug'
),
);
});
testWithoutContext
(
'works if --local-engine is specified and --local-engine-src-path '
'is determined by flutter root'
,
()
async
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
...
...
@@ -128,6 +201,24 @@ void main() {
);
expect
(
logger
.
traceText
,
contains
(
'Local engine source at flutter/engine/src'
));
});
testWithoutContext
(
'fails if --local-engine is specified and --local-engine-src-path '
'cannot be determined'
,
()
async
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
LocalEngineLocator
localEngineLocator
=
LocalEngineLocator
(
fileSystem:
fileSystem
,
flutterRoot:
'flutter/flutter'
,
logger:
BufferLogger
.
test
(),
userMessages:
UserMessages
(),
platform:
FakePlatform
(
environment:
<
String
,
String
>{}),
);
await
expectToolExitLater
(
localEngineLocator
.
findEnginePath
(
null
,
'/path/to/nothing'
,
null
),
contains
(
'Unable to detect local Flutter engine src directory'
),
);
});
}
Matcher
matchesEngineBuildPaths
(
{
...
...
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