mirror of
https://github.com/flutter/flutter
synced 2024-10-13 03:32:55 +00:00
Reland "AOT support for Linux Desktop I: switch Linux builds to assemble (#41612)" (#42030)" (#42038)
This reverts commit 142a8630ec
.
This commit is contained in:
parent
fa4d31b311
commit
3af16678ad
|
@ -17,7 +17,6 @@ Future<void> main(List<String> arguments) async {
|
||||||
final String flutterEngine = Platform.environment['FLUTTER_ENGINE'];
|
final String flutterEngine = Platform.environment['FLUTTER_ENGINE'];
|
||||||
final String localEngine = Platform.environment['LOCAL_ENGINE'];
|
final String localEngine = Platform.environment['LOCAL_ENGINE'];
|
||||||
final String flutterRoot = Platform.environment['FLUTTER_ROOT'];
|
final String flutterRoot = Platform.environment['FLUTTER_ROOT'];
|
||||||
|
|
||||||
Directory.current = projectDirectory;
|
Directory.current = projectDirectory;
|
||||||
|
|
||||||
if (localEngine != null && !localEngine.contains(buildMode)) {
|
if (localEngine != null && !localEngine.contains(buildMode)) {
|
||||||
|
@ -33,22 +32,34 @@ or
|
||||||
''');
|
''');
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
final String flutterExecutable = path.join(
|
||||||
|
flutterRoot, 'bin', Platform.isWindows ? 'flutter.bat' : 'flutter');
|
||||||
|
|
||||||
String cacheDirectory;
|
if (targetPlatform == 'linux-x64') {
|
||||||
switch (targetPlatform) {
|
// TODO(jonahwilliams): currently all builds are debug builds. Remove the
|
||||||
case 'linux-x64':
|
// hardcoded mode when profile and release support is added.
|
||||||
cacheDirectory = 'linux/flutter/ephemeral';
|
final ProcessResult unpackResult = await Process.run(
|
||||||
break;
|
flutterExecutable,
|
||||||
case 'windows-x64':
|
<String>[
|
||||||
cacheDirectory = 'windows/flutter/ephemeral';
|
'--suppress-analytics',
|
||||||
break;
|
'--verbose',
|
||||||
default:
|
if (flutterEngine != null) '--local-engine-src-path=$flutterEngine',
|
||||||
stderr.write('Unsupported target platform $targetPlatform');
|
if (localEngine != null) '--local-engine=$localEngine',
|
||||||
|
'assemble',
|
||||||
|
'-dTargetPlatform=$targetPlatform',
|
||||||
|
'-dBuildMode=debug',
|
||||||
|
'-dTargetFile=$flutterTarget',
|
||||||
|
'--output=build',
|
||||||
|
'debug_bundle_linux_assets',
|
||||||
|
]);
|
||||||
|
if (unpackResult.exitCode != 0) {
|
||||||
|
stderr.write(unpackResult.stderr);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String flutterExecutable = path.join(
|
const String cacheDirectory = 'windows/flutter/ephemeral';
|
||||||
flutterRoot, 'bin', Platform.isWindows ? 'flutter.bat' : 'flutter');
|
|
||||||
final ProcessResult unpackResult = await Process.run(
|
final ProcessResult unpackResult = await Process.run(
|
||||||
flutterExecutable,
|
flutterExecutable,
|
||||||
<String>[
|
<String>[
|
||||||
|
|
|
@ -2,18 +2,25 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'package:pool/pool.dart';
|
||||||
|
|
||||||
import '../../artifacts.dart';
|
import '../../artifacts.dart';
|
||||||
|
import '../../asset.dart';
|
||||||
import '../../base/file_system.dart';
|
import '../../base/file_system.dart';
|
||||||
import '../../build_info.dart';
|
import '../../build_info.dart';
|
||||||
|
import '../../devfs.dart';
|
||||||
import '../../globals.dart';
|
import '../../globals.dart';
|
||||||
import '../build_system.dart';
|
import '../build_system.dart';
|
||||||
|
import '../exceptions.dart';
|
||||||
|
import 'assets.dart';
|
||||||
|
import 'dart.dart';
|
||||||
|
|
||||||
/// Copies the Linux desktop embedding files to the copy directory.
|
/// Copies the Linux desktop embedding files to the copy directory.
|
||||||
class UnpackLinux extends Target {
|
class UnpackLinuxDebug extends Target {
|
||||||
const UnpackLinux();
|
const UnpackLinuxDebug();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get name => 'unpack_linux';
|
String get name => 'unpack_linux_debug';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Source> get inputs => const <Source>[
|
List<Source> get inputs => const <Source>[
|
||||||
|
@ -23,12 +30,12 @@ class UnpackLinux extends Target {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Source> get outputs => const <Source>[
|
List<Source> get outputs => const <Source>[
|
||||||
Source.pattern('{PROJECT_DIR}/linux/flutter/libflutter_linux_glfw.so'),
|
Source.pattern('{PROJECT_DIR}/linux/flutter/ephemeral/libflutter_linux_glfw.so'),
|
||||||
Source.pattern('{PROJECT_DIR}/linux/flutter/flutter_export.h'),
|
Source.pattern('{PROJECT_DIR}/linux/flutter/ephemeral/flutter_export.h'),
|
||||||
Source.pattern('{PROJECT_DIR}/linux/flutter/flutter_messenger.h'),
|
Source.pattern('{PROJECT_DIR}/linux/flutter/ephemeral/flutter_messenger.h'),
|
||||||
Source.pattern('{PROJECT_DIR}/linux/flutter/flutter_plugin_registrar.h'),
|
Source.pattern('{PROJECT_DIR}/linux/flutter/ephemeral/flutter_plugin_registrar.h'),
|
||||||
Source.pattern('{PROJECT_DIR}/linux/flutter/flutter_glfw.h'),
|
Source.pattern('{PROJECT_DIR}/linux/flutter/ephemeral/flutter_glfw.h'),
|
||||||
Source.pattern('{PROJECT_DIR}/linux/flutter/icudtl.dat'),
|
Source.pattern('{PROJECT_DIR}/linux/flutter/ephemeral/icudtl.dat'),
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -44,6 +51,7 @@ class UnpackLinux extends Target {
|
||||||
environment.projectDir.path,
|
environment.projectDir.path,
|
||||||
'linux',
|
'linux',
|
||||||
'flutter',
|
'flutter',
|
||||||
|
'ephemeral',
|
||||||
fs.path.relative(input.path, from: basePath),
|
fs.path.relative(input.path, from: basePath),
|
||||||
);
|
);
|
||||||
final File destinationFile = fs.file(outputPath);
|
final File destinationFile = fs.file(outputPath);
|
||||||
|
@ -54,3 +62,72 @@ class UnpackLinux extends Target {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a debug bundle for the Linux desktop target.
|
||||||
|
class DebugBundleLinuxAssets extends Target {
|
||||||
|
const DebugBundleLinuxAssets();
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get name => 'debug_bundle_linux_assets';
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Target> get dependencies => const <Target>[
|
||||||
|
KernelSnapshot(),
|
||||||
|
UnpackLinuxDebug(),
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Source> get inputs => const <Source>[
|
||||||
|
Source.pattern('{BUILD_DIR}/app.dill'),
|
||||||
|
Source.pattern('{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/linux.dart'),
|
||||||
|
Source.behavior(AssetOutputBehavior('flutter_assets')),
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Source> get outputs => const <Source>[
|
||||||
|
Source.behavior(AssetOutputBehavior('flutter_assets')),
|
||||||
|
Source.pattern('{OUTPUT_DIR}/flutter_assets/kernel_blob.bin'),
|
||||||
|
Source.pattern('{OUTPUT_DIR}/flutter_assets/AssetManifest.json'),
|
||||||
|
Source.pattern('{OUTPUT_DIR}/flutter_assets/FontManifest.json'),
|
||||||
|
Source.pattern('{OUTPUT_DIR}/flutter_assets/LICENSE'),
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> build(Environment environment) async {
|
||||||
|
if (environment.defines[kBuildMode] == null) {
|
||||||
|
throw MissingDefineException(kBuildMode, 'debug_bundle_linux_assets');
|
||||||
|
}
|
||||||
|
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||||
|
final Directory outputDirectory = environment.outputDir
|
||||||
|
.childDirectory('flutter_assets');
|
||||||
|
if (!outputDirectory.existsSync()) {
|
||||||
|
outputDirectory.createSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only copy the kernel blob in debug mode.
|
||||||
|
if (buildMode == BuildMode.debug) {
|
||||||
|
environment.buildDir.childFile('app.dill')
|
||||||
|
.copySync(outputDirectory.childFile('kernel_blob.bin').path);
|
||||||
|
}
|
||||||
|
|
||||||
|
final AssetBundle assetBundle = AssetBundleFactory.instance.createBundle();
|
||||||
|
await assetBundle.build();
|
||||||
|
final Pool pool = Pool(kMaxOpenFiles);
|
||||||
|
await Future.wait<void>(
|
||||||
|
assetBundle.entries.entries.map<Future<void>>((MapEntry<String, DevFSContent> entry) async {
|
||||||
|
final PoolResource resource = await pool.request();
|
||||||
|
try {
|
||||||
|
final File file = fs.file(fs.path.join(outputDirectory.path, entry.key));
|
||||||
|
file.parent.createSync(recursive: true);
|
||||||
|
final DevFSContent content = entry.value;
|
||||||
|
if (content is DevFSFileContent && content.file is File) {
|
||||||
|
await (content.file as File).copy(file.path);
|
||||||
|
} else {
|
||||||
|
await file.writeAsBytes(await entry.value.contentsAsBytes());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
resource.release();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ import '../runner/flutter_command.dart';
|
||||||
|
|
||||||
/// All currently implemented targets.
|
/// All currently implemented targets.
|
||||||
const List<Target> _kDefaultTargets = <Target>[
|
const List<Target> _kDefaultTargets = <Target>[
|
||||||
UnpackLinux(),
|
|
||||||
UnpackWindows(),
|
UnpackWindows(),
|
||||||
CopyAssets(),
|
CopyAssets(),
|
||||||
KernelSnapshot(),
|
KernelSnapshot(),
|
||||||
|
@ -32,6 +31,7 @@ const List<Target> _kDefaultTargets = <Target>[
|
||||||
DebugMacOSBundleFlutterAssets(),
|
DebugMacOSBundleFlutterAssets(),
|
||||||
ProfileMacOSBundleFlutterAssets(),
|
ProfileMacOSBundleFlutterAssets(),
|
||||||
ReleaseMacOSBundleFlutterAssets(),
|
ReleaseMacOSBundleFlutterAssets(),
|
||||||
|
DebugBundleLinuxAssets(),
|
||||||
WebReleaseBundle(),
|
WebReleaseBundle(),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class AssembleCommand extends FlutterCommand {
|
||||||
final Target result = _kDefaultTargets
|
final Target result = _kDefaultTargets
|
||||||
.firstWhere((Target target) => target.name == name, orElse: () => null);
|
.firstWhere((Target target) => target.name == name, orElse: () => null);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
throwToolExit('No target named "{target.name} defined."');
|
throwToolExit('No target named "$name" defined.');
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
import '../artifacts.dart';
|
import '../artifacts.dart';
|
||||||
import '../base/common.dart';
|
import '../base/common.dart';
|
||||||
import '../base/file_system.dart';
|
import '../base/file_system.dart';
|
||||||
import '../base/process.dart';
|
|
||||||
import '../build_info.dart';
|
import '../build_info.dart';
|
||||||
import '../cache.dart';
|
import '../cache.dart';
|
||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
|
@ -13,26 +12,12 @@ import '../runner/flutter_command.dart';
|
||||||
|
|
||||||
/// The directory in the Flutter cache for each platform's artifacts.
|
/// The directory in the Flutter cache for each platform's artifacts.
|
||||||
const Map<TargetPlatform, String> flutterArtifactPlatformDirectory = <TargetPlatform, String>{
|
const Map<TargetPlatform, String> flutterArtifactPlatformDirectory = <TargetPlatform, String>{
|
||||||
TargetPlatform.linux_x64: 'linux-x64',
|
|
||||||
TargetPlatform.darwin_x64: 'darwin-x64',
|
|
||||||
TargetPlatform.windows_x64: 'windows-x64',
|
TargetPlatform.windows_x64: 'windows-x64',
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(jonahwilliams): this should come from a configuration in each build
|
// TODO(jonahwilliams): this should come from a configuration in each build
|
||||||
// directory.
|
// directory.
|
||||||
const Map<TargetPlatform, List<String>> artifactFilesByPlatform = <TargetPlatform, List<String>>{
|
const Map<TargetPlatform, List<String>> artifactFilesByPlatform = <TargetPlatform, List<String>>{
|
||||||
TargetPlatform.linux_x64: <String>[
|
|
||||||
'libflutter_linux_glfw.so',
|
|
||||||
'flutter_export.h',
|
|
||||||
'flutter_messenger.h',
|
|
||||||
'flutter_plugin_registrar.h',
|
|
||||||
'flutter_glfw.h',
|
|
||||||
'icudtl.dat',
|
|
||||||
'cpp_client_wrapper_glfw/',
|
|
||||||
],
|
|
||||||
TargetPlatform.darwin_x64: <String>[
|
|
||||||
'FlutterMacOS.framework',
|
|
||||||
],
|
|
||||||
TargetPlatform.windows_x64: <String>[
|
TargetPlatform.windows_x64: <String>[
|
||||||
'flutter_windows.dll',
|
'flutter_windows.dll',
|
||||||
'flutter_windows.dll.exp',
|
'flutter_windows.dll.exp',
|
||||||
|
@ -52,7 +37,7 @@ class UnpackCommand extends FlutterCommand {
|
||||||
UnpackCommand() {
|
UnpackCommand() {
|
||||||
argParser.addOption(
|
argParser.addOption(
|
||||||
'target-platform',
|
'target-platform',
|
||||||
allowed: <String>['darwin-x64', 'linux-x64', 'windows-x64'],
|
allowed: <String>['windows-x64'],
|
||||||
);
|
);
|
||||||
argParser.addOption('cache-dir',
|
argParser.addOption('cache-dir',
|
||||||
help: 'Location to output platform specific artifacts.');
|
help: 'Location to output platform specific artifacts.');
|
||||||
|
@ -74,15 +59,9 @@ class UnpackCommand extends FlutterCommand {
|
||||||
};
|
};
|
||||||
final TargetPlatform targetPlatform = getTargetPlatformForName(argResults['target-platform']);
|
final TargetPlatform targetPlatform = getTargetPlatformForName(argResults['target-platform']);
|
||||||
switch (targetPlatform) {
|
switch (targetPlatform) {
|
||||||
case TargetPlatform.darwin_x64:
|
|
||||||
result.add(DevelopmentArtifact.macOS);
|
|
||||||
break;
|
|
||||||
case TargetPlatform.windows_x64:
|
case TargetPlatform.windows_x64:
|
||||||
result.add(DevelopmentArtifact.windows);
|
result.add(DevelopmentArtifact.windows);
|
||||||
break;
|
break;
|
||||||
case TargetPlatform.linux_x64:
|
|
||||||
result.add(DevelopmentArtifact.linux);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -134,15 +113,9 @@ class ArtifactUnpacker {
|
||||||
bool copyCachedArtifacts(String targetDirectory) {
|
bool copyCachedArtifacts(String targetDirectory) {
|
||||||
String cacheStamp;
|
String cacheStamp;
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case TargetPlatform.linux_x64:
|
|
||||||
cacheStamp = 'linux-sdk';
|
|
||||||
break;
|
|
||||||
case TargetPlatform.windows_x64:
|
case TargetPlatform.windows_x64:
|
||||||
cacheStamp = 'windows-sdk';
|
cacheStamp = 'windows-sdk';
|
||||||
break;
|
break;
|
||||||
case TargetPlatform.darwin_x64:
|
|
||||||
cacheStamp = 'macos-sdk';
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throwToolExit('Unsupported target platform: $platform');
|
throwToolExit('Unsupported target platform: $platform');
|
||||||
}
|
}
|
||||||
|
@ -208,27 +181,17 @@ class ArtifactUnpacker {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.directory(targetDirectory).createSync(recursive: true);
|
fs.directory(targetDirectory).createSync(recursive: true);
|
||||||
|
for (final String entityName in artifactFiles) {
|
||||||
// On macOS, delete the existing framework if any before copying in the
|
final String sourcePath = fs.path.join(sourceDirectory, entityName);
|
||||||
// new one, since it's a directory. On the other platforms, where files
|
final String targetPath = fs.path.join(targetDirectory, entityName);
|
||||||
// are just individual files, this isn't necessary since copying over
|
if (entityName.endsWith('/')) {
|
||||||
// existing files will do the right thing.
|
copyDirectorySync(
|
||||||
if (platform == TargetPlatform.darwin_x64) {
|
fs.directory(sourcePath),
|
||||||
_copyMacOSFramework(
|
fs.directory(targetPath),
|
||||||
fs.path.join(sourceDirectory, artifactFiles[0]), targetDirectory);
|
);
|
||||||
} else {
|
} else {
|
||||||
for (final String entityName in artifactFiles) {
|
fs.file(sourcePath)
|
||||||
final String sourcePath = fs.path.join(sourceDirectory, entityName);
|
.copySync(fs.path.join(targetDirectory, entityName));
|
||||||
final String targetPath = fs.path.join(targetDirectory, entityName);
|
|
||||||
if (entityName.endsWith('/')) {
|
|
||||||
copyDirectorySync(
|
|
||||||
fs.directory(sourcePath),
|
|
||||||
fs.directory(targetPath),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
fs.file(sourcePath)
|
|
||||||
.copySync(fs.path.join(targetDirectory, entityName));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,43 +233,6 @@ class ArtifactUnpacker {
|
||||||
_lastCopiedHashFile(directory).writeAsStringSync(hash);
|
_lastCopiedHashFile(directory).writeAsStringSync(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Copies the framework at [frameworkPath] to [targetDirectory]
|
|
||||||
/// by invoking 'cp -R'.
|
|
||||||
///
|
|
||||||
/// The shelling out is done to avoid complications with preserving special
|
|
||||||
/// files (e.g., symbolic links) in the framework structure.
|
|
||||||
///
|
|
||||||
/// Removes any previous version of the framework that already exists in the
|
|
||||||
/// target directory.
|
|
||||||
void _copyMacOSFramework(String frameworkPath, String targetDirectory) {
|
|
||||||
_deleteFrameworkIfPresent(
|
|
||||||
fs.path.join(targetDirectory, fs.path.basename(frameworkPath)));
|
|
||||||
|
|
||||||
final RunResult result = processUtils
|
|
||||||
.runSync(<String>['cp', '-R', frameworkPath, targetDirectory]);
|
|
||||||
if (result.exitCode != 0) {
|
|
||||||
throw Exception(
|
|
||||||
'Failed to copy framework (exit ${result.exitCode}:\n'
|
|
||||||
'${result.stdout}\n---\n${result.stderr}',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Recursively deletes the framework at [frameworkPath], if it exists.
|
|
||||||
void _deleteFrameworkIfPresent(String frameworkPath) {
|
|
||||||
// Ensure that the path is a framework, to minimize the potential for
|
|
||||||
// catastrophic deletion bugs with bad arguments.
|
|
||||||
if (fs.path.extension(frameworkPath) != '.framework') {
|
|
||||||
throw Exception(
|
|
||||||
'Attempted to delete a non-framework directory: $frameworkPath');
|
|
||||||
}
|
|
||||||
|
|
||||||
final Directory directory = fs.directory(frameworkPath);
|
|
||||||
if (directory.existsSync()) {
|
|
||||||
directory.deleteSync(recursive: true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the engine hash from [file] as a String, or null.
|
/// Returns the engine hash from [file] as a String, or null.
|
||||||
///
|
///
|
||||||
/// If the file is missing, or cannot be read, returns null.
|
/// If the file is missing, or cannot be read, returns null.
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
import 'package:flutter_tools/src/base/platform.dart';
|
import 'package:flutter_tools/src/base/platform.dart';
|
||||||
import 'package:flutter_tools/src/build_system/build_system.dart';
|
import 'package:flutter_tools/src/build_system/build_system.dart';
|
||||||
|
import 'package:flutter_tools/src/build_system/targets/dart.dart';
|
||||||
import 'package:flutter_tools/src/build_system/targets/linux.dart';
|
import 'package:flutter_tools/src/build_system/targets/linux.dart';
|
||||||
import 'package:flutter_tools/src/cache.dart';
|
import 'package:flutter_tools/src/cache.dart';
|
||||||
import 'package:mockito/mockito.dart';
|
import 'package:mockito/mockito.dart';
|
||||||
|
@ -28,11 +29,15 @@ void main() {
|
||||||
when(mockPlatform.isWindows).thenReturn(false);
|
when(mockPlatform.isWindows).thenReturn(false);
|
||||||
when(mockPlatform.isMacOS).thenReturn(false);
|
when(mockPlatform.isMacOS).thenReturn(false);
|
||||||
when(mockPlatform.isLinux).thenReturn(true);
|
when(mockPlatform.isLinux).thenReturn(true);
|
||||||
|
when(mockPlatform.environment).thenReturn(Map<String, String>.unmodifiable(<String, String>{}));
|
||||||
testbed = Testbed(setup: () {
|
testbed = Testbed(setup: () {
|
||||||
Cache.flutterRoot = '';
|
Cache.flutterRoot = '';
|
||||||
environment = Environment(
|
environment = Environment(
|
||||||
outputDir: fs.currentDirectory,
|
outputDir: fs.currentDirectory,
|
||||||
projectDir: fs.currentDirectory,
|
projectDir: fs.currentDirectory,
|
||||||
|
defines: <String, String>{
|
||||||
|
kBuildMode: 'debug',
|
||||||
|
}
|
||||||
);
|
);
|
||||||
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);
|
||||||
fs.file('bin/cache/artifacts/engine/linux-x64/flutter_export.h').createSync();
|
fs.file('bin/cache/artifacts/engine/linux-x64/flutter_export.h').createSync();
|
||||||
|
@ -49,36 +54,51 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Copies files to correct cache directory', () => testbed.run(() async {
|
test('Copies files to correct cache directory', () => testbed.run(() async {
|
||||||
final BuildResult result = await buildSystem.build(const UnpackLinux(), environment);
|
final BuildResult result = await buildSystem.build(const UnpackLinuxDebug(), environment);
|
||||||
|
|
||||||
expect(result.hasException, false);
|
expect(result.hasException, false);
|
||||||
expect(fs.file('linux/flutter/libflutter_linux_glfw.so').existsSync(), true);
|
expect(fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').existsSync(), true);
|
||||||
expect(fs.file('linux/flutter/flutter_export.h').existsSync(), true);
|
expect(fs.file('linux/flutter/ephemeral/flutter_export.h').existsSync(), true);
|
||||||
expect(fs.file('linux/flutter/flutter_messenger.h').existsSync(), true);
|
expect(fs.file('linux/flutter/ephemeral/flutter_messenger.h').existsSync(), true);
|
||||||
expect(fs.file('linux/flutter/flutter_plugin_registrar.h').existsSync(), true);
|
expect(fs.file('linux/flutter/ephemeral/flutter_plugin_registrar.h').existsSync(), true);
|
||||||
expect(fs.file('linux/flutter/flutter_glfw.h').existsSync(), true);
|
expect(fs.file('linux/flutter/ephemeral/flutter_glfw.h').existsSync(), true);
|
||||||
expect(fs.file('linux/flutter/icudtl.dat').existsSync(), true);
|
expect(fs.file('linux/flutter/ephemeral/icudtl.dat').existsSync(), true);
|
||||||
expect(fs.file('linux/flutter/cpp_client_wrapper_glfw/foo').existsSync(), true);
|
expect(fs.file('linux/flutter/ephemeral/cpp_client_wrapper_glfw/foo').existsSync(), true);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
test('Does not re-copy files unecessarily', () => testbed.run(() async {
|
test('Does not re-copy files unecessarily', () => testbed.run(() async {
|
||||||
await buildSystem.build(const UnpackLinux(), environment);
|
await buildSystem.build(const UnpackLinuxDebug(), environment);
|
||||||
// Set a date in the far distant past to deal with the limited resolution
|
// Set a date in the far distant past to deal with the limited resolution
|
||||||
// of the windows filesystem.
|
// of the windows filesystem.
|
||||||
final DateTime theDistantPast = DateTime(1991, 8, 23);
|
final DateTime theDistantPast = DateTime(1991, 8, 23);
|
||||||
fs.file('linux/flutter/libflutter_linux_glfw.so').setLastModifiedSync(theDistantPast);
|
fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').setLastModifiedSync(theDistantPast);
|
||||||
await buildSystem.build(const UnpackLinux(), environment);
|
await buildSystem.build(const UnpackLinuxDebug(), environment);
|
||||||
|
|
||||||
expect(fs.file('linux/flutter/libflutter_linux_glfw.so').statSync().modified, equals(theDistantPast));
|
expect(fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').statSync().modified, equals(theDistantPast));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
test('Detects changes in input cache files', () => testbed.run(() async {
|
test('Detects changes in input cache files', () => testbed.run(() async {
|
||||||
await buildSystem.build(const UnpackLinux(), environment);
|
await buildSystem.build(const UnpackLinuxDebug(), environment);
|
||||||
fs.file('bin/cache/artifacts/engine/linux-x64/libflutter_linux_glfw.so').writeAsStringSync('asd'); // modify cache.
|
fs.file('bin/cache/artifacts/engine/linux-x64/libflutter_linux_glfw.so').writeAsStringSync('asd'); // modify cache.
|
||||||
|
|
||||||
await buildSystem.build(const UnpackLinux(), environment);
|
await buildSystem.build(const UnpackLinuxDebug(), environment);
|
||||||
|
|
||||||
expect(fs.file('linux/flutter/libflutter_linux_glfw.so').readAsStringSync(), 'asd');
|
expect(fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').readAsStringSync(), 'asd');
|
||||||
|
}));
|
||||||
|
|
||||||
|
test('Copies artifacts to out directory', () => testbed.run(() async {
|
||||||
|
environment.buildDir.createSync(recursive: true);
|
||||||
|
|
||||||
|
// Create input files.
|
||||||
|
environment.buildDir.childFile('app.dill').createSync();
|
||||||
|
|
||||||
|
await const DebugBundleLinuxAssets().build(environment);
|
||||||
|
final Directory output = environment.outputDir
|
||||||
|
.childDirectory('flutter_assets');
|
||||||
|
|
||||||
|
expect(output.childFile('kernel_blob.bin').existsSync(), true);
|
||||||
|
expect(output.childFile('FontManifest.json').existsSync(), false);
|
||||||
|
expect(output.childFile('AssetManifest.json').existsSync(), true);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue