[Buildroot] [PATCH v3 11/11] package/flutter-sdk-bin/Config.in.host: add pub-cache location option
Adam Duskett
adam.duskett at amarulasolutions.com
Tue Jan 2 23:59:33 UTC 2024
When running the command "flutter pub get," the plugins are stored in the
pub-cache directory along with their sha256sum hashes. The default location of
the pub-cache directory is current $(HOST_DIR)/share/flutter/sdk/.pub-cache,
which is not an acceptable choice by default because every plugin is
re-downloaded during every build of a flutter application either during a new
build or when building with the per-package-directory option enabled.
Furthermore, keeping the pub-cache in its current location prevents users from
committing the pub-cache directory to git for faster rebuilds of a
Buildroot-based system, as a user cannot store the pub-cache for later use.
To fix the above issue, add a new option to flutter-sdk-bin/Config.in.host,
BR2_PACKAGE_HOST_FLUTTER_SDK_BIN_PUB_CACHE_LOCATION and set the default to
$(DL_DIR)/br-flutter-pub-cache. While hard-coding the location is generally
preferable, a developer may already have a working pub-cache at a different
location. Setting this option to a string provides no downsides, and the
default location is now set to a sane default, providing an optimal solution
to the problem above.
Signed-off-by: Adam Duskett <adam.duskett at amarulasolutions.com>
---
package/flutter-sdk-bin/Config.in.host | 11 +++++++++++
package/flutter-sdk-bin/flutter-sdk-bin.mk | 2 +-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/package/flutter-sdk-bin/Config.in.host b/package/flutter-sdk-bin/Config.in.host
index 181a2ee6e5..a1ac5835d9 100644
--- a/package/flutter-sdk-bin/Config.in.host
+++ b/package/flutter-sdk-bin/Config.in.host
@@ -13,3 +13,14 @@ config BR2_PACKAGE_HOST_FLUTTER_SDK_BIN
free and open source.
https://flutter.dev/
+
+if BR2_PACKAGE_HOST_FLUTTER_SDK_BIN_ARCH_SUPPORTS
+
+config BR2_PACKAGE_HOST_FLUTTER_SDK_BIN_PUB_CACHE_LOCATION
+ string "pub-cache location"
+ default "$(DL_DIR)/br-flutter-pub-cache"
+ help
+ Directory to store cached packages used by Pub with
+ Dart/Flutter.
+
+endif
diff --git a/package/flutter-sdk-bin/flutter-sdk-bin.mk b/package/flutter-sdk-bin/flutter-sdk-bin.mk
index e7fd09cb56..5edd53df28 100644
--- a/package/flutter-sdk-bin/flutter-sdk-bin.mk
+++ b/package/flutter-sdk-bin/flutter-sdk-bin.mk
@@ -105,4 +105,4 @@ HOST_FLUTTER_SDK_BIN_DART_BIN = \
$(eval $(host-generic-package))
# For target packages to locate said pub-cache
-FLUTTER_SDK_BIN_PUB_CACHE = $(HOST_FLUTTER_SDK_BIN_SDK)/.pub-cache
+FLUTTER_SDK_BIN_PUB_CACHE = $(call qstrip,$(BR2_PACKAGE_HOST_FLUTTER_SDK_BIN_PUB_CACHE_LOCATION))
--
2.43.0
More information about the buildroot
mailing list