Skip to content

Commit b324678

Browse files
authored
[infra] Split up package:native_assets_cli (#2259)
Closes: #999 Splits up `package:native_assets_cli` in `package:hooks`, `package:code_assets` and `package:data_assets`. Renames `package:native_assets_builder` to `package:hooks_runner`. The dependencies are as follows: * `hooks` has dev dependencies on `code_assets` and `data_assets` because all the integration tests use these asset types. * `hooks_runner` has a dependency on `code_assets` due to the kernel-encoding `KernelAssets` which is used to bundle the code-assets asset-mapping in various SDKs. * `hooks_runner` has a dev dependency on `data_assets` because the integration tests use it. Versions: * The split up packages continue numbering from the original version. (It doesn't really matter, we'll need to go to 1.0.0 in the future anyway.) Internal package structure: * This PR does not reorganize packages. It moves the files exactly to the same path. This could use cleanup, but let's try to get this PR as small as possible. CI: * Two workflows are combined. (This could likely use some cleanup, especially trying to collect coverage across all packages in the workspace instead of a single package at the time.) Publishing: * These packages will now need their autopublishing set up. I'll do this after we bump the version to non-wip. Rolling: * This will need to be rolled into the Dart and Flutter SDKs. Changing the dependencies there and fixing whatever test setup explicitly mentioning the package names.
1 parent 7bca903 commit b324678

File tree

521 files changed

+1005
-1099
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

521 files changed

+1005
-1099
lines changed

.github/ISSUE_TEMPLATE/code_assets.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
name: "package:code_assets"
3+
about: "Create a bug or file a feature request against package:code_assets."
4+
labels: "package:code_assets"
5+
---

.github/ISSUE_TEMPLATE/data_assets.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
name: "package:data_assets"
3+
about: "Create a bug or file a feature request against package:data_assets."
4+
labels: "package:data_assets"
5+
---

.github/ISSUE_TEMPLATE/hooks.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
name: "package:hooks"
3+
about: "Create a bug or file a feature request against package:hooks."
4+
labels: "package:hooks"
5+
---
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
name: "package:hooks_runner"
3+
about: "Create a bug or file a feature request against package:hooks_runner."
4+
labels: "package:hooks_runner"
5+
---

.github/ISSUE_TEMPLATE/native_assets_builder.md

-5
This file was deleted.

.github/ISSUE_TEMPLATE/native_assets_cli.md

-5
This file was deleted.

.github/labeler.yml

+12-4
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,21 @@
2020
- changed-files:
2121
- any-glob-to-any-file: 'pkgs/jnigen/**'
2222

23-
'package:native_assets_builder':
23+
'package:code_assets':
2424
- changed-files:
25-
- any-glob-to-any-file: 'pkgs/native_assets_builder/**'
25+
- any-glob-to-any-file: 'pkgs/code_assets/**'
2626

27-
'package:native_assets_cli':
27+
'package:data_assets':
2828
- changed-files:
29-
- any-glob-to-any-file: 'pkgs/native_assets_cli/**'
29+
- any-glob-to-any-file: 'pkgs/data_assets/**'
30+
31+
'package:hooks':
32+
- changed-files:
33+
- any-glob-to-any-file: 'pkgs/hooks/**'
34+
35+
'package:hooks_runner':
36+
- changed-files:
37+
- any-glob-to-any-file: 'pkgs/hooks_runner/**'
3038

3139
'package:native_toolchain_c':
3240
- changed-files:

.github/pr-title-checker-config.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
22
"CHECKS": {
33
"prefixes": [
4+
"[code_assets] ",
5+
"[data_assets] ",
46
"[ffi] ",
57
"[ffigen] ",
8+
"[hooks_runner] ",
9+
"[hooks] ",
610
"[infra] ",
711
"[jni] ",
812
"[jnigen] ",
9-
"[native_assets_builder] ",
10-
"[native_assets_cli] ",
1113
"[native_toolchain_c] ",
1214
"[objective_c] ",
1315
"[swift2objc] ",

.github/workflows/hooks.yaml

-63
This file was deleted.

.github/workflows/native.yaml

+33-16
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,20 @@ on:
1010
# No `branches:` to enable stacked PRs on GitHub.
1111
paths:
1212
- ".github/workflows/native.yaml"
13-
- "pkgs/native_assets_builder/**"
14-
- "pkgs/native_assets_cli/**"
13+
- "pkgs/code_assets/**"
14+
- "pkgs/data_assets/**"
15+
- "pkgs/hooks_runner/**"
16+
- "pkgs/hooks/**"
1517
- "pkgs/native_toolchain_c/**"
1618
- "tools/**"
1719
push:
1820
branches: [main]
1921
paths:
2022
- ".github/workflows/native.yaml"
21-
- "pkgs/native_assets_builder/**"
22-
- "pkgs/native_assets_cli/**"
23+
- "pkgs/code_assets/**"
24+
- "pkgs/data_assets/**"
25+
- "pkgs/hooks_runner/**"
26+
- "pkgs/hooks/**"
2327
- "pkgs/native_toolchain_c/**"
2428
- "tools/**"
2529
schedule:
@@ -32,8 +36,13 @@ jobs:
3236
matrix:
3337
os: [ubuntu, macos, windows]
3438
sdk: [dev]
35-
package: [native_assets_builder, native_assets_cli, native_toolchain_c]
36-
# Breaking changes temporarily break the example run on the Dart SDK until native_assets_builder is rolled into the Dart SDK dev build.
39+
package:
40+
- code_assets
41+
- data_assets
42+
- hooks
43+
- hooks_runner
44+
- native_toolchain_c
45+
# Breaking changes temporarily break the example run on the Dart SDK until hooks_runner is rolled into the Dart SDK dev build.
3746
breaking-change: [false]
3847

3948
runs-on: ${{ matrix.os }}-latest
@@ -57,10 +66,10 @@ jobs:
5766
- run: dart pub get
5867

5968
- run: dart pub get -C test_data/native_add_version_skew/
60-
if: ${{ matrix.package == 'native_assets_builder' }}
69+
if: ${{ matrix.package == 'hooks_runner' }}
6170

6271
- run: dart pub get -C test_data/native_add_version_skew_2/
63-
if: ${{ matrix.package == 'native_assets_builder' }}
72+
if: ${{ matrix.package == 'hooks_runner' }}
6473

6574
- run: dart analyze --fatal-infos
6675
# Run on dev to ensure we're not depending on deprecated SDK things.
@@ -75,35 +84,43 @@ jobs:
7584

7685
- run: dart --enable-experiment=native-assets test
7786
working-directory: pkgs/${{ matrix.package }}/example/build/native_dynamic_linking/
78-
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'dev' && !matrix.breaking-change }}
87+
if: ${{ matrix.package == 'hooks' && matrix.sdk == 'dev' && !matrix.breaking-change }}
7988

8089
- run: dart --enable-experiment=native-assets test
8190
working-directory: pkgs/${{ matrix.package }}/example/build/native_add_app/
82-
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'dev' && !matrix.breaking-change }}
91+
if: ${{ matrix.package == 'hooks' && matrix.sdk == 'dev' && !matrix.breaking-change }}
8392

