Skip to content
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

[native_assets_cli] [doc] Document multiple invocation behavior #1891

Merged
merged 2 commits into from
Jan 15, 2025
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
9 changes: 9 additions & 0 deletions pkgs/native_assets_cli/lib/src/code_assets/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class CodeConfig {
final Architecture? _targetArchitecture;

final LinkModePreference linkModePreference;

/// A compiler toolchain able to target [targetOS] with [targetArchitecture].
final CCompilerConfig? cCompiler;

/// The operating system being compiled for.
Expand Down Expand Up @@ -106,6 +108,13 @@ class CodeConfig {
);
}

/// The architecture the code code asset should be built for.
///
/// The build and link hooks are invoked once per [targetArchitecture]. If the
/// invoker produces multi-architecture applications, the invoker is
/// responsible for combining the [CodeAsset]s for individual architectures
/// into a universal binary. So, the build and link hook implementations are
/// not responsible for providing universal binaries.
Architecture get targetArchitecture {
// TODO: Remove once Dart 3.7 stable is out and we bump the minimum SDK to
// 3.7.
Expand Down
17 changes: 16 additions & 1 deletion pkgs/native_assets_cli/lib/src/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,25 @@ final latestVersion = Version(1, 8, 0);
/// catches issues with 2.)
final latestParsableVersion = Version(1, 5, 0);

/// The configuration for a build or link hook invocation.
final class HookConfig {
final Map<String, Object?> json;

/// The asset types that the invoker of this hook supports.
/// The asset types that should be built by an invocation of a hook.
///
/// The invoker of a hook may, and in most cases will, invoke the hook
/// separately for different asset types.
///
/// This means that hooks should be written in a way that they are a no-op if
/// they are invoked for an asset type that is not emitted by the hook. Most
/// asset extensions provide a to check [buildAssetTypes] for their own asset
/// type. For example, `CodeAsset`s can be used as follows:
///
/// ```dart
/// if (input.config.buildCodeAssets) {
/// // Emit code asset.
/// }
/// ```
final List<String> buildAssetTypes;

HookConfig(this.json)
Expand Down
Loading