Unverified Commit ec4049e7 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] support bundle-sksl-path on all desktop and mobile targets (#58879)

Adds support for --bundle-sksl-path to windows, linux, macOS, and iOS.

Fixes #53115
parent 39e00d2e
......@@ -67,6 +67,11 @@ if [[ -n "$PERFORMANCE_MEASUREMENT_FILE" ]]; then
performance_measurement_option="--performance-measurement-file=${PERFORMANCE_MEASUREMENT_FILE}"
fi
bundle_sksl_path=""
if [[ -n "$BUNDLE_SKSL_PATH" ]]; then
bundle_sksl_path="-iBundleSkSLPath=${BUNDLE_SKSL_PATH}"
fi
RunCommand "${FLUTTER_ROOT}/bin/flutter" \
${verbose_flag} \
${flutter_engine_flag} \
......@@ -80,6 +85,7 @@ RunCommand "${FLUTTER_ROOT}/bin/flutter" \
-dDartObfuscation="${DART_OBFUSCATION}" \
-dSplitDebugInfo="${SPLIT_DEBUG_INFO}" \
-dTrackWidgetCreation="${TRACK_WIDGET_CREATION}" \
${bundle_sksl_path} \
--DartDefines="${DART_DEFINES}" \
--ExtraGenSnapshotOptions="${EXTRA_GEN_SNAPSHOT_OPTIONS}" \
--ExtraFrontEndOptions="${EXTRA_FRONT_END_OPTIONS}" \
......
......@@ -22,6 +22,7 @@ Future<void> main(List<String> arguments) async {
final String localEngine = Platform.environment['LOCAL_ENGINE'];
final String projectDirectory = Platform.environment['PROJECT_DIR'];
final String splitDebugInfo = Platform.environment['SPLIT_DEBUG_INFO'];
final String bundleSkSLPath = Platform.environment['BUNDLE_SKSL_PATH'];
final bool trackWidgetCreation = Platform.environment['TRACK_WIDGET_CREATION'] == 'true';
final bool treeShakeIcons = Platform.environment['TREE_SHAKE_ICONS'] == 'true';
final bool verbose = Platform.environment['VERBOSE_SCRIPT_LOGGING'] == 'true';
......@@ -62,6 +63,8 @@ or
'-dTargetFile=$flutterTarget',
'-dTreeShakeIcons="$treeShakeIcons"',
'-dDartObfuscation=$dartObfuscation',
if (bundleSkSLPath != null)
'-iBundleSkSLPath=$bundleSkSLPath',
if (splitDebugInfo != null)
'-dSplitDebugInfo=$splitDebugInfo',
if (dartDefines != null)
......
......@@ -54,6 +54,11 @@ BuildApp() {
derived_dir="${project_path}/.ios/Flutter"
fi
local bundle_sksl_path=""
if [[ -n "$BUNDLE_SKSL_PATH" ]]; then
bundle_sksl_path="-iBundleSkSLPath=${BUNDLE_SKSL_PATH}"
fi
# Default value of assets_path is flutter_assets
local assets_path="flutter_assets"
# The value of assets_path can set by add FLTAssetsPath to
......@@ -166,6 +171,7 @@ is set to release or run \"flutter build ios --release\", then re-run Archive fr
-dTrackWidgetCreation="${TRACK_WIDGET_CREATION}" \
-dDartObfuscation="${DART_OBFUSCATION}" \
-dEnableBitcode="${bitcode_flag}" \
${bundle_sksl_path} \
--ExtraGenSnapshotOptions="${EXTRA_GEN_SNAPSHOT_OPTIONS}" \
--DartDefines="${DART_DEFINES}" \
--ExtraFrontEndOptions="${EXTRA_FRONT_END_OPTIONS}" \
......
......@@ -154,6 +154,8 @@ class BuildInfo {
'TREE_SHAKE_ICONS': treeShakeIcons.toString(),
if (performanceMeasurementFile != null)
'PERFORMANCE_MEASUREMENT_FILE': performanceMeasurementFile,
if (bundleSkSLPath != null)
'BUNDLE_SKSL_PATH': bundleSkSLPath,
};
}
}
......
......@@ -6,7 +6,6 @@ import '../../artifacts.dart';
import '../../base/build.dart';
import '../../base/file_system.dart';
import '../../build_info.dart';
import '../../devfs.dart';
import '../../globals.dart' as globals;
import '../build_system.dart';
import '../depfile.dart';
......@@ -63,27 +62,11 @@ abstract class AndroidAssetBundle extends Target {
.copySync(outputDirectory.childFile('isolate_snapshot_data').path);
}
if (_copyAssets) {
final String shaderBundlePath = environment.inputs[kBundleSkSLPath];
final DevFSContent skslBundle = processSkSLBundle(
shaderBundlePath,
engineVersion: environment.engineVersion,
fileSystem: environment.fileSystem,
logger: environment.logger,
targetPlatform: TargetPlatform.android,
);
final Depfile assetDepfile = await copyAssets(
environment,
outputDirectory,
additionalContent: <String, DevFSContent>{
if (skslBundle != null)
kSkSLShaderBundlePath: skslBundle,
}
targetPlatform: TargetPlatform.android,
);
if (shaderBundlePath != null) {
final File skSLBundleFile = environment.fileSystem
.file(shaderBundlePath).absolute;
assetDepfile.inputs.add(skSLBundleFile);
}
final DepfileService depfileService = DepfileService(
fileSystem: globals.fs,
logger: globals.logger,
......
......@@ -31,7 +31,18 @@ const String kBundleSkSLPath = 'BundleSkSLPath';
/// Returns a [Depfile] containing all assets used in the build.
Future<Depfile> copyAssets(Environment environment, Directory outputDirectory, {
Map<String, DevFSContent> additionalContent,
@required TargetPlatform targetPlatform,
}) async {
// Check for an SkSL bundle.
final String shaderBundlePath = environment.inputs[kBundleSkSLPath];
final DevFSContent skslBundle = processSkSLBundle(
shaderBundlePath,
engineVersion: environment.engineVersion,
fileSystem: environment.fileSystem,
logger: environment.logger,
targetPlatform: targetPlatform,
);
final File pubspecFile = environment.projectDir.childFile('pubspec.yaml');
final AssetBundle assetBundle = AssetBundleFactory.instance.createBundle();
final int resultCode = await assetBundle.build(
......@@ -61,6 +72,8 @@ Future<Depfile> copyAssets(Environment environment, Directory outputDirectory, {
final Map<String, DevFSContent> assetEntries = <String, DevFSContent>{
...assetBundle.entries,
...?additionalContent,
if (skslBundle != null)
kSkSLShaderBundlePath: skslBundle,
};
await Future.wait<void>(
......@@ -92,7 +105,13 @@ Future<Depfile> copyAssets(Environment environment, Directory outputDirectory, {
resource.release();
}
}));
return Depfile(inputs + assetBundle.additionalDependencies, outputs);
final Depfile depfile = Depfile(inputs + assetBundle.additionalDependencies, outputs);
if (shaderBundlePath != null) {
final File skSLBundleFile = environment.fileSystem
.file(shaderBundlePath).absolute;
depfile.inputs.add(skSLBundleFile);
}
return depfile;
}
/// The path of the SkSL JSON bundle included in flutter_assets.
......@@ -197,7 +216,11 @@ class CopyAssets extends Target {
.buildDir
.childDirectory('flutter_assets');
output.createSync(recursive: true);
final Depfile depfile = await copyAssets(environment, output);
final Depfile depfile = await copyAssets(
environment,
output,
targetPlatform: TargetPlatform.android,
);
final DepfileService depfileService = DepfileService(
fileSystem: globals.fs,
logger: globals.logger,
......
......@@ -116,7 +116,11 @@ class CopyFlutterBundle extends Target {
globals.fs.file(isolateSnapshotData)
.copySync(environment.outputDir.childFile('isolate_snapshot_data').path);
}
final Depfile assetDepfile = await copyAssets(environment, environment.outputDir);
final Depfile assetDepfile = await copyAssets(
environment,
environment.outputDir,
targetPlatform: TargetPlatform.android,
);
final DepfileService depfileService = DepfileService(
fileSystem: globals.fs,
logger: globals.logger,
......
......@@ -308,7 +308,11 @@ abstract class IosAssetBundle extends Target {
}
// Copy the assets.
final Depfile assetDepfile = await copyAssets(environment, assetDirectory);
final Depfile assetDepfile = await copyAssets(
environment,
assetDirectory,
targetPlatform: TargetPlatform.ios,
);
final DepfileService depfileService = DepfileService(
fileSystem: globals.fs,
logger: globals.logger,
......
......@@ -139,7 +139,11 @@ abstract class BundleLinuxAssets extends Target {
environment.buildDir.childFile('app.dill')
.copySync(outputDirectory.childFile('kernel_blob.bin').path);
}
final Depfile depfile = await copyAssets(environment, outputDirectory);
final Depfile depfile = await copyAssets(
environment,
outputDirectory,
targetPlatform: TargetPlatform.linux_x64,
);
final DepfileService depfileService = DepfileService(
fileSystem: environment.fileSystem,
logger: environment.logger,
......
......@@ -293,7 +293,11 @@ abstract class MacOSBundleFlutterAssets extends Target {
.childDirectory('flutter_assets');
assetDirectory.createSync(recursive: true);
final Depfile assetDepfile = await copyAssets(environment, assetDirectory);
final Depfile assetDepfile = await copyAssets(
environment,
assetDirectory,
targetPlatform: TargetPlatform.darwin_x64,
);
final DepfileService depfileService = DepfileService(
fileSystem: globals.fs,
logger: globals.logger,
......
......@@ -281,7 +281,11 @@ class WebReleaseBundle extends Target {
}
final Directory outputDirectory = environment.outputDir.childDirectory('assets');
outputDirectory.createSync(recursive: true);
final Depfile depfile = await copyAssets(environment, environment.outputDir.childDirectory('assets'));
final Depfile depfile = await copyAssets(
environment,
environment.outputDir.childDirectory('assets'),
targetPlatform: TargetPlatform.web_javascript,
);
final DepfileService depfileService = DepfileService(
fileSystem: globals.fs,
logger: globals.logger,
......
......@@ -132,7 +132,11 @@ abstract class BundleWindowsAssets extends Target {
environment.buildDir.childFile('app.dill')
.copySync(outputDirectory.childFile('kernel_blob.bin').path);
}
final Depfile depfile = await copyAssets(environment, outputDirectory);
final Depfile depfile = await copyAssets(
environment,
outputDirectory,
targetPlatform: TargetPlatform.windows_x64,
);
final DepfileService depfileService = DepfileService(
fileSystem: environment.fileSystem,
logger: environment.logger,
......
......@@ -33,6 +33,7 @@ class BuildIOSCommand extends BuildSubCommand {
usesExtraFrontendOptions();
addEnableExperimentation(hide: !verboseHelp);
addBuildPerformanceFile(hide: !verboseHelp);
addBundleSkSLPathOption(hide: !verboseHelp);
addNullSafetyModeOptions();
argParser
..addFlag('simulator',
......
......@@ -28,6 +28,7 @@ class BuildLinuxCommand extends BuildSubCommand {
addEnableExperimentation(hide: !verboseHelp);
usesTrackWidgetCreation(verboseHelp: verboseHelp);
addBuildPerformanceFile(hide: !verboseHelp);
addBundleSkSLPathOption(hide: !verboseHelp);
addNullSafetyModeOptions();
}
......
......@@ -29,6 +29,7 @@ class BuildMacosCommand extends BuildSubCommand {
usesBuildNameOption();
addEnableExperimentation(hide: !verboseHelp);
addBuildPerformanceFile(hide: !verboseHelp);
addBundleSkSLPathOption(hide: !verboseHelp);
addNullSafetyModeOptions();
}
......
......@@ -31,6 +31,7 @@ class BuildWindowsCommand extends BuildSubCommand {
addEnableExperimentation(hide: !verboseHelp);
usesTrackWidgetCreation(verboseHelp: verboseHelp);
addBuildPerformanceFile(hide: !verboseHelp);
addBundleSkSLPathOption(hide: !verboseHelp);
}
@override
......
......@@ -338,6 +338,7 @@ void main() {
'--dart-define=foo.bar=2',
'--dart-define=fizz.far=3',
'--tree-shake-icons',
'--bundle-sksl-path=foo/bar.sksl.json',
]
);
......@@ -364,6 +365,7 @@ void main() {
' "FLUTTER_ROOT=\\"\${FLUTTER_ROOT}\\""',
' "PROJECT_DIR=\\"\${PROJECT_DIR}\\""',
' "FLUTTER_TARGET=\\"lib/other.dart\\""',
' "BUNDLE_SKSL_PATH=\\"foo/bar.sksl.json\\""',
]));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
......
......@@ -277,6 +277,7 @@ void main() {
r'--split-debug-info=C:\foo\',
'--dart-define=foo=a',
'--dart-define=bar=b',
r'--bundle-sksl-path=foo\bar.sksl.json',
r'--target=lib\main.dart',
]
);
......@@ -297,6 +298,7 @@ void main() {
expect(props.findAllElements('DART_OBFUSCATION').first.text, 'true');
expect(props.findAllElements('SPLIT_DEBUG_INFO').first.text, r'C:\foo\');
expect(props.findAllElements('FLUTTER_TARGET').first.text, r'lib\main.dart');
expect(props.findAllElements('BUNDLE_SKSL_PATH').first.text, r'foo\bar.sksl.json');
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => mockProcessManager,
......
......@@ -105,6 +105,7 @@ void main() {
splitDebugInfoPath: 'foo/',
extraFrontEndOptions: <String>['--enable-experiment=non-nullable', 'bar'],
extraGenSnapshotOptions: <String>['--enable-experiment=non-nullable', 'fizz'],
bundleSkSLPath: 'foo/bar/baz.sksl.json',
);
expect(buildInfo.toEnvironmentConfig(), <String, String>{
......@@ -115,6 +116,7 @@ void main() {
'SPLIT_DEBUG_INFO': 'foo/',
'EXTRA_FRONT_END_OPTIONS': '--enable-experiment%3Dnon-nullable,bar',
'EXTRA_GEN_SNAPSHOT_OPTIONS': '--enable-experiment%3Dnon-nullable,fizz',
'BUNDLE_SKSL_PATH': 'foo/bar/baz.sksl.json',
});
});
......
......@@ -9,8 +9,10 @@ import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/targets/assets.dart';
import 'package:flutter_tools/src/build_system/targets/common.dart';
import 'package:flutter_tools/src/build_system/targets/ios.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
......@@ -46,10 +48,12 @@ void main() {
defines: <String, String>{
kTargetPlatform: 'ios',
},
inputs: <String, String>{},
processManager: processManager,
artifacts: MockArtifacts(),
logger: globals.logger,
fileSystem: globals.fs,
engineVersion: '2',
);
});
});
......@@ -112,6 +116,7 @@ void main() {
}));
test('DebugIosApplicationBundle', () => testbed.run(() async {
environment.inputs[kBundleSkSLPath] = 'bundle.sksl';
environment.defines[kBuildMode] = 'debug';
// Precompiled dart data
when(globals.artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: BuildMode.debug))
......@@ -133,6 +138,16 @@ void main() {
.childDirectory('App.framework')
.childFile('App')
.createSync(recursive: true);
// sksl bundle
globals.fs.file('bundle.sksl').writeAsStringSync(json.encode(
<String, Object>{
'engineRevision': '2',
'platform': 'ios',
'data': <String, Object>{
'A': 'B',
}
}
));
await const DebugIosApplicationBundle().build(environment);
......@@ -145,6 +160,8 @@ void main() {
expect(assetDirectory.childFile('AssetManifest.json'), exists);
expect(assetDirectory.childFile('vm_snapshot_data'), exists);
expect(assetDirectory.childFile('isolate_snapshot_data'), exists);
expect(assetDirectory.childFile('io.flutter.shaders.json'), exists);
expect(assetDirectory.childFile('io.flutter.shaders.json').readAsStringSync(), '{"data":{"A":"B"}}');
}, overrides: <Type, Generator>{
Artifacts: () => MockArtifacts(),
}));
......
......@@ -9,8 +9,10 @@ import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/targets/assets.dart';
import 'package:flutter_tools/src/build_system/targets/common.dart';
import 'package:flutter_tools/src/build_system/targets/linux.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:mockito/mockito.dart';
import '../../../src/common.dart';
......@@ -83,16 +85,29 @@ void main() {
defines: <String, String>{
kBuildMode: 'debug',
},
inputs: <String, String>{
kBundleSkSLPath: 'bundle.sksl',
},
artifacts: MockArtifacts(),
processManager: FakeProcessManager.any(),
fileSystem: fileSystem,
logger: BufferLogger.test(),
engineVersion: '2',
);
testEnvironment.buildDir.createSync(recursive: true);
// Create input files.
testEnvironment.buildDir.childFile('app.dill').createSync();
fileSystem.file('bundle.sksl').writeAsStringSync(json.encode(
<String, Object>{
'engineRevision': '2',
'platform': 'ios',
'data': <String, Object>{
'A': 'B',
}
}
));
await const DebugBundleLinuxAssets().build(testEnvironment);
final Directory output = testEnvironment.outputDir
......@@ -100,6 +115,10 @@ void main() {
expect(output.childFile('kernel_blob.bin'), exists);
expect(output.childFile('AssetManifest.json'), exists);
// SkSL
expect(output.childFile('io.flutter.shaders.json'), exists);
expect(output.childFile('io.flutter.shaders.json').readAsStringSync(), '{"data":{"A":"B"}}');
// No bundled fonts
expect(output.childFile('FontManifest.json'), isNot(exists));
}, overrides: <Type, Generator>{
......
......@@ -9,9 +9,11 @@ import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.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/targets/assets.dart';
import 'package:flutter_tools/src/build_system/targets/common.dart';
import 'package:flutter_tools/src/build_system/targets/macos.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/macos/xcode.dart';
import 'package:mockito/mockito.dart';
......@@ -49,7 +51,7 @@ final List<File> inputs = <File>[
void main() {
Testbed testbed;
Environment environment;
MockPlatform mockPlatform;
Platform platform;
setUpAll(() {
Cache.disableLocking();
......@@ -57,32 +59,25 @@ void main() {
});
setUp(() {
mockPlatform = MockPlatform();
when(mockPlatform.isWindows).thenReturn(false);
when(mockPlatform.isMacOS).thenReturn(true);
when(mockPlatform.isLinux).thenReturn(false);
when(mockPlatform.environment).thenReturn(const <String, String>{});
platform = FakePlatform(operatingSystem: 'macos', environment: <String, String>{});
testbed = Testbed(setup: () {
globals.fs.file(globals.fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'lib', 'ui',
'ui.dart')).createSync(recursive: true);
globals.fs.file(globals.fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'sdk_ext',
'vmservice_io.dart')).createSync(recursive: true);
environment = Environment.test(
globals.fs.currentDirectory,
defines: <String, String>{
kBuildMode: 'debug',
kTargetPlatform: 'darwin-x64',
},
inputs: <String, String>{},
artifacts: MockArtifacts(),
processManager: FakeProcessManager.any(),
logger: globals.logger,
fileSystem: globals.fs,
engineVersion: '2'
);
environment.buildDir.createSync(recursive: true);
}, overrides: <Type, Generator>{
ProcessManager: () => MockProcessManager(),
Platform: () => mockPlatform,
Platform: () => platform,
});
});
......@@ -132,56 +127,86 @@ void main() {
}));
test('debug macOS application creates correctly structured framework', () => testbed.run(() async {
globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
'vm_isolate_snapshot.bin')).createSync(recursive: true);
globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
'isolate_snapshot.bin')).createSync(recursive: true);
globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'App.framework', 'App'))
.createSync(recursive: true);
environment.inputs[kBundleSkSLPath] = 'bundle.sksl';
globals.fs.file('bin/cache/artifacts/engine/darwin-x64/vm_isolate_snapshot.bin')
.createSync(recursive: true);
globals.fs.file('bin/cache/artifacts/engine/darwin-x64/isolate_snapshot.bin')
.createSync(recursive: true);
globals.fs.file('${environment.buildDir.path}/App.framework/App')
.createSync(recursive: true);
// sksl bundle
globals.fs.file('bundle.sksl').writeAsStringSync(json.encode(
<String, Object>{
'engineRevision': '2',
'platform': 'ios',
'data': <String, Object>{
'A': 'B',
}
}
));
final String inputKernel = globals.fs.path.join(environment.buildDir.path, 'app.dill');
final String outputKernel = globals.fs.path.join('App.framework', 'Versions', 'A', 'Resources',
'flutter_assets', 'kernel_blob.bin');
final String outputPlist = globals.fs.path.join('App.framework', 'Versions', 'A', 'Resources',
'Info.plist');
final String inputKernel = '${environment.buildDir.path}/app.dill';
globals.fs.file(inputKernel)
..createSync(recursive: true)
..writeAsStringSync('testing');
await const DebugMacOSBundleFlutterAssets().build(environment);
expect(globals.fs.file(outputKernel).readAsStringSync(), 'testing');
expect(globals.fs.file(outputPlist).readAsStringSync(), contains('io.flutter.flutter.app'));
expect(globals.fs.file(
'App.framework/Versions/A/Resources/flutter_assets/kernel_blob.bin').readAsStringSync(),
'testing',
);
expect(globals.fs.file(
'App.framework/Versions/A/Resources/Info.plist').readAsStringSync(),
contains('io.flutter.flutter.app'),
);
expect(globals.fs.file(
'App.framework/Versions/A/Resources/flutter_assets/vm_snapshot_data'),
exists,
);
expect(globals.fs.file(
'App.framework/Versions/A/Resources/flutter_assets/isolate_snapshot_data'),
exists,
);
final File skslFile = globals.fs.file('App.framework/Versions/A/Resources/flutter_assets/io.flutter.shaders.json');
expect(skslFile, exists);
expect(skslFile.readAsStringSync(), '{"data":{"A":"B"}}');
}));
test('release/profile macOS application has no blob or precompiled runtime', () => testbed.run(() async {
globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
'vm_isolate_snapshot.bin')).createSync(recursive: true);
globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
'isolate_snapshot.bin')).createSync(recursive: true);
globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'App.framework', 'App'))
.createSync(recursive: true);
final String outputKernel = globals.fs.path.join('App.framework', 'Resources',
'flutter_assets', 'kernel_blob.bin');
final String precompiledVm = globals.fs.path.join('App.framework', 'Resources',
'flutter_assets', 'vm_snapshot_data');
final String precompiledIsolate = globals.fs.path.join('App.framework', 'Resources',
'flutter_assets', 'isolate_snapshot_data');
globals.fs.file('bin/cache/artifacts/engine/darwin-x64/vm_isolate_snapshot.bin')
.createSync(recursive: true);
globals.fs.file('bin/cache/artifacts/engine/darwin-x64/isolate_snapshot.bin')
.createSync(recursive: true);
globals.fs.file('${environment.buildDir.path}/App.framework/App')
.createSync(recursive: true);
await const ProfileMacOSBundleFlutterAssets().build(environment..defines[kBuildMode] = 'profile');
expect(globals.fs.file(outputKernel), isNot(exists));
expect(globals.fs.file(precompiledVm), isNot(exists));
expect(globals.fs.file(precompiledIsolate), isNot(exists));
expect(globals.fs.file(
'App.framework/Versions/A/Resources/flutter_assets/kernel_blob.bin'),
isNot(exists),
);
expect(globals.fs.file(
'App.framework/Versions/A/Resources/flutter_assets/vm_snapshot_data'),
isNot(exists),
);
expect(globals.fs.file(
'App.framework/Versions/A/Resources/flutter_assets/isolate_snapshot_data'),
isNot(exists),
);
}));
test('release/profile macOS application updates when App.framework updates', () => testbed.run(() async {
globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
'vm_isolate_snapshot.bin')).createSync(recursive: true);
globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
'isolate_snapshot.bin')).createSync(recursive: true);
globals.fs.file('bin/cache/artifacts/engine/darwin-x64/vm_isolate_snapshot.bin')
.createSync(recursive: true);
globals.fs.file('bin/cache/artifacts/engine/darwin-x64/isolate_snapshot.bin')
.createSync(recursive: true);
final File inputFramework = globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'App.framework', 'App'))
..createSync(recursive: true)
..writeAsStringSync('ABC');
..createSync(recursive: true)
..writeAsStringSync('ABC');
await const ProfileMacOSBundleFlutterAssets().build(environment..defines[kBuildMode] = 'profile');
final File outputFramework = globals.fs.file(globals.fs.path.join(environment.outputDir.path, 'App.framework', 'App'));
......@@ -195,7 +220,6 @@ void main() {
}));
}
class MockPlatform extends Mock implements Platform {}
class MockProcessManager extends Mock implements ProcessManager {}
class MockGenSnapshot extends Mock implements GenSnapshot {}
class MockXcode extends Mock implements Xcode {}
......
......@@ -11,8 +11,10 @@ import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/depfile.dart';
import 'package:flutter_tools/src/build_system/targets/assets.dart';
import 'package:flutter_tools/src/build_system/targets/common.dart';
import 'package:flutter_tools/src/build_system/targets/windows.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:mockito/mockito.dart';
import '../../../src/common.dart';
......@@ -50,7 +52,7 @@ void main() {
logger: BufferLogger.test(),
defines: <String, String>{
kBuildMode: 'debug',
}
},
);
final DepfileService depfileService = DepfileService(
logger: BufferLogger.test(),
......@@ -149,10 +151,24 @@ void main() {
logger: BufferLogger.test(),
defines: <String, String>{
kBuildMode: 'debug',
}
},
inputs: <String, String>{
kBundleSkSLPath: 'bundle.sksl',
},
engineVersion: '2',
);
environment.buildDir.childFile('app.dill').createSync(recursive: true);
// sksl bundle
fileSystem.file('bundle.sksl').writeAsStringSync(json.encode(
<String, Object>{
'engineRevision': '2',
'platform': 'ios',
'data': <String, Object>{
'A': 'B',
}
}
));
await const DebugBundleWindowsAssets().build(environment);
......@@ -160,6 +176,8 @@ void main() {
expect(environment.buildDir.childFile('flutter_assets.d'), exists);
expect(fileSystem.file(r'C:\flutter_assets\kernel_blob.bin'), exists);
expect(fileSystem.file(r'C:\flutter_assets\AssetManifest.json'), exists);
expect(fileSystem.file(r'C:\flutter_assets\io.flutter.shaders.json'), exists);
expect(fileSystem.file(r'C:\flutter_assets\io.flutter.shaders.json').readAsStringSync(), '{"data":{"A":"B"}}');
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
......
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