-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add crystal tool dependencies
#13613
Add crystal tool dependencies
#13613
Conversation
config = create_compiler "tool dependencies", no_codegen: true | ||
config.compiler.no_codegen = true | ||
|
||
config.compiler.dependency_printer = dependency_printer || DependencyPrinter.new(STDOUT) | ||
config.compile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be expressed as an extra parameter of Crystal::Command#compile_no_codegen
? In that case the command-line argument handling would be done inside #create_compiler
itself, similar to hierarchy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the benefit? It seems to me this is a pretty simple setup. Yes, it's some duplicate code. But that's not bad. Combining everthing in one place adds quite a bit of complexity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't run this branch yet, but I believe this means the tool doesn't have access to any of the common command-line options that other tools have (-D
, --prelude
etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is indeed a problem with this approach: crystal tool dependencies
still shows the full help rather than this help, but the option parser only ever accepts this -f
, and not the actually shown options like -h
. In particular this -f tree|flat
conflicts with the other -f text|json
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If crystal tool hierarchy
accepts -D
and --prelude
, so should this tool; this is not merely a matter of code duplication
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual common piece that should be reused for a single option parser instance is create_compiler
. Utilizing compile_no_codegen
would add unnecessary complexity for no real gain.
Co-authored-by: Quinton Miller <nicetas.c@gmail.com>
how hard would it be to remove a branch? like |
@beta-ziliani It won't be hard. But I would prefer to keep this PR focused on a minimal implementation. Let's talk about these enhancements in a separate issue. |
@straight-shoota Just as a suggestion, if it's possible to add redundant dependency warnings in the Crystal file that would be great. |
PR title still refers to the singular name (dependency vs dependencies) |
crystal tool dependency
crystal tool dependencies
I've changed the target branch to a feature branch on this repo (#13631). I'll be making a couple of individual PRs to that branch and we can merge that all together into master after the freeze period for 1.9 is over. |
This tool prints all source files read by the compiler in their require order.
It's a basic implementation with two format options,
tree
andflat
. They are identical except thatflat
has no indent.Files are printed exactly in the order they are required. Duplicates (i.e. when a file had already been required before) are not shown.
Example output for an empty file
Resolves #11481