Skip to content

[native_assets_builder] Support pub workspaces #1905

Closed
@dcharkes

Description

@dcharkes

The native assets builder should take into account pub workspaces:

  • .dart_tool/package_config.json is to possibly be in a ancestor directory
  • runPackageName argument should be required for build/link hooks, so only native assets that are a dependency are built (instead of all packages in the package resolution of the whole workspace).
  • runPackageName argument should be required for "if there are packages with native assets", the native assets experiment only has to be enabled if a dependency has a hook.
  • Native assets should be shared for the whole workspace. (The package resolution is identical, so the native assets should be identical.) I need to check if no information leaks from runPackageName into the BuildInput.

And this needs to be rolled into


Yet another CI issue: Testing native_assets_ci/example/build/native_dynamic_linking.dart fails:

PathNotFoundException: Cannot open file, path = 'D:\a\native\native\pkgs\native_assets_cli\example\build\native_add_app\.dart_tool\package_config.json' (OS Error: The system cannot find the file specified.

That's because the native_assets_builder package itself doesn't understand workspaces:

  static Future<PackageLayout> fromRootPackageRoot(
    FileSystem fileSystem,
    Uri rootPackageRoot,
  ) async {
    rootPackageRoot = rootPackageRoot.normalizePath();
    final packageConfigUri =
        rootPackageRoot.resolve('.dart_tool/package_config.json');  // <--
    assert(await fileSystem.file(packageConfigUri).exists());
    final packageConfig = await loadPackageConfigUri(packageConfigUri);
    return PackageLayout._(
        fileSystem, rootPackageRoot, packageConfig, packageConfigUri);
  }

Originally posted by @Levi-Lesches in #1884 (comment)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions