fix(make): keep plain target names that are also path prefixes#1693
fix(make): keep plain target names that are also path prefixes#169315daksh-2003 wants to merge 2 commits into
Conversation
|
#1219 discusses a possibility of using the information of whether the name is a |
c34f5f6 to
d0ef4e2
Compare
|
Few things on it @akinomyoga (if I am getting it right as to what you are referring to) : I did weigh .PHONY. The PR keys on a different bit: the collapse stage previously didn't know which names make actually reported as targets (the stage separation you noted in #1219). It now carries that across — an is_target map marks the extracted names, and the collapse stage re-offers a candidate's plain form only when it's both a reported target and a path node with children. Pure synthesized prefixes (the recursive subdir/… case) are never in is_target, so #544/#858 collapsing is unchanged. On .PHONY specifically: it is extractable (the -p dump marks blocks with # Phony target (prerequisite of .PHONY).), but as the criterion, I feel it's both insufficient and unnecessary here: a. Insufficient — a plain install: rule not declared .PHONY is still a real, user-facing target that hits the same collapse; a phony-only rule keeps dropping it, i.e. only partially fixes #1219: install: # not .PHONY -> phony-only STILL drops it With the approach in PR, both this and the CMake .PHONY case complete to install + install/. b. Unnecessary — CMake marks its targets .PHONY, so is_target already covers the reported cases. The two criteria only differ for a non-phony target that is also a path prefix and is genuinely directory-prep, e.g. sub: ; mkdir -p sub with sub/a sub/b: | sub. For the approach taken here, it offers sub alongside sub/; a phony-only rule would offer just sub/. I think offering sub is acceptable: make sub is valid, it matches pre-2.12 behavior, and it's statically indistinguishable from the legitimate non-phony install above — the only signal separating them is .PHONY, which misclassifies that case. It also needs no change to the portability-sensitive extraction awk. |
|
I don't know how seriously I should respond to the details of AI-generated text these days, but I guess short responses would suffice for LLM, which has an excellent ability of capturing the context.
Isn't that just the Makefile is broken?
Yes, it's unnecessary to satisfy your purpose. However, it breaks another behavior, as indicated in the next paragraph in your response.
This is the key point. First of all, there is a reason that subdirectory names are dropped, i.e., to be consistent with the normal pathname completions. That's independent of the present issue, where the non-subdirectory |
|
The AI remark… genuinely not something you come across daily in communities That said, I think I feel why it came across that way — and it's a genuine miss on my side, not going to dress it up. I anchored on "make reported install as a target, so don't drop it" and never circled back to what that actually means: .PHONY. You're right that .PHONY is the thing that separates a logical install (no real directory — fine to surface) from a real sub/ that just happens to also be a target, and the is_target check can't tell those apart. For what it's worth, the "statically indistinguishable" line was me reasoning past the obvious answer — I'd fixated on the CMake repro (all phony there) and generalized off the flat target list. And the non-phony install example was a weak justification anyway; it just gave me the nudge to go back and re-read the manual. |
|
as for carrying over .PHONY info to collapsing stage..if relied on awk parser, it seems it would degrade to today's behavior on non-gnu make, which I don't know how much doing it would solve the core idea for issue |
|
but yeah, the extracter is already only parses GNU's -p output it seems |
It's unrelated to this PR, but I strongly feel that these days, being a maintainer of several projects. I've been thinking of what we got and what we lost in the OSS communications with the emergence of LLM. The LLM expands the human inputs into a large amount of text, which contains both something that makes sense and doesn't. When I directly chat with an LLM, I can simply ignore weird parts. The issue happens when it is used for real conversations. I can't tell which part of the weirdness arises from LLM and which part would be the OP's thoughts, so I am supposed to take a lot of time to respond to all of the points, including LLM quirks, which leaves me with an empty feeling. I'm very comfortable with the style after you switch (though you might still use LLM to improve wording). |
|
I'm now trying to see if there is another solution. I haven't yet tested it, but my naive idea is like f09a37c (after simple refactoring 2c12190).
Yeah, e.g., BSD make doesn't support it. We already assume GNU make for our completion. |
|
I was just checking something...it seems upstream has introduced: make --print-targets( which I believe would fall on (4.4.90→4.5) ), which might mean moving enumeration off the -p dump. So reanchoring a new dependency on -p's phony prose...where we might move to print targets once it lands for enumeration.... |
|
at least the first stage would be better moving away from awk parsing helper way project has today... |
|
not sure if .phony gating is that of a good idea anymore...only if we stick to the way of enumeration we are doing today for bash completion |
Thanks. Does that new option emit a machine-parseable format? That would be useful. Thank you for the information.
The format of
Even if the new make is shipped, we still need to support older versions of make at the same time. We may include the code to use |
I agree to that. Beleiving maintainance also would only go up: with print targets on top of -p as fallback. Perhaps, i dont know but, something like --print-phony on upstream... idk if it has been discussed over there or if Paul had any opinions on it, but seems like wishful thinking at this point. I would check this there once. meanwhile, for now, gating on phony where we have -p dump seems the only way feasible at least |
"--print-targets will print all explicit, non-special targets defined in the makefiles, one per line, then exit with success. No recipes are invoked and no makefiles are re-built." seems flat only, not structured like a json or something. seems would be trivially consumable by while read, grep, compgen -W |
|
Yeah, I cloned the repository from Savannah, built the I also checked the |
|
on your posted approach, a couple of things(from the commit): {target#target:} — shouldn't it be ${target#phony:} The is_phony_target = 0 in the starts_with($0, prefix) rule.....which fires on every line when the prefix is empty (make ), wiping the flag the marker just set. |
d0ef4e2 to
0277dc0
Compare
Ah, yeah. Right. Thank you.
Hmm, the existing implementation seems tricky. This means that an unrecognized line like |
|
i tried testing above what u suggested. have modified the tests a bit, along with empty prefix thing and the other one |
0277dc0 to
01b0ca4
Compare
|
The refactoring commit should be separated. Otherwise, it's hard to review the substantial changes. I've separated back the original commit of refactoring and force-pushed. |
I am not aware much of conventions for commits here. I carried forward from cmake's conventions for one commit per PR |
01b0ca4 to
a3d0671
Compare
That doesn't apply to this project. The convention seems to largely vary depending on the project. |
a3d0671 to
862c7e0
Compare
862c7e0 to
4cb0d6e
Compare
|
corrected for few over spills over 79 cols in test_make.py |
|
@akinomyoga one question out of curiosity: i was seeing zsh way of doing things, and I believe they expose a mechanism with some flags for opt in "collapse" with different semantics offered, while I think the default remains to be something collapsing targeted when implemented. what are your thoughts on that? |
That would touch the central policy of this project, which I asked about on the very first day when I joined the maintainer group. The answer has been That is, we want to minimize the customizability unless necessary. There is a related argument in #720 (comment). edit: I was forgetting, but I noticed that there has also been a related sentence in |
4cb0d6e to
d047e2f
Compare
|
I added adjustments in the push I also adjusted the commit message to clarify that make 3.80 is merely the minimum version I checked; the format of |
@akinomyoga couple of things (both sort of non blocking I believe in the scope of this): what are your thoughts on this? if we do decide to go with either or both, should this be a separate PR or this one only? |
I think the list in the present completion code hasn't been updated since it was added by b28d710 (2012). Those special targets aren't intentionally excluded. They can be added to the list. Or another option may be to exclude all all-caps targets starting with a period.
I also felt it while I was checking another PR #1577, but I haven't carefully thought about whether that is totally equivalent to the present handling. The code was originally contributed in the form of a sed script. The strange way of processing might be due to the limitations of the sed language. However, there might possibly be another reason for the present strange way. If we can mathematically transform the present processing to the suggested one, then we can safely rewrite the processing in the suggested way. Otherwise, we want to think carefully about hypothetical inputs causing different results, and confirm that You may modify the loop structure this time, with attention. Or you can simply add |
We have been writing the raw make targets into COMPREPLY and then re-producess them to generate the actual completions. However, we should store the make targets, which are not final completions, in an independent array. Co-authored-by: Daksh Mamodiya <mamodiyadaksh41@gmail.com>
d047e2f to
2573ed2
Compare
The target completion models target names as filesystem paths and collapses shared `/'-separated prefixes to `dir/'. But `/' in a target name is not always a directory boundary: CMake marks targets like `install' (with `install/local', `install/strip') and `X' (with `X/fast') as .PHONY, using `/' as a naming convention. The collapse treated them as directories and dropped the plain, runnable form, leaving only the `/'-suffixed siblings. Detect phony targets in the extraction stage (the `# Phony target' marker in `make -p' output, present since at least make 3.80) and tag each name `phony:' or `file:'. Phony targets are logical labels, not paths, so offer them as-is; only non-phony targets, which are real filepaths, go through the path collapse. Recursive-Makefile behavior (scop#544/scop#858) is unchanged, and a non-phony directory-prep target (e.g. `sub' built by a recipe) still collapses to `sub/'. Fixes: scop#1219 Co-authored-by: Koichi Murase <myoga.murase@gmail.com>
2573ed2 to
b29d4ea
Compare
|
Since another PR #1577 for the make script was merged, I've rebased the PR head on top of the current |
will push something in a bit |
I think those should be done in separate PRs. |
sure. fine with me. is there anything else left for this PR to close? |
akinomyoga
left a comment
There was a problem hiding this comment.
Nothing from me. Let's wait to see if others have something.
|
Nothing from me, quite frankly the make completion as a whole is already beyond something I'd like to touch or look at, but didn't catch anything alarming on a quick skim, and there are tests, and no existing tests needed modifications, so I'm fine. A quick LLM review didn't yield anything of substance that I can tell either. |
The make completion collapses /-separated target names as filesystem paths, so a target that is also the prefix of others (install with install/local, X with X/fast) is dropped and only its /-suffixed siblings are offered.
Fixes #1219
Approach:
/correctly #858 is unchanged.