flutter/dev/integration_tests/link_hook/hook/link.dart
Daco Harkes 27ba2f2790
[native assets] Roll dependencies (#160672)
This PR rolls in a number of breaking changes from dart-lang/native:

* `BuildMode` is no longer part of the protocol, so Flutter no longer
passes it in.
* This means all code dealing with the name conflict between
`native_assets_cli.BuildMode` and `flutter_tools.BuildMode` has been
cleaned up.
  * Also, the logs no longer mention the build mode.
* The tests still exercise both modes, because linking only happens in
release mode.
* `OS` is no longer part of the main protocol, but of the "code"
"protocol extension".
* The code now aligns more with `OS?` being nullable in a bunch of
places, since it is nullable if there's no code assets.
* The OS-specific config is nested in an object per OS.
* `CCompilerConfig`s fields are non-nullable now.
* So instead of passing an object with nullable fields around, a null
instead of the object is returned in various places.
* `FileSystem` is now passed in to the native assets builder.

This PR contains no feature changes.

This PR will need to be followed up by restricting what environment
variables are passed in (similar to
https://github.com/dart-lang/native/pull/1764), I will do this in a
follow up PR.

Tests:

* All existing features should be covered by existing tests.
2025-01-02 19:26:02 +00:00

28 lines
922 B
Dart

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:native_assets_cli/code_assets.dart';
void main(List<String> args) async {
await link(args, (LinkConfig config, LinkOutputBuilder output) async {
if (!config.buildAssetTypes.contains(CodeAsset.type)) {
return;
}
final CodeAsset asset = config.codeAssets.single;
final String packageName = config.packageName;
output.codeAssets.add(
CodeAsset(
package: packageName,
// Change the asset id to something that is used.
name: '${packageName}_bindings_generated.dart',
linkMode: asset.linkMode,
os: asset.os,
architecture: asset.architecture,
file: asset.file,
),
);
output.addDependency(config.packageRoot.resolve('hook/link.dart'));
});
}