8493
- run: dart --enable-experiment=native-assets run
8594
working-directory: pkgs/${{ matrix.package }}/example/build/native_add_app/
86-
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'dev' && !matrix.breaking-change }}
95+
if: ${{ matrix.package == 'hooks' && matrix.sdk == 'dev' && !matrix.breaking-change }}
8796

8897
- run: dart --enable-experiment=native-assets build bin/native_add_app.dart
8998
working-directory: pkgs/${{ matrix.package }}/example/build/native_add_app/
90-
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'dev' && !matrix.breaking-change }}
99+
if: ${{ matrix.package == 'hooks' && matrix.sdk == 'dev' && !matrix.breaking-change }}
91100

92101
- run: ./native_add_app.exe
93102
working-directory: pkgs/${{ matrix.package }}/example/build/native_add_app/bin/native_add_app/
94-
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'dev' && !matrix.breaking-change }}
103+
if: ${{ matrix.package == 'hooks' && matrix.sdk == 'dev' && !matrix.breaking-change }}
95104

96105
- run: dart --enable-experiment=native-assets test
97106
working-directory: pkgs/${{ matrix.package }}/example/build/use_dart_api/
98-
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'dev' && !matrix.breaking-change }}
107+
if: ${{ matrix.package == 'hooks' && matrix.sdk == 'dev' && !matrix.breaking-change }}
99108

