Skip to content

Commit

Permalink
Remove FLUTTER_CACHE_FOLDER and FLUTTER_DATA_FOLDER
Browse files Browse the repository at this point in the history
  • Loading branch information
anhappdev committed May 28, 2024
1 parent 9d5577e commit 0a6e2b7
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 284 deletions.
18 changes: 0 additions & 18 deletions docs/custom-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,6 @@ Data directory can be changed in settings, except for iOS, and its possible loca
You can specify the full path, which will not depend on the data folder.
Absolute path is only available for the task config path. All local resources in the task config must point to the data folder.

## Overriding default folders

You can change the data folder without using graphical interface.

Use `--dart-define=FLUTTER_DATA_FOLDER=<value>` to specify the folder you want to use.
It will still be possible to choose a different folder via UI but the app will use specified folder by default.

If you build the app using makefile commands, use `FLUTTER_DATA_FOLDER` environment variable. For example: `make flutter/test/integration FLUTTER_CACHE_FOLDER=/my/folder/path`

You can also override app cache folder.
Use `--dart-define=FLUTTER_CACHE_FOLDER=<value>` for manual build or `FLUTTER_CACHE_FOLDER` env for makefile script.
Note that it's impossible to change the cache folder from the UI.

These options are intended for CI use, and possibly for internal testing.
Never use them for any public builds.

These options are not available on iOS.

## Using external resources on an iPhone

On iOS an application resource folder can be found in `On My iPhone` -> `<app name>`.
Expand Down
2 changes: 0 additions & 2 deletions flutter/android/android-docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ flutter_common_docker_flags= \
--env FIREBASE_CRASHLYTICS_ENABLED=${FIREBASE_CRASHLYTICS_ENABLED} \
--env FLUTTER_BUILD_NUMBER=${FLUTTER_BUILD_NUMBER} \
--env FLUTTER_FORCE_PUB_GET=1 \
--env FLUTTER_DATA_FOLDER=${FLUTTER_DATA_FOLDER} \
--env FLUTTER_CACHE_FOLDER=${FLUTTER_CACHE_FOLDER} \
${proxy_docker_args} \
${backend_qti_flutter_docker_args} \
${backend_samsung_docker_args} \
Expand Down
6 changes: 2 additions & 4 deletions flutter/android/android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,15 @@ flutter/android/apk:
cd flutter && ${_start_args} flutter --no-version-check build apk \
${flutter_official_build_arg} \
${flutter_firebase_crashlytics_arg} \
${flutter_build_number_arg} \
${flutter_folder_args}
${flutter_build_number_arg}
cp -f flutter/build/app/outputs/flutter-apk/app-release.apk ${flutter_android_apk_release_path}.apk
.PHONY: flutter/android/appbundle
flutter/android/appbundle:
mkdir -p $$(dirname ${flutter_android_apk_release_path})
cd flutter && ${_start_args} flutter --no-version-check build appbundle \
${flutter_official_build_arg} \
${flutter_firebase_crashlytics_arg} \
${flutter_build_number_arg} \
${flutter_folder_args}
${flutter_build_number_arg}
cp -f flutter/build/app/outputs/bundle/release/app-release.aab ${flutter_android_apk_release_path}.aab

FLUTTER_ANDROID_APK_TEST_MAIN?=test-main.apk
Expand Down
16 changes: 1 addition & 15 deletions flutter/flutter.mk
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,6 @@ flutter/check/build-number:
@[ -n "$$FLUTTER_BUILD_NUMBER" ] \
|| (echo FLUTTER_BUILD_NUMBER env must be explicitly set; exit 1)

ifneq (${FLUTTER_DATA_FOLDER},)
flutter_data_folder_arg="--dart-define=FLUTTER_DATA_FOLDER=${FLUTTER_DATA_FOLDER}"
else
flutter_data_folder_arg=
endif
ifneq (${FLUTTER_CACHE_FOLDER},)
flutter_cache_folder_arg="--dart-define=FLUTTER_CACHE_FOLDER=${FLUTTER_CACHE_FOLDER}"
else
flutter_cache_folder_arg=
endif
flutter_folder_args=${flutter_data_folder_arg} ${flutter_cache_folder_arg}

FIREBASE_CRASHLYTICS_ENABLED?=false
flutter_firebase_crashlytics_arg="--dart-define=FIREBASE_CRASHLYTICS_ENABLED=${FIREBASE_CRASHLYTICS_ENABLED}"

Expand Down Expand Up @@ -180,15 +168,13 @@ flutter/test/integration:
${flutter_test_device_arg} \
${flutter_official_build_arg} \
${flutter_firebase_crashlytics_arg} \
${flutter_perf_test_arg} \
${flutter_folder_args}
${flutter_perf_test_arg}

