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_builder] Pass packageName in to builds #150

Merged
merged 5 commits into from
Oct 3, 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
2 changes: 1 addition & 1 deletion .github/workflows/dart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
sdk: [stable, dev]
package: [native_assets_builder, native_assets_cli, native_toolchain_c]
# Breaking changes temporarily break the example run on the Dart SDK until native_assets_builder is rolled into the Dart SDK dev build.
breaking-change: [false]
breaking-change: [true]
exclude:
# Only run analyze against dev on one host.
- os: macos
Expand Down
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.3.0

- Bump `package:native_assets_cli` to 0.3.0
([#142](https://github.com/dart-lang/native/issues/142)).

## 0.2.3

- Quicker build planning for 0 or 1 packages with native assets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class NativeAssetsBuildRunner {
targetMetadata: metadata,
);
final config = await _cliConfig(
packageName: package.name,
packageRoot: packageLayout.packageRoot(package.name),
target: target,
buildMode: buildMode,
Expand Down Expand Up @@ -310,6 +311,7 @@ build_output.yaml contained a format error.
}

static Future<BuildConfig> _cliConfig({
required String packageName,
required Uri packageRoot,
required Target target,
IOSSdk? targetIOSSdk,
Expand All @@ -321,6 +323,7 @@ build_output.yaml contained a format error.
DependencyMetadata? dependencyMetadata,
}) async {
final buildDirName = BuildConfig.checksum(
packageName: packageName,
packageRoot: packageRoot,
targetOs: target.os,
targetArchitecture: target.architecture,
Expand All @@ -339,6 +342,7 @@ build_output.yaml contained a format error.
}
return BuildConfig(
outDir: outDirUri,
packageName: packageName,
packageRoot: packageRoot,
targetOs: target.os,
targetArchitecture: target.architecture,
Expand Down Expand Up @@ -366,6 +370,7 @@ build_output.yaml contained a format error.
}
return BuildConfig.dryRun(
outDir: outDirUri,
packageName: packageName,
packageRoot: packageRoot,
targetOs: targetOs,
linkModePreference: linkMode,
Expand Down Expand Up @@ -470,9 +475,4 @@ extension on DateTime {
millisecondsSinceEpoch % Duration(seconds: 1).inMilliseconds);
}

extension on BuildConfig {
String get packageName =>
packageRoot.pathSegments.lastWhere((e) => e.isNotEmpty);
}

int _uriCompare(Uri u1, Uri u2) => u1.toString().compareTo(u2.toString());
4 changes: 2 additions & 2 deletions 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.3
version: 0.3.0
repository: https://github.com/dart-lang/native/tree/main/pkgs/native_assets_builder

environment:
Expand All @@ -10,7 +10,7 @@ environment:
dependencies:
graphs: ^2.3.1
logging: ^1.2.0
native_assets_cli: ^0.2.0
native_assets_cli: ^0.3.0
package_config: ^2.1.0

dev_dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,28 @@ void main() async {
}
});
});

test('right asset id but other directory', timeout: longTimeout, () async {
await inTempDir((tempUri) async {
final packageUri = tempUri.resolve('different_root_dir/');
await copyTestProjects(
sourceUri: testDataUri.resolve('native_add/'),
targetUri: packageUri,
);

await runPubGet(
workingDirectory: packageUri,
logger: logger,
);

{
final result = await build(
packageUri,
logger,
dartExecutable,
);
expect(result.success, true);
}
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
cli_config: ^0.1.1
cyclic_package_2:
path: ../cyclic_package_2
native_assets_cli: ^0.2.0
native_assets_cli: ^0.3.0
yaml: ^3.1.1
yaml_edit: ^2.1.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
cli_config: ^0.1.1
cyclic_package_1:
path: ../cyclic_package_1
native_assets_cli: ^0.2.0
native_assets_cli: ^0.3.0
yaml: ^3.1.1
yaml_edit: ^2.1.0

Expand Down
9 changes: 9 additions & 0 deletions pkgs/native_assets_builder/test/data/native_add/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- build.dart
- ffigen.yaml
- lib/native_add.dart
- lib/src/native_add_bindings_generated.dart
- lib/src/native_add.dart
- pubspec.yaml
- src/native_add.c
- src/native_add.h
- test/native_add_test.dart
4 changes: 2 additions & 2 deletions pkgs/native_assets_builder/test/data/native_add/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ environment:
dependencies:
cli_config: ^0.1.1
logging: ^1.1.1
native_assets_cli: ^0.2.0
native_toolchain_c: ^0.2.2
native_assets_cli: ^0.3.0
native_toolchain_c: ^0.3.0

dev_dependencies:
ffigen: ^8.0.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ environment:
dependencies:
cli_config: ^0.1.1
logging: ^1.1.1
native_assets_cli: ^0.2.0
native_toolchain_c: ^0.2.2
native_assets_cli: ^0.3.0
native_toolchain_c: ^0.3.0

dev_dependencies:
ffigen: ^8.0.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ environment:
dependencies:
cli_config: ^0.1.1
logging: ^1.1.1
native_assets_cli: ^0.2.0
native_toolchain_c: ^0.2.2
native_assets_cli: ^0.3.0
native_toolchain_c: ^0.3.0

dev_dependencies:
ffigen: ^8.0.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ environment:

dependencies:
cli_config: ^0.1.1
native_assets_cli: ^0.2.0
native_assets_cli: ^0.3.0
package_with_metadata:
path: ../package_with_metadata/
yaml: ^3.1.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ environment:

dependencies:
cli_config: ^0.1.1
native_assets_cli: ^0.2.0
native_assets_cli: ^0.3.0
yaml: ^3.1.1
yaml_edit: ^2.1.0

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

dependencies:
cli_config: ^0.1.1
native_assets_cli: ^0.2.0
native_assets_cli: ^0.3.0
yaml: ^3.1.1
yaml_edit: ^2.1.0

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

dependencies:
cli_config: ^0.1.1
native_assets_cli: ^0.2.0
native_assets_cli: ^0.3.0
yaml: ^3.1.1
yaml_edit: ^2.1.0

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

dependencies:
cli_config: ^0.1.1
native_assets_cli: ^0.2.0
native_assets_cli: ^0.3.0
yaml: ^3.1.1
yaml_edit: ^2.1.0

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

dependencies:
cli_config: ^0.1.1
native_assets_cli: ^0.2.0
native_assets_cli: ^0.3.0
yaml: ^3.1.1
yaml_edit: ^2.1.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ environment:
dependencies:
cli_config: ^0.1.1
logging: ^1.1.1
native_assets_cli: ^0.2.0
native_toolchain_c: ^0.2.2
native_assets_cli: ^0.3.0
native_toolchain_c: ^0.3.0

dev_dependencies:
ffigen: ^8.0.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import '../helpers.dart';

void main() async {
late Uri tempUri;
const name = 'native_add_library';

setUp(() async {
tempUri = (await Directory.systemTemp.createTemp()).uri;
Expand All @@ -31,14 +32,15 @@ void main() async {
test('native_add build$testSuffix', () async {
final testTempUri = tempUri.resolve('test1/');
await Directory.fromUri(testTempUri).create();
final testPackageUri = packageUri.resolve('example/native_add_library/');
final testPackageUri = packageUri.resolve('example/$name/');
final dartUri = Uri.file(Platform.resolvedExecutable);

final processResult = await Process.run(
dartUri.toFilePath(),
[
'build.dart',
'-Dout_dir=${tempUri.toFilePath()}',
'-Dpackage_name=$name',
'-Dpackage_root=${testPackageUri.toFilePath()}',
'-Dtarget_os=${OS.current}',
'-Dversion=${BuildConfig.version}',
Expand Down Expand Up @@ -80,7 +82,7 @@ void main() async {
expect(
dependencies.dependencies,
[
testPackageUri.resolve('src/native_add_library.c'),
testPackageUri.resolve('src/$name.c'),
testPackageUri.resolve('build.dart'),
],
);
Expand Down