Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .fvmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"flutter": "3.44.6"
}
"flutter": "3.47.5"
}
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: .fvmrc
cache: true

- name: Setup Zig
Expand Down Expand Up @@ -70,6 +71,7 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: .fvmrc
cache: true

- name: Setup Zig
Expand Down Expand Up @@ -103,6 +105,7 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: .fvmrc
cache: true

- name: Setup Zig
Expand Down Expand Up @@ -133,6 +136,7 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: .fvmrc
cache: true

- name: Setup Zig
Expand All @@ -151,6 +155,17 @@ jobs:
flutter pub get
flutter build macos --debug

- name: Build macOS example (Release)
run: |
set -o pipefail
cd example
build_log="$RUNNER_TEMP/flutter-macos-release.log"
flutter build macos --release 2>&1 | tee "$build_log"
if grep -Fq 'different framework names for different architectures' "$build_log"; then
echo 'Flutter reported inconsistent code asset framework names.' >&2
exit 1
fi

build-linux:
runs-on: ubuntu-latest

Expand All @@ -169,6 +184,7 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: .fvmrc
cache: true

- name: Setup Zig
Expand Down Expand Up @@ -200,6 +216,7 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: .fvmrc
cache: true

- name: Setup Zig
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: .fvmrc
cache: true

- name: Setup Zig
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pub-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: .fvmrc
cache: true

- name: Setup Zig
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Releases

## Unreleased

### Changed

* Pin development to Flutter 3.47.5 and update the minimum SDK constraints for
the current native-assets dependencies.
* Use the pinned Flutter version in CI and verify the macOS Release build does
not report inconsistent code asset framework names.
* Upgrade `code_assets`, `hooks`, and `ffigen`; move `test` to the newest
version compatible with the `flutter_test` SDK pin.
* Raise the example app's macOS deployment target to 12.0 for Flutter 3.47.
* Document how to compare this customized package with a freshly generated
`package_ffi` template while preserving Android `content://` support.

---

## 0.0.4

* Hash Android `content://` URIs through `ContentResolver.openFileDescriptor`
Expand Down
34 changes: 32 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,43 @@

## Setup

Use Flutter stable, Zig, and the platform SDKs for the targets you want to
build. The CI Zig version is defined in
Use the Flutter version in `.fvmrc`, Zig, and the platform SDKs for the targets
you want to build. The CI Zig version is defined in
`.github/actions/setup-zig/action.yml`.

If you do not use FVM locally, replace `fvm flutter` and `fvm dart` with
`flutter` and `dart`.

## Flutter Template Updates

The package starts from Flutter's `package_ffi` template, with a custom Zig
build hook and an Android plugin layer for `content://` access. Flutter updates
the templates inside each SDK release; there is no safe in-place command that
merges every upstream template change into this customized package.

To review a template update after changing the Flutter version in `.fvmrc`,
generate a clean copy with the same package name. Compare only the relevant
template files, not the entire repository (which also contains build outputs,
prebuilts, and custom platform code):

```bash
template_dir="$(mktemp -d)"
fvm flutter create --template=package_ffi --project-name flutter_file_hash \
--no-pub "$template_dir/flutter_file_hash"
for file in pubspec.yaml analysis_options.yaml ffigen.yaml hook/build.dart \
example/pubspec.yaml example/analysis_options.yaml \
example/macos/Runner.xcodeproj/project.pbxproj; do
diff -u "$template_dir/flutter_file_hash/$file" "$file" || true
done
```

Extend the file list when reviewing another platform's generated project.
Keep the custom `hook/build.dart`, Android `FlutterFileHashPlugin`, JNI/CMake
bridge, prebuilt layout, and handwritten FFI bindings intact unless the
corresponding package behavior is deliberately being changed. `.metadata`
records Flutter project metadata; it is not a general dependency or template
synchronizer.

Initialize the Zig submodule:

```bash
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,27 +376,26 @@ directly and avoid that extra copy.

## FFI/native-assets Template Usage

`flutter_file_hash` uses Flutter's modern `plugin_ffi`/native-assets path for
the native hash core. The public Dart API talks to one Zig native core through
the C ABI; platform code is used only where the operating system does not expose
a regular file path to Dart.
`flutter_file_hash` uses Flutter's `package_ffi` build-hook/native-assets path
for the Zig hash core. Android also has a small Flutter plugin layer because
`ContentResolver` is needed to open `content://` URIs. The public Dart API calls
the same Zig C ABI on every platform.

macOS release builds can print a native-assets packaging warning like:
Flutter versions before 3.47.0 could print this warning during macOS release
builds:

```text
Code asset "package:flutter_file_hash/src/zig_files_hash_bindings.dart" has
different framework names for different architectures. Picking
"zig_files_hash_c_api.framework" and ignoring "zig_files_hash_c_api1.framework".
```

This comes from Flutter's macOS `code_assets` packaging path when it combines
multiple architectures into one app bundle. The generated app bundle still
contains the expected universal native framework, so the warning can be ignored.
Flutter fixed multi-architecture code asset framework naming in 3.47.0
([Flutter #185640](https://github.com/flutter/flutter/pull/185640)). A macOS
Release build with Flutter 3.47.5 completed without this warning.

The strategy is to keep `plugin_ffi`/native-assets for the Zig core and adopt
upstream Flutter fixes when macOS native-assets packaging improves. Android
platform code remains limited to opening provider URIs, as described in Android
URI Streams.
The Android plugin opens provider URIs and passes file descriptors or streams
to the shared Zig core, as described in Android URI Streams.

## Performance

Expand Down Expand Up @@ -435,4 +434,5 @@ Contributions are welcome.

MIT. See [LICENSE](LICENSE) for details.

Built on Flutter's `plugin_ffi`/native-assets template.
Built with Flutter's `package_ffi` build hooks and an Android plugin for
`content://` access.
4 changes: 4 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
analyzer:
exclude:
- build/**
- android/**
include: package:flutter_lints/flutter.yaml

# Additional information about this file can be found at
Expand Down
3 changes: 3 additions & 0 deletions example/.fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"flutter": "3.47.5"
}
3 changes: 3 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release

# FVM Version Cache
.fvm/
9 changes: 9 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
analyzer:
exclude:
- build/**
- android/**
- ios/**
- web/**
- windows/**
- macos/**
- linux/**
include: package:flutter_lints/flutter.yaml

linter:
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -487,7 +487,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -538,7 +538,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
43 changes: 16 additions & 27 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -934,9 +934,8 @@ class _HashDemoPageState extends State<HashDemoPage> {
}

void _showMessage(String message) {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text(message)));
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(message)));
}
}

Expand All @@ -954,17 +953,14 @@ class _Header extends StatelessWidget {
children: [
Text(
'File Hash',
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
color: palette.text,
fontWeight: FontWeight.w800,
),
style: Theme.of(context).textTheme.headlineSmall
?.copyWith(color: palette.text, fontWeight: FontWeight.w800),
),
const SizedBox(height: 4),
Text(
'Native streaming hash (MD5 / SHA / XXH3 / BLAKE3)',
style: Theme.of(
context,
).textTheme.bodyMedium?.copyWith(color: palette.muted),
style: Theme.of(context).textTheme.bodyMedium
?.copyWith(color: palette.muted),
),
],
),
Expand Down Expand Up @@ -1005,10 +1001,8 @@ class _CardPanel extends StatelessWidget {
children: [
Text(
title,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
color: palette.text,
fontWeight: FontWeight.w700,
),
style: Theme.of(context).textTheme.titleMedium
?.copyWith(color: palette.text, fontWeight: FontWeight.w700),
),
const SizedBox(height: 10),
...children,
Expand Down Expand Up @@ -1248,17 +1242,14 @@ class _FileDetails extends StatelessWidget {
children: [
Text(
file.name,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: palette.text,
fontWeight: FontWeight.w600,
),
style: Theme.of(context).textTheme.bodyMedium
?.copyWith(color: palette.text, fontWeight: FontWeight.w600),
),
const SizedBox(height: 4),
SelectableText(
'${_fileSizeLabel(file.size)} - ${file.displayPath}',
style: Theme.of(
context,
).textTheme.bodySmall?.copyWith(color: palette.muted),
style: Theme.of(context).textTheme.bodySmall
?.copyWith(color: palette.muted),
),
],
);
Expand All @@ -1285,19 +1276,17 @@ class _DigestResult extends StatelessWidget {
children: [
Text(
'Result',
style: Theme.of(
context,
).textTheme.labelSmall?.copyWith(color: palette.muted),
style: Theme.of(context).textTheme.labelSmall
?.copyWith(color: palette.muted),
),
const SizedBox(height: 6),
SelectableText(digest, style: _monoStyle(context, palette)),
if (elapsedMs != null) ...[
const SizedBox(height: 8),
Text(
_formatMs(elapsedMs),
style: Theme.of(
context,
).textTheme.labelSmall?.copyWith(color: palette.muted),
style: Theme.of(context).textTheme.labelSmall
?.copyWith(color: palette.muted),
),
],
],
Expand Down
6 changes: 3 additions & 3 deletions example/macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down Expand Up @@ -553,7 +553,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -603,7 +603,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
Loading
Loading