.PHONY: flutter/run
flutter/run:
cd flutter && ${_start_args} \
flutter --no-version-check \
run \
${flutter_folder_args} \
${flutter_test_device_arg} \
${flutter_official_build_arg} \
${flutter_firebase_crashlytics_arg}
Expand Down
4 changes: 0 additions & 4 deletions flutter/lib/app_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ class DartDefine {
bool.fromEnvironment('FIREBASE_CRASHLYTICS_ENABLED', defaultValue: false);
static const isFastMode =
bool.fromEnvironment('FAST_MODE', defaultValue: false);
static const defaultCacheFolder =
String.fromEnvironment('FLUTTER_CACHE_FOLDER');
static const defaultDataFolder =
String.fromEnvironment('FLUTTER_DATA_FOLDER');
}

class WidgetKeys {
Expand Down
9 changes: 0 additions & 9 deletions flutter/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,6 @@
"settingsTaskConfigLocalResource": "local",
"settingsTaskConfigError": "Path to config is invalid:",
"settingsTaskDataFolderTitle": "Data folder",
"settingsTaskDataFolderDesc": "Task config may contain non-downloadable files that must be managed manually.",
"settingsTaskDataFolderDefault": "Default",
"settingsTaskDataFolderApp": "Application folder",
"settingsTaskDataFolderCustom": "Custom folder",
"settingsTaskDataFolderSelected": "Selected data folder",
"settingsTaskDataFolderWarning": "Folder <path> does not exist or is not accessible",
"settingsTaskCacheFolderTitle": "Cache folder",
"settingsTaskCacheFolderDesc": "Cache folder contains downloadable data.\nThis folder can only be changed during build.",
"settingsTaskCacheFolderDefault": "Default",
"settingsClearCache": "Clear cache",
"settingsClearCacheConfirm": "All loaded resources will be deleted and downloaded again. Continue?",
"settingsUnableSpecifyConfiguration": "Could not specify until benchmarks is running or content is loading",
Expand Down
25 changes: 6 additions & 19 deletions flutter/lib/resources/resource_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import 'package:flutter/foundation.dart';
import 'package:crypto/crypto.dart';
import 'package:path_provider/path_provider.dart';

import 'package:mlperfbench/app_constants.dart';
import 'package:mlperfbench/resources/cache_manager.dart';
import 'package:mlperfbench/resources/resource.dart';
import 'package:mlperfbench/resources/result_manager.dart';
import 'package:mlperfbench/resources/utils.dart';
import 'package:mlperfbench/store.dart';
import 'package:mlperfbench/ui/settings/data_folder_type.dart';

class ResourceManager {
static const _dataPrefix = 'local://';
Expand Down Expand Up @@ -60,18 +58,11 @@ class ResourceManager {
}

String getDataFolder() {
switch (parseDataFolderType(store.dataFolderType)) {
case DataFolderType.default_:
if (DartDefine.defaultDataFolder.isNotEmpty) {
return DartDefine.defaultDataFolder;
} else {
return applicationDirectory;
}
case DataFolderType.appFolder:
return applicationDirectory;
case DataFolderType.custom:
return store.customDataFolder;
}
return applicationDirectory;
}

String getDataPrefix() {
return _dataPrefix;
}

Future<bool> isResourceExist(String? uri) async {
Expand Down Expand Up @@ -152,11 +143,7 @@ class ResourceManager {
Future<void> initSystemPaths() async {
applicationDirectory = await getApplicationDirectory();
await Directory(applicationDirectory).create(recursive: true);
if (DartDefine.defaultCacheFolder.isNotEmpty) {
_loadedResourcesDir = DartDefine.defaultCacheFolder;
} else {
_loadedResourcesDir = '$applicationDirectory/$_loadedResourcesDirName';
}
_loadedResourcesDir = '$applicationDirectory/$_loadedResourcesDirName';
await Directory(_loadedResourcesDir).create();

cacheManager = CacheManager(_loadedResourcesDir);
Expand Down
16 changes: 0 additions & 16 deletions flutter/lib/store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,6 @@ class Store extends ChangeNotifier {
notifyListeners();
}

String get dataFolderType => _getString(StoreConstants.dataFolderType);

set dataFolderType(String value) {
_storeFromDisk.setString(StoreConstants.dataFolderType, value);
notifyListeners();
}

String get customDataFolder => _getString(StoreConstants.customDataFolder);

set customDataFolder(String value) {
_storeFromDisk.setString(StoreConstants.customDataFolder, value);
notifyListeners();
}

String get taskSelection => _getString(StoreConstants.taskSelection);

set taskSelection(String value) {
Expand Down Expand Up @@ -152,8 +138,6 @@ class StoreConstants {
static const previousExtendedResult = 'previous extended result';
static const previousAppVersion = 'previous app version';
static const keepLogs = 'keep_logs';
static const dataFolderType = 'data folder type';
static const customDataFolder = 'custom data folder';
static const taskSelection = 'disabled_tasks';
static const testMinDuration = 'test min duration';
static const testCooldownDuration = 'test cooldown duration';
Expand Down
17 changes: 0 additions & 17 deletions flutter/lib/ui/settings/data_folder_type.dart

This file was deleted.

Loading

0 comments on commit 0a6e2b7

Please sign in to comment.