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

Make: add CppDef extra for extracting FOO in -DFOO as a macro of CPreProcessor #4024

Merged
merged 11 commits into from
Jul 11, 2024

Conversation

masatake
Copy link
Member

See bootlin/elixir#221 .

input.mak:

CPPFLAGS = -DOUTPUT=stdout
foo.o: foo.c
	$(CC) $(CPPFLAGS) $<

Output:

$ ./ctags --extras-Make='+{CppDef}' --fields=+lE -o - input.mak 
CPPFLAGS	input.mak	/^CPPFLAGS = -DOUTPUT=stdout$/;"	m	language:Make
OUTPUT	input.mak	/^CPPFLAGS = -DOUTPUT=stdout$/;"	d	language:CPreProcessor	extras:CppDef
foo.o	input.mak	/^foo.o: foo.c$/;"	t	language:Make

When --extras-Make='+{CppDef}' is given, the Make parser extracts OUTPUT.

Violent heuristics, but I know this is useful when reading a source tree like Linux kernel.
I have tried hard to make the impact on the original code small.

Copy link

codecov bot commented Jun 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.45%. Comparing base (ac6c14c) to head (c16adc6).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4024      +/-   ##
==========================================
+ Coverage   85.42%   85.45%   +0.03%     
==========================================
  Files         235      235              
  Lines       56729    56848     +119     
==========================================
+ Hits        48462    48582     +120     
+ Misses       8267     8266       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@masatake
Copy link
Member Author

masatake commented Jun 26, 2024

We must merge #4025 first.
The coverage must be 100%.

@masatake masatake force-pushed the make--extract-D branch 4 times, most recently from 3054dd8 to 54b4dad Compare July 1, 2024 16:41
@masatake masatake force-pushed the make--extract-D branch 2 times, most recently from b4605ec to 31db172 Compare July 9, 2024 17:32
@masatake
Copy link
Member Author

The last one line the test cases don't cover looks a bit strange for me. Though I have modified the line, I cannot convince we need the line.
I took more time for inspecting the line before merging.

…ments

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
…Processor

Implement the heuristics discussed in
bootlin/elixir#221
Based on ideas suggested by @tleb.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
The edge cases were suggested by @tleb in
bootlin/elixir#221

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Suggested by @tleb in
bootlin/elixir#221 (comment) .

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
With the original code, X for the input:

    C += -DX\
         -I.

is extracted as:

    X	input.mak	/^	-I.$/;"	d	language:CPreProcessor	extras:CppDef

The pattern is extracted from the line next to the line where X
appears.

Reported by @tleb in
bootlin/elixir#221 (comment) .

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
@masatake masatake merged commit e79e67d into universal-ctags:master Jul 11, 2024
46 checks passed
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.

1 participant