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

Include module path in virtual file names #11852

Draft
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

kLabz
Copy link
Contributor

@kLabz kLabz commented Dec 4, 2024

When using -D dump-dependencies, macro modules show up with their file names, but for macro generated modules that's unusable (they're all named /server/file_x_y which doesn't help much).

tbh I'm not sure this is the kind of fix we need here, but I also didn't want to break things relying on current -D dump-dependencies output.

@@ -461,7 +461,7 @@ let make_macro_api ctx mctx p =
in
let add is_macro ctx =
let mdep = Option.map_default (fun s -> TypeloadModule.load_module ~origin:MDepFromMacro ctx (parse_path s) pos) ctx.m.curmod mdep in
let mnew = TypeloadModule.type_module ctx.com ctx.g ~dont_check_path:(has_native_meta) m (ctx.com.file_keys#generate_virtual ctx.com.compilation_step) [tdef,pos] pos in
let mnew = TypeloadModule.type_module ctx.com ctx.g ~dont_check_path:(has_native_meta) m (ctx.com.file_keys#generate_virtual m ctx.com.compilation_step) [tdef,pos] pos in
Copy link
Member

Choose a reason for hiding this comment

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

Let's rename m to mpath while we're here.

@Simn
Copy link
Member

Simn commented Dec 5, 2024

We could name these something like defineType/Module_step_counter to make it a bit more human-readable. Where does that /server/ you mention come from?

@Antriel
Copy link
Contributor

Antriel commented Dec 5, 2024

The /server/ was from my example. It just includes the full path, and that happened to be the project root. Ideally it would include the package and the module name, but even just the module name is better than nondescript name.

@Simn
Copy link
Member

Simn commented Dec 5, 2024

Yes the package should be there too of course. Internally the naming doesn't really matter, the only part that's important is that the file key is unique. So a normal module path with the step and counter suffix would be fine too.

@kLabz
Copy link
Contributor Author

kLabz commented Dec 5, 2024

Printf.sprintf "%s_%i_%i" (s_type_path mpath) step !virtual_counter should do?
Would also be nice to convert that dotpath to directory structure, I suppose

@skial skial mentioned this pull request Dec 9, 2024
1 task
@Antriel
Copy link
Contributor

Antriel commented Dec 17, 2024

RE dotpath to directory structure: Yes please. It will be nicer. I could replace dots with slashes on my dependency visualizer, but that would require special handling for .macro.hx and such, which is less nice.

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