-
Notifications
You must be signed in to change notification settings - Fork 2k
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
make: introduce __SHORT_FILE__ define #2969
make: introduce __SHORT_FILE__ define #2969
Conversation
The idea sounds good, but the patch some doesn't work for me. It's still showing the full path. |
Well, did you use I'm replacing |
Nevermind, I misinterpreted the purpose of this PR. I thought it should affect the output of the Make system itself. |
@@ -57,10 +57,12 @@ CXXFLAGS = $(filter-out $(CXXUWFLAGS), $(CFLAGS)) $(CXXEXFLAGS) | |||
# compile and generate dependency info | |||
|
|||
$(OBJC): $(BINDIR)$(MODULE)/%.o: %.c | |||
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<) | |||
$(AD)$(CC) -D__SHORT_FILE__=\"$(subst $(RIOTBASE)/,,$(abspath $<))\" \ |
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 think that a more robust way would be to do $(patsubst $(RIOTBASE)/%,,$(abspath $<))
I like this, I didn't like the output from the debug messages with filenames because of the length. |
@gebart changed to patsubst. Why do you think it's more robust? |
I also like this idea. What about additionally introducing something like Opinions? [1] https://www.gnu.org/software/make/manual/html_node/File-Name-Functions.html |
Because with patsubst you can make sure that you are only replacing the prefix of the filename, in case RIOTBASE is set to something really short, and that exists in the tree, like
You don't have to worry about that since when you run |
How should symlinks be handled? |
I would argue that if you have set RIOTBASE to a symlink, then you probably want to use the symlink to refer to that path and not the real path name. |
@gebart completely valid and I agree with you. I was just giving food for thought (: |
Is it me or did they disable the button to re-start a failed travis job? |
It's still there. Are you logged in? |
Ah, no, I wasn't. Thx. |
I don't quite like that "short file" and "file name" don't really show what's the exact difference. "short file" alone made sense together with "file", but like this... Do you have ideas for better names? |
What about
|
@cgundogan How about the other way around, use FILE as a prefix:
or, instead of |
I like |
+1 to FILE_RELATIVE and FILE_NOPATH
|
I strongly vote against introducing new double underscores now that we eliminated them from the header file guards ... |
@Kijewski you're right. |
@gebart, I think |
b344881
to
aed4be3
Compare
Someone dares to say ACK and merge? |
Untested ACK (from my phone, can't run it) |
Go if Travis is green |
make: introduce __SHORT_FILE__ define
While fiddling with the logging, I realized that currently the RIOT make system uses absolute paths for filenames, causing
__FILE__
to contain the full path.That is longer than necessary and also exposes the build system (the messages contain e.g., "/home/kaspar/src/riot.bullshit/*"...), it makes it a lot harder to get reproducable builds built on different build systems.
So I propose the define
__SHORT_FILE__
that only contains the path starting from $(RIOTBASE).I tried redefining
__FILE__
, but gcc complains about that.Opinions?