[flutter_tools] wire up complete support for Dart obfuscation (#50509)
This commit is contained in:
62
dev/devicelab/bin/tasks/android_obfuscate_test.dart
Normal file
62
dev/devicelab/bin/tasks/android_obfuscate_test.dart
Normal file
@@ -0,0 +1,62 @@
|
||||
// Copyright 2014 The Flutter 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 'dart:async';
|
||||
|
||||
import 'package:flutter_devicelab/framework/apk_utils.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
try {
|
||||
bool foundProjectName = false;
|
||||
await runProjectTest((FlutterProject flutterProject) async {
|
||||
section('APK content for task assembleRelease with --obfuscate');
|
||||
await inDirectory(flutterProject.rootPath, () async {
|
||||
await flutter('build', options: <String>[
|
||||
'apk',
|
||||
'--target-platform=android-arm',
|
||||
'--obfuscate',
|
||||
'--split-debug-info=foo/',
|
||||
]);
|
||||
});
|
||||
final String outputDirectory = path.join(
|
||||
flutterProject.rootPath,
|
||||
'build/app/outputs/apk/release/app-release.apk',
|
||||
);
|
||||
final Iterable<String> apkFiles = await getFilesInApk(outputDirectory);
|
||||
|
||||
checkCollectionContains<String>(<String>[
|
||||
...flutterAssets,
|
||||
...baseApkFiles,
|
||||
'lib/armeabi-v7a/libapp.so',
|
||||
], apkFiles);
|
||||
|
||||
// Verify that an identifier from the Dart project code is not present
|
||||
// in the compiled binary.
|
||||
await inDirectory(flutterProject.rootPath, () async {
|
||||
await exec('unzip', <String>[outputDirectory]);
|
||||
final String response = await eval(
|
||||
'grep',
|
||||
<String>[flutterProject.name, 'lib/armeabi-v7a/libapp.so'],
|
||||
canFail: true,
|
||||
);
|
||||
if (response.trim().contains('matches')) {
|
||||
foundProjectName = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
if (foundProjectName) {
|
||||
return TaskResult.failure('Found project name in obfuscated dart library');
|
||||
}
|
||||
return TaskResult.success(null);
|
||||
} on TaskResult catch (taskResult) {
|
||||
return taskResult;
|
||||
} catch (e) {
|
||||
return TaskResult.failure(e.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
58
dev/devicelab/bin/tasks/ios_obfuscate_test.dart
Normal file
58
dev/devicelab/bin/tasks/ios_obfuscate_test.dart
Normal file
@@ -0,0 +1,58 @@
|
||||
// Copyright 2014 The Flutter 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 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_devicelab/framework/apk_utils.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
try {
|
||||
bool foundProjectName = false;
|
||||
await runProjectTest((FlutterProject flutterProject) async {
|
||||
section('iOS Framework content with --obfuscate');
|
||||
await inDirectory(flutterProject.rootPath, () async {
|
||||
await flutter('build', options: <String>[
|
||||
'ios',
|
||||
'--release',
|
||||
'--obfuscate',
|
||||
'--split-debug-info=foo/',
|
||||
]);
|
||||
});
|
||||
final String outputFramework = path.join(
|
||||
flutterProject.rootPath,
|
||||
'build/ios/iphoneos/Runner.app/Frameworks/App.framework/App',
|
||||
);
|
||||
if (!File(outputFramework).existsSync()) {
|
||||
fail('Failed to produce expected output at $outputFramework');
|
||||
}
|
||||
|
||||
// Verify that an identifier from the Dart project code is not present
|
||||
// in the compiled binary.
|
||||
await inDirectory(flutterProject.rootPath, () async {
|
||||
final String response = await eval(
|
||||
'grep',
|
||||
<String>[flutterProject.name, outputFramework],
|
||||
canFail: true,
|
||||
);
|
||||
if (response.trim().contains('matches')) {
|
||||
foundProjectName = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
if (foundProjectName) {
|
||||
return TaskResult.failure('Found project name in obfuscated dart library');
|
||||
}
|
||||
return TaskResult.success(null);
|
||||
} on TaskResult catch (taskResult) {
|
||||
return taskResult;
|
||||
} catch (e) {
|
||||
return TaskResult.failure(e.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -319,6 +319,13 @@ tasks:
|
||||
stage: devicelab
|
||||
required_agent_capabilities: ["mac/android"]
|
||||
|
||||
android_obfuscate_test:
|
||||
description: >
|
||||
Builds an obfuscated APK and verifies a dart identifier cannot be found
|
||||
stage: devicelab
|
||||
flaky: true
|
||||
required_agent_capabilities: ["linux/android"]
|
||||
|
||||
complex_layout_semantics_perf:
|
||||
description: >
|
||||
Measures duration of building the initial semantics tree.
|
||||
@@ -390,6 +397,13 @@ tasks:
|
||||
|
||||
# iOS on-device tests
|
||||
|
||||
ios_obfuscate_test:
|
||||
description: >
|
||||
Builds an obfuscated APK and verifies a dart identifier cannot be found
|
||||
stage: devicelab
|
||||
flaky: true
|
||||
required_agent_capabilities: ["mac/ios"]
|
||||
|
||||
tiles_scroll_perf_ios__timeline_summary:
|
||||
description: >
|
||||
Measures the runtime performance of the tiles tab in the Complex Layout sample app on iPhone 6.
|
||||
|
||||
Reference in New Issue
Block a user