-
Notifications
You must be signed in to change notification settings - Fork 101
feat: add prebuilt native asset hook support #275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
HamdaanAliQuatil
wants to merge
2
commits into
master
Choose a base branch
from
native-prebuilt-assets
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| name: build-prebuilt-assets | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| # This workflow only produces artifacts. Maintainers can review and commit the | ||
| # resulting prebuilts in a follow-up PR or release-prep change. | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build prebuilt asset (${{ matrix.asset_os }} / ${{ matrix.asset_arch }}) | ||
| runs-on: ${{ matrix.runner }} | ||
| timeout-minutes: 30 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - runner: ubuntu-latest | ||
| asset_os: linux | ||
| asset_arch: x64 | ||
| library_name: libwebcrypto.so | ||
| - runner: windows-latest | ||
| asset_os: windows | ||
| asset_arch: x64 | ||
| library_name: webcrypto.dll | ||
| - runner: macos-13 | ||
| asset_os: macos | ||
| asset_arch: x64 | ||
| library_name: libwebcrypto.dylib | ||
| - runner: macos-15 | ||
| asset_os: macos | ||
| asset_arch: arm64 | ||
| library_name: libwebcrypto.dylib | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install NASM | ||
| if: runner.os == 'Windows' | ||
| uses: ilammy/setup-nasm@v1 | ||
|
|
||
| - name: Configure Linux dependencies | ||
| if: runner.os == 'Linux' | ||
| run: | | ||
| sudo apt-get update -y | ||
| sudo apt-get install -y ninja-build | ||
|
|
||
| - name: Build native library | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| build_dir="$PWD/build/prebuilt" | ||
| install_dir="$PWD/build/prebuilt-install" | ||
| rm -rf "$build_dir" "$install_dir" | ||
|
|
||
| cmake -S src -B "$build_dir" \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DCMAKE_INSTALL_PREFIX="$install_dir" | ||
|
|
||
| cmake --build "$build_dir" --config Release --target install | ||
|
|
||
| staged_dir="prebuilt/${{ matrix.asset_os }}/${{ matrix.asset_arch }}" | ||
| mkdir -p "$staged_dir" | ||
| cp "$install_dir/${{ matrix.library_name }}" "$staged_dir/${{ matrix.library_name }}" | ||
|
|
||
| - name: Upload prebuilt artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: webcrypto-prebuilt-${{ matrix.asset_os }}-${{ matrix.asset_arch }} | ||
| path: prebuilt/${{ matrix.asset_os }}/${{ matrix.asset_arch }}/${{ matrix.library_name }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| Prebuilt native assets | ||
| ====================== | ||
|
|
||
| This directory is reserved for prebuilt `webcrypto` native libraries that can | ||
| be bundled by `hook/build.dart` without requiring a local C/C++ toolchain. | ||
|
|
||
| These binaries should be generated by maintainer-triggered CI from merged | ||
| source, then committed by a maintainer. They should not be accepted from | ||
| user-authored PRs. | ||
|
|
||
| Expected layout: | ||
|
|
||
| - `prebuilt/<os>/<architecture>/<library-file>` | ||
|
|
||
| Examples: | ||
|
|
||
| - `prebuilt/linux/x64/libwebcrypto.so` | ||
| - `prebuilt/macos/arm64/libwebcrypto.dylib` | ||
| - `prebuilt/windows/x64/webcrypto.dll` | ||
|
|
||
| If a matching prebuilt is present for the current target, the build hook will | ||
| stage and bundle it. If not, the hook will fall back to building from source. | ||
|
|
||
| Expected refresh policy: | ||
|
|
||
| - refresh on release preparation | ||
| - refresh after native-impacting changes | ||
| - do not rebuild on a time-based schedule | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want to highlight alternative options, in no particular order.
prebuilt/as part of the automated publishing job, they are always build github actions and published inside the package to pub.devprebuilt/and upload as artifacts on the github release we create when we create a new version, the hook will then have to download these from github releases.prebuilt/and then commit them to git.(C) has the downside that repository size will increase significantly over time, especially if we add more architectures/platforms.
(A) has the downside that download size of users will increase, but not that much. pub.dev will refuse packages larger than 100mb or 200mb (I don't recall the exact limits), but we'll probably be okay unless we add many architectures.
If we can build the artifacts in github CI, then perhaps (A) is attractive? We also avoid maintainer churn and avoid having to store binary artifacts in github.