Skip to content

[native_assets_builder] Take packageLayout for build and dryRun #127

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

Merged
merged 3 commits into from
Sep 12, 2023
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
5 changes: 5 additions & 0 deletions pkgs/native_assets_builder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.2.2

- Take a `PackageLayout` argument for `build` and `dryRun`
[flutter#134427](https://github.com/flutter/flutter/issues/134427).

## 0.2.1

- Provide a `PackageLayout` constructor for already parsed `PackageConfig`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class NativeAssetsBuildRunner {
IOSSdk? targetIOSSdk,
int? targetAndroidNdkApi,
required bool includeParentEnvironment,
PackageLayout? packageLayout,
}) async {
final packageLayout =
await PackageLayout.fromRootPackageRoot(workingDirectory);
packageLayout ??= await PackageLayout.fromRootPackageRoot(workingDirectory);
final packagesWithNativeAssets =
await packageLayout.packagesWithNativeAssets;
final planner = await NativeAssetsBuildPlanner.fromRootPackageRoot(
Expand Down Expand Up @@ -118,9 +118,9 @@ class NativeAssetsBuildRunner {
required OS targetOs,
required Uri workingDirectory,
required bool includeParentEnvironment,
PackageLayout? packageLayout,
}) async {
final packageLayout =
await PackageLayout.fromRootPackageRoot(workingDirectory);
packageLayout ??= await PackageLayout.fromRootPackageRoot(workingDirectory);
final packagesWithNativeAssets =
await packageLayout.packagesWithNativeAssets;
final planner = await NativeAssetsBuildPlanner.fromRootPackageRoot(
Expand Down
2 changes: 1 addition & 1 deletion pkgs/native_assets_builder/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: native_assets_builder
description: >-
This package is the backend that invokes top-level `build.dart` scripts.
version: 0.2.1
version: 0.2.2
repository: https://github.com/dart-lang/native/tree/main/pkgs/native_assets_builder

environment:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'dart:io';

import 'package:native_assets_builder/native_assets_builder.dart';
import 'package:test/test.dart';

import '../helpers.dart';
Expand Down Expand Up @@ -36,15 +37,25 @@ void main() async {
}

// Trigger a build, should not invoke anything.
{
for (final passPackageLayout in [true, false]) {
PackageLayout? packageLayout;
if (passPackageLayout) {
packageLayout = await PackageLayout.fromRootPackageRoot(packageUri);
}
final logMessages = <String>[];
final result = await build(packageUri, logger, dartExecutable,
capturedLogs: logMessages);
final result = await build(
packageUri,
logger,
dartExecutable,
capturedLogs: logMessages,
packageLayout: packageLayout,
);
expect(
false,
logMessages
.join('\n')
.contains('native_add${Platform.pathSeparator}build.dart'));
false,
logMessages
.join('\n')
.contains('native_add${Platform.pathSeparator}build.dart'),
);
expect(result.assets.length, 1);
}
});
Expand Down
4 changes: 4 additions & 0 deletions pkgs/native_assets_builder/test/build_runner/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Future<BuildResult> build(
CCompilerConfig? cCompilerConfig,
bool includeParentEnvironment = true,
List<String>? capturedLogs,
PackageLayout? packageLayout,
}) async {
StreamSubscription<LogRecord>? subscription;
if (capturedLogs != null) {
Expand All @@ -51,6 +52,7 @@ Future<BuildResult> build(
workingDirectory: packageUri,
cCompilerConfig: cCompilerConfig,
includeParentEnvironment: includeParentEnvironment,
packageLayout: packageLayout,
);
if (result.success) {
await expectAssetsExist(result.assets);
Expand All @@ -71,6 +73,7 @@ Future<DryRunResult> dryRun(
CCompilerConfig? cCompilerConfig,
bool includeParentEnvironment = true,
List<String>? capturedLogs,
PackageLayout? packageLayout,
}) async {
StreamSubscription<LogRecord>? subscription;
if (capturedLogs != null) {
Expand All @@ -86,6 +89,7 @@ Future<DryRunResult> dryRun(
targetOs: Target.current.os,
workingDirectory: packageUri,
includeParentEnvironment: includeParentEnvironment,
packageLayout: packageLayout,
);

if (subscription != null) {
Expand Down