Skip to content

chore: adopt dart native build hooks#236

Open
HamdaanAliQuatil wants to merge 6 commits intomasterfrom
native-hooks
Open

chore: adopt dart native build hooks#236
HamdaanAliQuatil wants to merge 6 commits intomasterfrom
native-hooks

Conversation

@HamdaanAliQuatil
Copy link
Copy Markdown
Collaborator

Closes #192

@jonasfj
Copy link
Copy Markdown
Member

jonasfj commented Nov 17, 2025

This is awesome! But we probably need to fix lints and get the tests to pass :D

Comment thread pubspec.yaml
@jonasfj
Copy link
Copy Markdown
Member

jonasfj commented Nov 24, 2025

Do we have any idea what is wrong with the desktop platforms?

Comment thread pubspec.yaml
@HamdaanAliQuatil HamdaanAliQuatil changed the base branch from master to changelog December 14, 2025 06:43
@HamdaanAliQuatil HamdaanAliQuatil changed the base branch from changelog to master December 14, 2025 06:43
Comment thread hook/build.dart
@HamdaanAliQuatil HamdaanAliQuatil force-pushed the native-hooks branch 2 times, most recently from dacb521 to 5a70dff Compare February 27, 2026 20:29
Comment thread hook/build.dart Outdated
}

final targetOs = input.config.code.targetOS;
if (!_hostSupports(targetOs)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we don't support building for Android?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had added a guard in the hook that restricted it to desktop targets while testing the VM path, and I failed to remove it afterward. I’ve removed that restriction now.

Android still passes in CI after that change. The Android log also shows native build-related activity, including native_toolchain_cmake being resolved and a rebuild after File modified during build.

Comment thread hook/build.dart Outdated
Abi.linuxArm64,
Abi.macosArm64,
Abi.windowsArm64,
}.contains(Abi.current());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is Abi.current()?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Abi.current() is the ABI of the Dart process running the hook.

I had used it as a host-architecture guard, but that was the wrong abstraction here since the actual target already comes from input.config.code. Ive removed it.

Comment thread hook/build.dart Outdated
packageRoot.resolve('src/webcrypto.c'),
packageRoot.resolve('src/webcrypto.h'),
packageRoot.resolve('src/symbols.generated.c'),
packageRoot.resolve('third_party/boringssl/sources.cmake'),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have way more dependencies? What is this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are hook invalidation dependencies, not linker dependencies.

I was using a small hand-maintained list of obvious inputs, but that seems too ad hoc. I've changed it to collect actual native build inputs from src/ and third_party/boringssl/ instead.


concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does this come from and how is it related?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to change CI in this PR?

If we need to change CI, can we do it in an independent PR that discusses why are making those changes.

- run: flutter test --coverage
- run: flutter test --platform chrome
- run: flutter test --platform chrome --wasm
- run: dart test -p chrome -c dart2wasm
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This very cool, now we can test with dart test too.

- name: Run integration_test with chromedriver
working-directory: ./example
run: |
xvfb-run ../tool/with-chromedriver.sh flutter drive \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this stopped working, but that should land in a different PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use Dart native build hooks for packaging

3 participants