-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(shorebird_cli): support local engine artifacts (#1524)
- Loading branch information
Showing
12 changed files
with
311 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// ignore_for_file: one_member_abstracts | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:path/path.dart' as p; | ||
import 'package:scoped/scoped.dart'; | ||
import 'package:shorebird_cli/src/process.dart'; | ||
import 'package:shorebird_cli/src/shorebird_env.dart'; | ||
|
||
/// All Flutter artifacts used explicitly by Shorebird. | ||
enum FlutterArtifact { | ||
/// The gen_snapshot executable. | ||
genSnapshot, | ||
|
||
/// The analyze_snapshot executable. | ||
analyzeSnapshot, | ||
} | ||
|
||
/// A reference to a [FlutterArtifacts] instance. | ||
final flutterArtifactsRef = create<FlutterArtifacts>( | ||
FlutterCachedArtifacts.new, | ||
); | ||
|
||
/// The [FlutterArtifacts] instance available in the current zone. | ||
FlutterArtifacts get flutterArtifacts => read(flutterArtifactsRef); | ||
|
||
/// {@template flutter_artifacts} | ||
/// A class that provides access to Flutter artifacts. | ||
/// {@endtemplate} | ||
abstract class FlutterArtifacts { | ||
/// Returns the path to the given [artifact]. | ||
String getArtifactPath({required FlutterArtifact artifact}); | ||
} | ||
|
||
/// {@template flutter_cached_artifacts} | ||
/// A class that provides access to cached Flutter artifacts. | ||
/// {@endtemplate} | ||
class FlutterCachedArtifacts implements FlutterArtifacts { | ||
/// {@macro flutter_cached_artifacts} | ||
const FlutterCachedArtifacts(); | ||
|
||
@override | ||
String getArtifactPath({ | ||
required FlutterArtifact artifact, | ||
}) { | ||
switch (artifact) { | ||
case FlutterArtifact.genSnapshot: | ||
return _genSnapshotFile.path; | ||
case FlutterArtifact.analyzeSnapshot: | ||
return _analyzeSnapshotFile.path; | ||
} | ||
} | ||
|
||
File get _genSnapshotFile { | ||
return File( | ||
p.join( | ||
shorebirdEnv.flutterDirectory.path, | ||
'bin', | ||
'cache', | ||
'artifacts', | ||
'engine', | ||
'ios-release', | ||
'gen_snapshot_arm64', | ||
), | ||
); | ||
} | ||
|
||
File get _analyzeSnapshotFile { | ||
return File( | ||
p.join( | ||
shorebirdEnv.flutterDirectory.path, | ||
'bin', | ||
'cache', | ||
'artifacts', | ||
'engine', | ||
'ios-release', | ||
'analyze_snapshot_arm64', | ||
), | ||
); | ||
} | ||
} | ||
|
||
/// {@template flutter_local_engine_artifacts} | ||
/// A class that provides access to locally built Flutter artifacts. | ||
/// {@endtemplate} | ||
class FlutterLocalEngineArtifacts implements FlutterArtifacts { | ||
/// {@macro flutter_local_engine_artifacts} | ||
const FlutterLocalEngineArtifacts(); | ||
|
||
@override | ||
String getArtifactPath({required FlutterArtifact artifact}) { | ||
switch (artifact) { | ||
case FlutterArtifact.genSnapshot: | ||
return _genSnapshotFile.path; | ||
case FlutterArtifact.analyzeSnapshot: | ||
return _analyzeSnapshotFile.path; | ||
} | ||
} | ||
|
||
File get _genSnapshotFile { | ||
return File( | ||
p.join( | ||
engineConfig.localEngineSrcPath!, | ||
'out', | ||
'ios_release', | ||
'clang_x64', | ||
'gen_snapshot_arm64', | ||
), | ||
); | ||
} | ||
|
||
File get _analyzeSnapshotFile { | ||
return File( | ||
p.join( | ||
engineConfig.localEngineSrcPath!, | ||
'out', | ||
'ios_release', | ||
'clang_x64', | ||
'analyze_snapshot_arm64', | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.