Skip to content

Resolve relative paths in additional_includes and additional_lib_directories - #394

Open
dariyooo wants to merge 1 commit into
simolus3:mainfrom
dariyooo:fix-path_resolution
Open

Resolve relative paths in additional_includes and additional_lib_directories#394
dariyooo wants to merge 1 commit into
simolus3:mainfrom
dariyooo:fix-path_resolution

Conversation

@dariyooo

@dariyooo dariyooo commented Aug 2, 2026

Copy link
Copy Markdown

With source: source, path is resolved against the pubspec, but additional_includes and additional_lib_directories are passed through as-is. native_toolchain_c then resolves them against its build directory (.dart_tool/hooks_runner/shared/sqlite3/build/<checksum>/), so relative entries can never point at anything useful and only absolute paths work today.

This resolves both against the pubspec, matching path. Absolute entries pass through unchanged. Not breaking, since relative values are currently unusable.

The base is read from input.json['user_defines']['workspace_pubspec']['base_path'] because HookInputUserDefines.path() only resolves a single string.

Test added to test/hook/description_test.dart.

@simolus3 simolus3 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that these options are intended to be used internally only.

If you want to add extensions, is it a requirement for you to link those statically? Dynamically loading extensions through a separate asset is much simpler, doesn't require changes to this package, and allows us to refine the build in the future (exposing new options puts constraints on that).

/// [HookInputUserDefines.path] does for `path`. That method only resolves a
/// single string, so list-valued options need the base itself.
static Uri? _userDefinesBase(BuildInput input) {
final userDefines = input.json['user_defines'];

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there is no better way to do this at the moment, but us crawling through undocumented JSON structures doesn't seem great. I've opened dart-lang/native#3515 to ask for a proper API.

@dariyooo

dariyooo commented Aug 3, 2026

Copy link
Copy Markdown
Author

If you want to add extensions, is it a requirement for you to link those statically?

Sadly, I do not really see another option. l also thought about just compiling a complete sqlite dynamic library that has all symbols in it but I also do not see a way to load that.

@simolus3

simolus3 commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Out of interest, what extension are you trying to load (if it's public)? Most extensions can be configured to call SQLite APIs through function pointers, which means you don't need SQLite and the extension to be linked together statically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants