Commit cd8434d9 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Refactor how Artifacts are located (#8234)

Artifacts are now located in a central place.
This will enable us to downlaod artifacts when we need them (instead of
downloading them all upfront).
This also makes replacing sky_snapshot with gen_snapshot easier.
parent cc808cda
......@@ -41,6 +41,7 @@ import 'src/commands/test.dart';
import 'src/commands/trace.dart';
import 'src/commands/update_packages.dart';
import 'src/commands/upgrade.dart';
import 'src/artifacts.dart';
import 'src/devfs.dart';
import 'src/device.dart';
import 'src/doctor.dart';
......@@ -49,7 +50,6 @@ import 'src/ios/mac.dart';
import 'src/ios/simulators.dart';
import 'src/run_hot.dart';
import 'src/runner/flutter_command_runner.dart';
import 'src/toolchain.dart';
import 'src/usage.dart';
......@@ -113,7 +113,7 @@ Future<Null> main(List<String> args) async {
context.putIfAbsent(Doctor, () => new Doctor());
context.putIfAbsent(HotRunnerConfig, () => new HotRunnerConfig());
context.putIfAbsent(Cache, () => new Cache());
context.putIfAbsent(ToolConfiguration, () => new ToolConfiguration());
context.putIfAbsent(Artifacts, () => new CachedArtifacts());
context.putIfAbsent(Config, () => new Config());
context.putIfAbsent(OperatingSystemUtils, () => new OperatingSystemUtils());
context.putIfAbsent(Xcode, () => new Xcode());
......
This diff is collapsed.
......@@ -4,6 +4,7 @@
import 'dart:async';
import '../artifacts.dart';
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/logger.dart';
......@@ -49,7 +50,7 @@ class BuildAotCommand extends BuildSubCommand {
if (platform == null)
throwToolExit('Unknown platform: $targetPlatform');
String typeName = fs.path.basename(tools.getEngineArtifactsDirectory(platform, getBuildMode()).path);
String typeName = artifacts.getEngineType(platform, getBuildMode());
Status status = logger.startProgress('Building AOT snapshot in ${getModeName(getBuildMode())} mode ($typeName)...',
expectSlowOperation: true);
String outputPath = await buildAotSnapshot(
......@@ -115,33 +116,7 @@ Future<String> _buildAotSnapshot(
return null;
}
String entryPointsDir, dartEntryPointsDir, snapshotterDir, genSnapshot;
String engineSrc = tools.engineSrcPath;
String genSnapshotExecutable = 'gen_snapshot';
if (engineSrc != null) {
entryPointsDir = fs.path.join(engineSrc, 'flutter', 'runtime');
dartEntryPointsDir = fs.path.join(engineSrc, 'dart', 'runtime', 'bin');
snapshotterDir = fs.path.join(engineSrc, 'flutter', 'lib', 'snapshot');
String engineOut = tools.getEngineArtifactsDirectory(platform, buildMode).path;
if (platform == TargetPlatform.ios) {
genSnapshot = fs.path.join(engineOut, 'clang_x64', genSnapshotExecutable);
} else {
String host32BitToolchain = getCurrentHostPlatform() == HostPlatform.darwin_x64 ? 'clang_i386' : 'clang_x86';
genSnapshot = fs.path.join(engineOut, host32BitToolchain, genSnapshotExecutable);
}
} else {
String artifactsDir = tools.getEngineArtifactsDirectory(platform, buildMode).path;
entryPointsDir = artifactsDir;
dartEntryPointsDir = entryPointsDir;
snapshotterDir = entryPointsDir;
if (platform == TargetPlatform.ios) {
genSnapshot = fs.path.join(artifactsDir, genSnapshotExecutable);
} else {
String hostToolsDir = fs.path.join(artifactsDir, getNameForHostPlatform(getCurrentHostPlatform()));
genSnapshot = fs.path.join(hostToolsDir, genSnapshotExecutable);
}
}
String genSnapshot = artifacts.getArtifactPath(Artifact.genSnapshot, platform, buildMode);
Directory outputDir = fs.directory(outputPath);
outputDir.createSync(recursive: true);
......@@ -150,8 +125,8 @@ Future<String> _buildAotSnapshot(
String isolateSnapshotData = fs.path.join(outputDir.path, 'isolate_snapshot_data');
String isolateSnapshotInstructions = fs.path.join(outputDir.path, 'isolate_snapshot_instr');
String vmEntryPoints = fs.path.join(entryPointsDir, 'dart_vm_entry_points.txt');
String ioEntryPoints = fs.path.join(dartEntryPointsDir, 'dart_io_entries.txt');
String vmEntryPoints = artifacts.getArtifactPath(Artifact.dartVmEntryPointsTxt, platform, buildMode);
String ioEntryPoints = artifacts.getArtifactPath(Artifact.dartIoEntriesTxt, platform, buildMode);
PackageMap packageMap = new PackageMap(PackageMap.globalPackagesPath);
String packageMapError = packageMap.checkValid();
......@@ -184,13 +159,13 @@ Future<String> _buildAotSnapshot(
case TargetPlatform.android_arm:
case TargetPlatform.android_x64:
case TargetPlatform.android_x86:
vmEntryPointsAndroid = fs.path.join(entryPointsDir, 'dart_vm_entry_points_android.txt');
vmEntryPointsAndroid = artifacts.getArtifactPath(Artifact.dartVmEntryPointsAndroidTxt, platform, buildMode);
filePaths.addAll(<String>[
vmEntryPointsAndroid,
]);
break;
case TargetPlatform.ios:
snapshotDartIOS = fs.path.join(snapshotterDir, 'snapshot.dart');
snapshotDartIOS = artifacts.getArtifactPath(Artifact.snapshotDart, platform, buildMode);
assembly = fs.path.join(outputDir.path, 'snapshot_assembly.S');
filePaths.addAll(<String>[
snapshotDartIOS,
......
......@@ -7,6 +7,7 @@ import 'dart:convert' show JSON;
import '../android/android_sdk.dart';
import '../android/gradle.dart';
import '../artifacts.dart';
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/logger.dart';
......@@ -285,28 +286,12 @@ Future<_ApkComponents> _findApkComponents(
components.manifest = fs.file(manifest);
components.resources = resources == null ? null : fs.directory(resources);
components.extraFiles = extraFiles != null ? extraFiles : <String, File>{};
if (tools.isLocalEngine) {
String abiDir = getAbiDirectory(platform);
String enginePath = tools.engineSrcPath;
String buildDir = tools.getEngineArtifactsDirectory(platform, buildMode).path;
components.icuData = fs.file('$enginePath/third_party/icu/android/icudtl.dat');
components.jars = <File>[
fs.file('$buildDir/gen/flutter/shell/platform/android/android/classes.dex.jar')
];
components.libSkyShell = fs.file('$buildDir/gen/flutter/shell/platform/android/android/android/libs/$abiDir/libsky_shell.so');
components.debugKeystore = fs.file('$enginePath/build/android/ant/chromium-debug.keystore');
} else {
Directory artifacts = tools.getEngineArtifactsDirectory(platform, buildMode);
components.icuData = fs.file(fs.path.join(artifacts.path, 'icudtl.dat'));
components.jars = <File>[
fs.file(fs.path.join(artifacts.path, 'classes.dex.jar'))
];
components.libSkyShell = fs.file(fs.path.join(artifacts.path, 'libsky_shell.so'));
components.debugKeystore = fs.file(fs.path.join(artifacts.path, 'chromium-debug.keystore'));
}
components.icuData = fs.file(artifacts.getArtifactPath(Artifact.icudtlDat, platform, buildMode));
components.jars = <File>[
fs.file(artifacts.getArtifactPath(Artifact.classesDexJar, platform, buildMode))
];
components.libSkyShell = fs.file(artifacts.getArtifactPath(Artifact.libskyShellSo, platform, buildMode));
components.debugKeystore = fs.file(artifacts.getArtifactPath(Artifact.chromiumDebugKeyStore, platform, buildMode));
await parseServiceConfigs(components.services, jars: components.jars);
......@@ -534,8 +519,8 @@ Future<Null> buildAndroid(
if (components == null)
throwToolExit('Failure building APK: unable to find components.');
String typeName = fs.path.basename(tools.getEngineArtifactsDirectory(platform, buildMode).path);
Status status = logger.startProgress('Building APK in ${getModeName(buildMode)} mode ($typeName)...',
String typeName = artifacts.getEngineType(platform, buildMode);
Status status = logger.startProgress('Building APK in ${getModeName(buildMode)} mode ($typeName)...',
expectSlowOperation: true);
if (flxPath != null && flxPath.isNotEmpty) {
......@@ -658,8 +643,10 @@ void _writeBuildMetaEntry(String buildDirectoryPath, String key, dynamic value)
String _getTargetBuildTypeToken(TargetPlatform platform, BuildMode buildMode, File outputBinary) {
String buildType = getNameForTargetPlatform(platform) + '-' + getModeName(buildMode);
if (tools.isLocalEngine)
buildType += ' [${tools.engineBuildPath}]';
if (artifacts is LocalEngineArtifacts) {
LocalEngineArtifacts localEngineArtifacts = artifacts;
buildType += ' [${localEngineArtifacts.engineOutPath}]';
}
if (outputBinary.existsSync())
buildType += ' [${outputBinary.lastModifiedSync().millisecondsSinceEpoch}]';
return buildType;
......
......@@ -6,7 +6,6 @@ import 'dart:async';
import '../application_package.dart';
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/logger.dart';
import '../base/utils.dart';
import '../build_info.dart';
......@@ -63,7 +62,7 @@ class BuildIOSCommand extends BuildSubCommand {
String logTarget = forSimulator ? 'simulator' : 'device';
String typeName = fs.path.basename(tools.getEngineArtifactsDirectory(TargetPlatform.ios, getBuildMode()).path);
String typeName = artifacts.getEngineType(TargetPlatform.ios, getBuildMode());
Status status = logger.startProgress('Building $app for $logTarget ($typeName)...',
expectSlowOperation: true);
XcodeBuildResult result = await buildXcodeProject(
......
......@@ -6,11 +6,11 @@ import 'dart:async';
import 'package:test/src/executable.dart' as test; // ignore: implementation_imports
import '../artifacts.dart';
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart';
import '../base/platform.dart';
import '../base/process_manager.dart';
import '../base/os.dart';
import '../cache.dart';
......@@ -19,7 +19,6 @@ import '../globals.dart';
import '../runner/flutter_command.dart';
import '../test/coverage_collector.dart';
import '../test/flutter_platform.dart' as loader;
import '../toolchain.dart';
class TestCommand extends FlutterCommand {
TestCommand() {
......@@ -190,7 +189,7 @@ class TestCommand extends FlutterCommand {
}
testArgs.addAll(files);
final String shellPath = tools.getHostToolPath(HostTool.SkyShell) ?? platform.environment['SKY_SHELL'];
final String shellPath = artifacts.getArtifactPath(Artifact.skyShell);
if (!fs.isFileSync(shellPath))
throwToolExit('Cannot find Flutter shell at $shellPath');
loader.installHook(
......
......@@ -4,9 +4,9 @@
import 'dart:convert';
import '../artifacts.dart';
import '../base/file_system.dart';
import '../base/process.dart';
import '../toolchain.dart';
class DartDependencySetBuilder {
DartDependencySetBuilder(this.mainScriptPath,
......@@ -19,7 +19,7 @@ class DartDependencySetBuilder {
Set<String> build() {
final String skySnapshotPath =
ToolConfiguration.instance.getHostToolPath(HostTool.SkySnapshot);
Artifacts.instance.getArtifactPath(Artifact.skySnapshot);
final List<String> args = <String>[
skySnapshotPath,
......
......@@ -4,6 +4,7 @@
import 'dart:async';
import 'artifacts.dart';
import 'asset.dart';
import 'base/common.dart';
import 'base/file_system.dart';
......@@ -12,7 +13,6 @@ import 'dart/package_map.dart';
import 'devfs.dart';
import 'build_info.dart';
import 'globals.dart';
import 'toolchain.dart';
import 'zip.dart';
const String defaultMainPath = 'lib/main.dart';
......@@ -88,7 +88,7 @@ Future<Null> build({
bool includeRobotoFonts: true,
bool reportLicensedPackages: false
}) async {
snapshotterPath ??= tools.getHostToolPath(HostTool.SkySnapshot);
snapshotterPath ??= artifacts.getArtifactPath(Artifact.skySnapshot);
outputPath ??= defaultFlxOutputPath;
kernelPath ??= defaultKernelPath;
snapshotPath ??= defaultSnapshotPath;
......
......@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'artifacts.dart';
import 'base/config.dart';
import 'base/context.dart';
import 'base/logger.dart';
import 'cache.dart';
import 'toolchain.dart';
Logger get logger => context[Logger];
Cache get cache => Cache.instance;
Config get config => Config.instance;
ToolConfiguration get tools => ToolConfiguration.instance;
Artifacts get artifacts => Artifacts.instance;
/// Display an error level message to the user. Commands should use this if they
/// fail in some way.
......
......@@ -5,6 +5,7 @@
import '../base/file_system.dart';
import '../base/process.dart';
import '../build_info.dart';
import '../artifacts.dart';
import '../cache.dart';
import '../globals.dart';
......@@ -33,11 +34,13 @@ void updateXcodeGeneratedProperties(String projectPath, BuildMode mode, String t
localsBuffer.writeln('SYMROOT=\${SOURCE_ROOT}/../${getIosBuildDirectory()}');
String flutterFrameworkDir = fs.path.normalize(tools.getEngineArtifactsDirectory(TargetPlatform.ios, mode).path);
String flutterFrameworkDir = fs.path.normalize(fs.path.dirname(artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, mode)));
localsBuffer.writeln('FLUTTER_FRAMEWORK_DIR=$flutterFrameworkDir');
if (tools.isLocalEngine)
localsBuffer.writeln('LOCAL_ENGINE=${tools.engineBuildPath}');
if (artifacts is LocalEngineArtifacts) {
LocalEngineArtifacts localEngineArtifacts = artifacts;
localsBuffer.writeln('LOCAL_ENGINE=${localEngineArtifacts.engineOutPath}');
}
File localsFile = fs.file(fs.path.join(projectPath, 'ios', 'Flutter', 'Generated.xcconfig'));
localsFile.createSync(recursive: true);
......
......@@ -8,6 +8,7 @@ import 'package:args/args.dart';
import 'package:args/command_runner.dart';
import '../android/android_sdk.dart';
import '../artifacts.dart';
import '../base/common.dart';
import '../base/context.dart';
import '../base/file_system.dart';
......@@ -19,7 +20,6 @@ import '../cache.dart';
import '../dart/package_map.dart';
import '../device.dart';
import '../globals.dart';
import '../toolchain.dart';
import '../usage.dart';
import '../version.dart';
......@@ -206,8 +206,7 @@ class FlutterCommandRunner extends CommandRunner<Null> {
// Set up the tooling configuration.
String enginePath = _findEnginePath(globalResults);
if (enginePath != null) {
ToolConfiguration.instance.engineSrcPath = enginePath;
ToolConfiguration.instance.engineBuildPath = _findEngineBuildPath(globalResults, enginePath);
Artifacts.useLocalEngine(enginePath, _findEngineBuildPath(globalResults, enginePath));
}
// The Android SDK could already have been set by tests.
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'base/context.dart';
import 'base/file_system.dart';
import 'build_info.dart';
import 'cache.dart';
import 'globals.dart';
enum HostTool {
SkySnapshot,
SkyShell,
}
const Map<HostTool, String> _kHostToolFileName = const <HostTool, String>{
HostTool.SkySnapshot: 'sky_snapshot',
HostTool.SkyShell: 'sky_shell',
};
/// A ToolConfiguration can return the tools directory for the current host platform
/// and the engine artifact directory for a given target platform. It is configurable
/// via command-line arguments in order to support local engine builds.
class ToolConfiguration {
ToolConfiguration();
Cache get cache => context[Cache];
static ToolConfiguration get instance => context[ToolConfiguration];
/// Override using the artifacts from the cache directory (--engine-src-path).
String engineSrcPath;
/// Path to a local engine build acting as a source for artifacts (--local-engine).
String engineBuildPath;
bool get isLocalEngine => engineSrcPath != null;
/// Return the directory that contains engine artifacts for the given targets.
/// This directory might contain artifacts like `libsky_shell.so`.
Directory getEngineArtifactsDirectory(TargetPlatform platform, BuildMode mode) {
Directory dir = _getEngineArtifactsDirectory(platform, mode);
if (dir != null)
printTrace('Using engine artifacts dir: ${dir.path}');
return dir;
}
Directory _getEngineArtifactsDirectory(TargetPlatform platform, BuildMode mode) {
if (engineBuildPath != null) {
return fs.directory(engineBuildPath);
} else {
String suffix = mode != BuildMode.debug ? '-${getModeName(mode)}' : '';
// Create something like `android-arm` or `android-arm-release`.
String dirName = getNameForTargetPlatform(platform) + suffix;
Directory engineDir = cache.getArtifactDirectory('engine');
return fs.directory(fs.path.join(engineDir.path, dirName));
}
}
String getHostToolPath(HostTool tool) {
if (engineBuildPath == null) {
return fs.path.join(cache.getArtifactDirectory('engine').path,
getNameForHostPlatform(getCurrentHostPlatform()),
_kHostToolFileName[tool]);
}
if (tool == HostTool.SkySnapshot) {
String clangPath = fs.path.join(engineBuildPath, 'clang_x64', 'sky_snapshot');
if (fs.isFileSync(clangPath))
return clangPath;
return fs.path.join(engineBuildPath, 'sky_snapshot');
} else if (tool == HostTool.SkyShell) {
if (getCurrentHostPlatform() == HostPlatform.linux_x64) {
return fs.path.join(engineBuildPath, 'sky_shell');
} else if (getCurrentHostPlatform() == HostPlatform.darwin_x64) {
return fs.path.join(engineBuildPath, 'SkyShell.app', 'Contents', 'MacOS', 'SkyShell');
}
}
throw 'Unexpected host tool: $tool';
}
}
......@@ -16,6 +16,7 @@ import 'analyze_test.dart' as analyze_test;
import 'android_device_test.dart' as android_device_test;
import 'android_sdk_test.dart' as android_sdk_test;
import 'application_package_test.dart' as application_package_test;
import 'artifacts_test.dart' as artifacts_test;
import 'asset_bundle_test.dart' as asset_bundle_test;
import 'base_utils_test.dart' as base_utils_test;
import 'channel_test.dart' as channel_test;
......@@ -41,7 +42,6 @@ import 'protocol_discovery_test.dart' as protocol_discovery_test;
import 'run_test.dart' as run_test;
import 'stop_test.dart' as stop_test;
import 'test_test.dart' as test_test;
import 'toolchain_test.dart' as toolchain_test;
import 'trace_test.dart' as trace_test;
import 'upgrade_test.dart' as upgrade_test;
import 'utils_test.dart' as utils_test;
......@@ -55,6 +55,7 @@ void main() {
android_device_test.main();
android_sdk_test.main();
application_package_test.main();
artifacts_test.main();
asset_bundle_test.main();
base_utils_test.main();
channel_test.main();
......@@ -80,7 +81,6 @@ void main() {
run_test.main();
stop_test.main();
test_test.main();
toolchain_test.main();
trace_test.main();
upgrade_test.main();
utils_test.main();
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:test/test.dart';
import 'src/context.dart';
void main() {
group('CachedArtifacts', () {
Directory tempDir;
CachedArtifacts artifacts;
setUp(() {
tempDir = fs.systemTempDirectory.createTempSync('flutter_temp');
artifacts = new CachedArtifacts();
});
tearDown(() {
tempDir.deleteSync(recursive: true);
});
testUsingContext('getArtifactPath', () {
expect(
artifacts.getArtifactPath(Artifact.libskyShellSo, TargetPlatform.android_arm, BuildMode.debug),
fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'android-arm', 'libsky_shell.so')
);
expect(
artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, BuildMode.release),
fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'ios-release', 'Flutter.framework')
);
expect(
artifacts.getArtifactPath(Artifact.skyShell),
fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'linux-x64', 'sky_shell')
);
}, overrides: <Type, Generator> {
Cache: () => new Cache(rootOverride: tempDir),
Platform: () => new FakePlatform(operatingSystem: 'linux')
});
testUsingContext('getEngineType', () {
expect(
artifacts.getEngineType(TargetPlatform.android_arm, BuildMode.debug),
'android-arm'
);
expect(
artifacts.getEngineType(TargetPlatform.ios, BuildMode.release),
'ios-release'
);
expect(
artifacts.getEngineType(TargetPlatform.darwin_x64),
'darwin-x64'
);
}, overrides: <Type, Generator> {
Cache: () => new Cache(rootOverride: tempDir),
Platform: () => new FakePlatform(operatingSystem: 'linux')
});
});
group('LocalEngineArtifacts', () {
Directory tempDir;
LocalEngineArtifacts artifacts;
setUp(() {
tempDir = fs.systemTempDirectory.createTempSync('flutter_temp');
artifacts = new LocalEngineArtifacts(tempDir.path, fs.path.join(tempDir.path, 'out', 'android_debug_unopt'));
});
tearDown(() {
tempDir.deleteSync(recursive: true);
});
testUsingContext('getArtifactPath', () {
expect(
artifacts.getArtifactPath(Artifact.dartIoEntriesTxt, TargetPlatform.android_arm, BuildMode.debug),
fs.path.join(tempDir.path, 'dart', 'runtime', 'bin', 'dart_io_entries.txt')
);
expect(
artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, BuildMode.release),
fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'Flutter.framework')
);
expect(
artifacts.getArtifactPath(Artifact.skyShell),
fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'sky_shell')
);
}, overrides: <Type, Generator> {
Platform: () => new FakePlatform(operatingSystem: 'linux')
});
testUsingContext('getEngineType', () {
expect(
artifacts.getEngineType(TargetPlatform.android_arm, BuildMode.debug),
'android_debug_unopt'
);
expect(
artifacts.getEngineType(TargetPlatform.ios, BuildMode.release),
'android_debug_unopt'
);
expect(
artifacts.getEngineType(TargetPlatform.darwin_x64),
'android_debug_unopt'
);
}, overrides: <Type, Generator> {
Platform: () => new FakePlatform(operatingSystem: 'linux')
});
});
}
\ No newline at end of file
......@@ -4,6 +4,7 @@
import 'dart:async';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/config.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
......@@ -17,7 +18,6 @@ import 'package:flutter_tools/src/doctor.dart';
import 'package:flutter_tools/src/ios/mac.dart';
import 'package:flutter_tools/src/ios/simulators.dart';
import 'package:flutter_tools/src/run_hot.dart';
import 'package:flutter_tools/src/toolchain.dart';
import 'package:flutter_tools/src/usage.dart';
import 'package:mockito/mockito.dart';
......@@ -53,7 +53,7 @@ void testUsingContext(String description, dynamic testMethod(), {
testContext.putIfAbsent(Doctor, () => new MockDoctor());
testContext.putIfAbsent(HotRunnerConfig, () => new HotRunnerConfig());
testContext.putIfAbsent(Cache, () => new Cache());
testContext.putIfAbsent(ToolConfiguration, () => new ToolConfiguration());
testContext.putIfAbsent(Artifacts, () => new CachedArtifacts());
testContext.putIfAbsent(Config, () => new Config());
testContext.putIfAbsent(OperatingSystemUtils, () {
MockOperatingSystemUtils os = new MockOperatingSystemUtils();
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/toolchain.dart';
import 'package:test/test.dart';
import 'src/context.dart';
void main() {
group('ToolConfiguration', () {
Directory tempDir;
tempDir = fs.systemTempDirectory.createTempSync('flutter_temp');
testUsingContext('using cache', () {
ToolConfiguration toolConfig = new ToolConfiguration();
expect(
toolConfig.getEngineArtifactsDirectory(TargetPlatform.android_arm, BuildMode.debug).path,
endsWith(fs.path.join('cache', 'artifacts', 'engine', 'android-arm'))
);
expect(
toolConfig.getEngineArtifactsDirectory(TargetPlatform.android_arm, BuildMode.release).path,
endsWith(fs.path.join('cache', 'artifacts', 'engine', 'android-arm-release'))
);
expect(tempDir, isNotNull);
tempDir.deleteSync(recursive: true);
}, overrides: <Type, Generator> {
Cache: () => new Cache(rootOverride: tempDir),
});
testUsingContext('using enginePath', () {
ToolConfiguration toolConfig = new ToolConfiguration();
toolConfig.engineSrcPath = 'engine';
toolConfig.engineBuildPath = 'engine/out/android_debug';
expect(
toolConfig.getEngineArtifactsDirectory(TargetPlatform.android_arm, BuildMode.debug).path,
'engine/out/android_debug'
);
});
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment