diff --git a/.github/workflows/dart.yaml b/.github/workflows/dart.yaml index fafce3bdb..c285821e2 100644 --- a/.github/workflows/dart.yaml +++ b/.github/workflows/dart.yaml @@ -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 diff --git a/pkgs/native_assets_builder/CHANGELOG.md b/pkgs/native_assets_builder/CHANGELOG.md index 191357077..5700d5d27 100644 --- a/pkgs/native_assets_builder/CHANGELOG.md +++ b/pkgs/native_assets_builder/CHANGELOG.md @@ -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 diff --git a/pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart b/pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart index d312db754..1c1544648 100644 --- a/pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart +++ b/pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart @@ -84,6 +84,7 @@ class NativeAssetsBuildRunner { targetMetadata: metadata, ); final config = await _cliConfig( + packageName: package.name, packageRoot: packageLayout.packageRoot(package.name), target: target, buildMode: buildMode, @@ -310,6 +311,7 @@ build_output.yaml contained a format error. } static Future _cliConfig({ + required String packageName, required Uri packageRoot, required Target target, IOSSdk? targetIOSSdk, @@ -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, @@ -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, @@ -366,6 +370,7 @@ build_output.yaml contained a format error. } return BuildConfig.dryRun( outDir: outDirUri, + packageName: packageName, packageRoot: packageRoot, targetOs: targetOs, linkModePreference: linkMode, @@ -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()); diff --git a/pkgs/native_assets_builder/pubspec.yaml b/pkgs/native_assets_builder/pubspec.yaml index 14695419f..ad0e45afb 100644 --- a/pkgs/native_assets_builder/pubspec.yaml +++ b/pkgs/native_assets_builder/pubspec.yaml @@ -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: @@ -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: diff --git a/pkgs/native_assets_builder/test/build_runner/build_runner_asset_id_test.dart b/pkgs/native_assets_builder/test/build_runner/build_runner_asset_id_test.dart index 95ba8def7..19ad31922 100644 --- a/pkgs/native_assets_builder/test/build_runner/build_runner_asset_id_test.dart +++ b/pkgs/native_assets_builder/test/build_runner/build_runner_asset_id_test.dart @@ -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); + } + }); + }); } diff --git a/pkgs/native_assets_builder/test/data/cyclic_package_1/pubspec.yaml b/pkgs/native_assets_builder/test/data/cyclic_package_1/pubspec.yaml index 62e9e627c..48b20d548 100644 --- a/pkgs/native_assets_builder/test/data/cyclic_package_1/pubspec.yaml +++ b/pkgs/native_assets_builder/test/data/cyclic_package_1/pubspec.yaml @@ -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 diff --git a/pkgs/native_assets_builder/test/data/cyclic_package_2/pubspec.yaml b/pkgs/native_assets_builder/test/data/cyclic_package_2/pubspec.yaml index 102844e3a..639c8e50c 100644 --- a/pkgs/native_assets_builder/test/data/cyclic_package_2/pubspec.yaml +++ b/pkgs/native_assets_builder/test/data/cyclic_package_2/pubspec.yaml @@ -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 diff --git a/pkgs/native_assets_builder/test/data/native_add/manifest.yaml b/pkgs/native_assets_builder/test/data/native_add/manifest.yaml new file mode 100644 index 000000000..e922db8c1 --- /dev/null +++ b/pkgs/native_assets_builder/test/data/native_add/manifest.yaml @@ -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 diff --git a/pkgs/native_assets_builder/test/data/native_add/pubspec.yaml b/pkgs/native_assets_builder/test/data/native_add/pubspec.yaml index 5a09f24fe..460c20491 100644 --- a/pkgs/native_assets_builder/test/data/native_add/pubspec.yaml +++ b/pkgs/native_assets_builder/test/data/native_add/pubspec.yaml @@ -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 diff --git a/pkgs/native_assets_builder/test/data/native_add_add_source/pubspec.yaml b/pkgs/native_assets_builder/test/data/native_add_add_source/pubspec.yaml index 5a09f24fe..460c20491 100644 --- a/pkgs/native_assets_builder/test/data/native_add_add_source/pubspec.yaml +++ b/pkgs/native_assets_builder/test/data/native_add_add_source/pubspec.yaml @@ -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 diff --git a/pkgs/native_assets_builder/test/data/native_subtract/pubspec.yaml b/pkgs/native_assets_builder/test/data/native_subtract/pubspec.yaml index f1eea1404..25b36841b 100644 --- a/pkgs/native_assets_builder/test/data/native_subtract/pubspec.yaml +++ b/pkgs/native_assets_builder/test/data/native_subtract/pubspec.yaml @@ -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 diff --git a/pkgs/native_assets_builder/test/data/package_reading_metadata/pubspec.yaml b/pkgs/native_assets_builder/test/data/package_reading_metadata/pubspec.yaml index c5c92667a..b475e36dc 100644 --- a/pkgs/native_assets_builder/test/data/package_reading_metadata/pubspec.yaml +++ b/pkgs/native_assets_builder/test/data/package_reading_metadata/pubspec.yaml @@ -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 diff --git a/pkgs/native_assets_builder/test/data/package_with_metadata/pubspec.yaml b/pkgs/native_assets_builder/test/data/package_with_metadata/pubspec.yaml index 579151723..3dc55948d 100644 --- a/pkgs/native_assets_builder/test/data/package_with_metadata/pubspec.yaml +++ b/pkgs/native_assets_builder/test/data/package_with_metadata/pubspec.yaml @@ -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 diff --git a/pkgs/native_assets_builder/test/data/wrong_build_output/pubspec.yaml b/pkgs/native_assets_builder/test/data/wrong_build_output/pubspec.yaml index 51671865a..a9822faec 100644 --- a/pkgs/native_assets_builder/test/data/wrong_build_output/pubspec.yaml +++ b/pkgs/native_assets_builder/test/data/wrong_build_output/pubspec.yaml @@ -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 diff --git a/pkgs/native_assets_builder/test/data/wrong_build_output_2/pubspec.yaml b/pkgs/native_assets_builder/test/data/wrong_build_output_2/pubspec.yaml index 7afbf3450..863c61ae9 100644 --- a/pkgs/native_assets_builder/test/data/wrong_build_output_2/pubspec.yaml +++ b/pkgs/native_assets_builder/test/data/wrong_build_output_2/pubspec.yaml @@ -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 diff --git a/pkgs/native_assets_builder/test/data/wrong_build_output_3/pubspec.yaml b/pkgs/native_assets_builder/test/data/wrong_build_output_3/pubspec.yaml index 749a89ed2..c76a14a73 100644 --- a/pkgs/native_assets_builder/test/data/wrong_build_output_3/pubspec.yaml +++ b/pkgs/native_assets_builder/test/data/wrong_build_output_3/pubspec.yaml @@ -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 diff --git a/pkgs/native_assets_builder/test/data/wrong_namespace_asset/pubspec.yaml b/pkgs/native_assets_builder/test/data/wrong_namespace_asset/pubspec.yaml index 5b255aba6..4fffb5a8b 100644 --- a/pkgs/native_assets_builder/test/data/wrong_namespace_asset/pubspec.yaml +++ b/pkgs/native_assets_builder/test/data/wrong_namespace_asset/pubspec.yaml @@ -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 diff --git a/pkgs/native_assets_cli/example/native_add_library/pubspec.yaml b/pkgs/native_assets_cli/example/native_add_library/pubspec.yaml index 5405e1e97..05e72decf 100644 --- a/pkgs/native_assets_cli/example/native_add_library/pubspec.yaml +++ b/pkgs/native_assets_cli/example/native_add_library/pubspec.yaml @@ -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 diff --git a/pkgs/native_assets_cli/test/example/native_add_library_test.dart b/pkgs/native_assets_cli/test/example/native_add_library_test.dart index 286eff61a..34da58dc9 100644 --- a/pkgs/native_assets_cli/test/example/native_add_library_test.dart +++ b/pkgs/native_assets_cli/test/example/native_add_library_test.dart @@ -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; @@ -31,7 +32,7 @@ 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( @@ -39,6 +40,7 @@ void main() async { [ 'build.dart', '-Dout_dir=${tempUri.toFilePath()}', + '-Dpackage_name=$name', '-Dpackage_root=${testPackageUri.toFilePath()}', '-Dtarget_os=${OS.current}', '-Dversion=${BuildConfig.version}', @@ -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'), ], );