100109
- run: dart --enable-experiment=native-assets test
101110
working-directory: pkgs/${{ matrix.package }}/example/build/download_asset/
102-
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'dev' && !matrix.breaking-change }}
111+
if: ${{ matrix.package == 'hooks' && matrix.sdk == 'dev' && !matrix.breaking-change }}
103112

104113
- run: dart --enable-experiment=native-assets test
105114
working-directory: pkgs/${{ matrix.package }}/example/build/system_library/
106-
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'dev' && !matrix.breaking-change }}
115+
if: ${{ matrix.package == 'hooks' && matrix.sdk == 'dev' && !matrix.breaking-change }}
116+
117+
- run: |
118+
dart tool/generate_schemas.dart
119+
dart tool/generate_syntax.dart
120+
dart tool/normalize.dart
121+
git diff --exit-code
122+
working-directory: pkgs/${{ matrix.package }}
123+
if: ${{ matrix.package == 'hook' && matrix.sdk == 'dev' }}
107124
108125
- name: Install coverage
109126
run: dart pub global activate coverage

CONTRIBUTING.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ new file please also add this. The year should be a single number stating the
3838
year the file was created (don't use a range like "2011-2012"). Additionally, if
3939
you edit an existing file, you shouldn't update the year.
4040

41-
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
41+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
4242
// for details. All rights reserved. Use of this source code is governed by a
4343
// BSD-style license that can be found in the LICENSE file.
4444

@@ -52,10 +52,11 @@ We pledge to maintain an open and welcoming environment. For details, see our
5252

5353
## Tests
5454

55-
Packages `native_assets_cli`, `native_assets_builder`, and `native_toolchain_c`
56-
roll into the Dart SDK. The tests of these packages are run on the Dart SDK in
57-
[a different way](https://github.com/dart-lang/sdk/issues/56574) than on the
58-
GitHub actions on this repo.
55+
Packages `hooks`, `code_assets`, `data_assets`, `hooks_runner`, and
56+
`native_toolchain_c` roll into the Dart SDK. The tests of these packages are run
57+
on the Dart SDK in [a different
58+
way](https://github.com/dart-lang/sdk/issues/56574) than on the GitHub actions
59+
on this repo.
5960

6061
1. The `tools/test.py` runs `(.*)test.dart`, so no `package:test` annotations
6162
are respected. So, things such as skips should be done with early returns.
@@ -73,4 +74,4 @@ Maven (`mvn` command) to build some sources and run integration tests.
7374
On Linux and MacOS, it can be installed with the [`sdkman`](https://sdkman.io/)
7475
package manager or a manual method. On Windows, it can be installed with
7576
[chocolatey](https://community.chocolatey.org/packages/maven) or
76-
[scoop](https://scoop.sh/#/apps?q=maven).
77+
[scoop](https://scoop.sh/#/apps?q=maven).

README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,27 @@ building and bundling.
99

1010
| Package | Description | Issues | Version |
1111
| --- | --- | --- | --- |
12+
| [code_assets](pkgs/code_assets/) | This package contains the Dart API for code assets in `hook/build.dart` and `hook/link.dart`. | [![issues](https://img.shields.io/badge/package:code_assets-4774bc)][code_assets_issues] | |
13+
| [data_assets](pkgs/data_assets/) | This package contains the Dart API for data assets in `hook/build.dart` and `hook/link.dart`. | [![issues](https://img.shields.io/badge/package:data_assets-4774bc)][data_assets_issues] | |
1214
| [ffi](pkgs/ffi/) | Utilities for working with Foreign Function Interface (FFI) code. | [![issues](https://img.shields.io/badge/package:ffi-4774bc)][ffi_issues] | [![pub package](https://img.shields.io/pub/v/ffi.svg)](https://pub.dev/packages/ffi) |
1315
| [ffigen](pkgs/ffigen/) | Generator for FFI bindings, using LibClang to parse C, Objective-C, and Swift files. | [![issues](https://img.shields.io/badge/package:ffigen-4774bc)][ffigen_issues] | [![pub package](https://img.shields.io/pub/v/ffigen.svg)](https://pub.dev/packages/ffigen) |
16+
| [hooks](pkgs/hooks/) | This package contains the API for `hook/build.dart` and `hook/link.dart`. | [![issues](https://img.shields.io/badge/package:hooks-4774bc)][hooks_issues] | |
17+
| [hooks_runner](pkgs/hooks_runner/) | This package is the backend that invokes `hook/build.dart` and `hook/link.dart` from Dart and Flutter. | [![issues](https://img.shields.io/badge/package:hooks_runner-4774bc)][hooks_runner_issues] | |
1418
| [jni](pkgs/jni/) | A library to access JNI from Dart and Flutter that acts as a support library for package:jnigen. | [![issues](https://img.shields.io/badge/package:jni-4774bc)][jni_issues] | [![pub package](https://img.shields.io/pub/v/jni.svg)](https://pub.dev/packages/jni) |
1519
| [jnigen](pkgs/jnigen/) | A Dart bindings generator for Java and Kotlin that uses JNI under the hood to interop with Java virtual machine. | [![issues](https://img.shields.io/badge/package:jnigen-4774bc)][jnigen_issues] | [![pub package](https://img.shields.io/pub/v/jnigen.svg)](https://pub.dev/packages/jnigen) |
16-
| [native_assets_builder](pkgs/native_assets_builder/) | This package is the backend that invokes build hooks. | [![issues](https://img.shields.io/badge/package:native__assets__builder-4774bc)][native_assets_builder_issues] | |
17-
| [native_assets_cli](pkgs/native_assets_cli/) | A library that contains the argument and file formats for implementing a native assets CLI. | [![issues](https://img.shields.io/badge/package:native__assets__cli-4774bc)][native_assets_cli_issues] | |
1820
| [native_toolchain_c](pkgs/native_toolchain_c/) | A library to invoke the native C compiler installed on the host machine. | [![issues](https://img.shields.io/badge/package:native__toolchain__c-4774bc)][native_toolchain_c_issues] | |
1921
| [objective_c](pkgs/objective_c/) | A library to access Objective C from Flutter that acts as a support library for package:ffigen. | [![issues](https://img.shields.io/badge/package:objective__c-4774bc)][objective_c_issues] | [![pub package](https://img.shields.io/pub/v/objective_c.svg)](https://pub.dev/packages/objective_c) |
2022
| [swift2objc](pkgs/swift2objc/) | A tool for generating bindings that allow interop between Dart and Swift code. | [![issues](https://img.shields.io/badge/package:swift2objc-4774bc)][swift2objc_issues] | [![pub package](https://img.shields.io/pub/v/swift2objc.svg)](https://pub.dev/packages/swift2objc) |
2123
| [swiftgen](pkgs/swiftgen/) | A tool for generating bindings that allow interop between Dart and Swift code. | [![issues](https://img.shields.io/badge/package:swiftgen-4774bc)][swiftgen_issues] | [![pub package](https://img.shields.io/pub/v/swiftgen.svg)](https://pub.dev/packages/swiftgen) |
2224

25+
[code_assets_issues]: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Acode_assets
26+
[data_assets_issues]: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Adata_assets
2327
[ffi_issues]: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Affi
2428
[ffigen_issues]: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Affigen
29+
[hooks_issues]: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ahooks
30+
[hooks_runner_issues]: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ahooks_runner
2531
[jni_issues]: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ajni
2632
[jnigen_issues]: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ajnigen
27-
[native_assets_builder_issues]: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Anative_assets_builder
28-
[native_assets_cli_issues]: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Anative_assets_cli
2933
[native_toolchain_c_issues]: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Anative_toolchain_c
3034
[objective_c_issues]: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aobjective_c
3135
[swift2objc_issues]: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aswift2objc

pkgs/code_assets/CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
## 0.1.0-wip
1+
## 0.19.0-wip
2+
3+
- Split up `package:native_assets_cli` in `package:hooks`,
4+
`package:code_assets`, and `package:data_assets`.
5+
6+
## 0.1.0
27

38
- Initial version.

pkgs/code_assets/README.md

-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
This library contains the hook protocol specification for bundling native code
77
with Dart packages.
88

9-
## This package is documentation only for the moment.
10-
11-
For using this feature, please refer to `package:native_assets_cli` for now.
12-
In the future, we'll split up that package into here.
13-
149
## Status: Experimental
1510

1611
**NOTE**: This package is currently experimental and published under the

pkgs/code_assets/doc/schema/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ These schemas document the protocol for build and link hooks with code assets.
33
* If you are a hook author, you should likely be using a hook-helper-package
44
Dart API (such as `package:native_toolchain_c`) instead of directly consuming
55
and producing JSON.
6-
* If you are a hook-helper-package author, you should likely be using a
7-
hook-helper-package's Dart API (such as `package:native_assets_cli`) which
8-
abstracts away from syntactic changes. If you do want to directly interact
9-
with the JSON, you can find the relevant schemas in [hook/](hook/).
6+
* If you are a hook-helper-package author, you should likely be using this
7+
package's Dart API which abstracts away from syntactic changes. If you do want
8+
to directly interact with the JSON, you can find the relevant schemas in
9+
[hook/](hook/).
1010
* If you are an SDK author, you should likely be using the SDK helper package
11-
(`package:native_assets_builder`) which abstracts away from syntactic changes.
11+
(`package:hooks_runner`) which abstracts away from syntactic changes.
1212
If you do want to directly interact with the JSON, you can find the relevant
1313
schemas in [sdk/](sdk/).
1414

pkgs/native_assets_cli/lib/src/code_assets/architecture.dart renamed to pkgs/code_assets/lib/src/code_assets/architecture.dart

+7-7
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ extension ArchitectureSyntaxExtension on Architecture {
100100

101101
ArchitectureSyntax toSyntax() => _toSyntax[this]!;
102102

103-
static Architecture fromSyntax(ArchitectureSyntax syntax) =>
104-
switch (_fromSyntax[syntax]) {
105-
null => throw FormatException(
106-
'The architecture "${syntax.name}" is not known',
107-
),
108-
final arch => arch,
109-
};
103+
static Architecture fromSyntax(
104+
ArchitectureSyntax syntax,
105+
) => switch (_fromSyntax[syntax]) {
106+
null =>
107+
throw FormatException('The architecture "${syntax.name}" is not known'),
108+
final arch => arch,
109+
};
110110
}

pkgs/native_assets_cli/lib/src/code_assets/c_compiler_config.dart renamed to pkgs/code_assets/lib/src/code_assets/c_compiler_config.dart

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ final class CCompilerConfig {
2323

2424
/// Configuration provided when [CodeConfig.targetOS] is [OS.windows].
2525
WindowsCCompilerConfig get windows => switch (_windows) {
26-
null => throw StateError(
27-
'Cannot access windows if CodeConfig.targetOS is not Windows',
28-
),
26+
null =>
27+
throw StateError(
28+
'Cannot access windows if CodeConfig.targetOS is not Windows',
29+
),
2930
final c => c,
3031
};
3132

pkgs/native_assets_cli/lib/src/code_assets/code_asset.dart renamed to pkgs/code_assets/lib/src/code_assets/code_asset.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import '../config.dart';
6-
import '../encoded_asset.dart';
5+
import 'package:hooks/hooks.dart';
6+
77
import 'config.dart';
88
import 'link_mode.dart';
99
import 'os.dart';

0 commit comments

Comments
 (0)