[PROPOSAL] make2compdb.c#392
Conversation
|
Epic! I'll be test driving this myself. |
|
Thanks so much, @g-berthiaume! It's interesting to see these concepts through another person's lens. Make all functions except the entry point When I compile with GCC 16 in the latest w64dk I get a It's "peek" not "peak". I was genuinely confused by this because the latter would normally mean highest value (highest memory use, highest count, etc.). Also "threated" instead of "treated" and "stars" instead of "starts", and "emtpy" instead of "empty". The program always outputs UTF-16, and there seems to be a misunderstanding how output is supposed to work. I'm surprised the resulting If the output device is a console, use As a see it for yourself test of the above, these must both produce the same result: The parser should be more oriented around tokens than substring search. Don't substring search for Because it's substring matching, this doesn't work as intended: Produces an
Produces output with escaped single quotes, The Only captures the second command. Add a test for this when you fix it. Unless this is intentional? The Compiler
Trivial to adjust, but even 16MiB arena may be a little tight for larger builds. Maybe 64M? Build commands can be quite bloated. Nothing below is a problem, nor must change. Just pointing them out as commentary. If you're committed to GNU-style toolchains (e.g. GCC, Clang), as MSVC is excluded, then because you're linking Might be surprising (or might not given those void example(Str const s)
{
s.ptr[0] = 0;
}But |
Would calling setlocale before starting the process not help? Then it wouldn't matter what the user's locale is. |
This PR introduces
make2compdb.A new CLI tool to generates Clang's JSON Compilation Database files (
compiler_commands.json) from make build systems.The API can be used in the following way:
Properties
Expand to see peports
$ peports make2compdb.exe KERNEL32.dll 0 ExitProcess 0 GetCommandLineW 0 GetConsoleMode 0 GetCurrentDirectoryW 0 GetStdHandle 0 ReadFile 0 VirtualAlloc 0 WriteConsoleW 0 WriteFile SHELL32.dll 0 CommandLineToArgvWExpand to see performance benchmarks
While I'm sure, we could do better, the CLI tool seems to be acceptably fast.
It seems to be a bit faster on Linux than on Windows, but I'm not sure if I'm not just measuring piping speeds.
With a small project (linux)
With a small project (windows)
With ffmpeg (windows)
With ffmpeg (linux)
By comparison, the https://github.com/nickdiego/compiledb takes 18 seconds to analyzer ffmpeg.
$ hyperfine "compiledb -p ffmpeg_output.txt" Benchmark 1: compiledb -p ffmpeg_output.txt Time (mean ± σ): 18.469 s ± 0.258 s [User: 18.128 s, System: 0.205 s] Range (min … max): 18.127 s … 19.003 s 10 runsSo it's a 331x speedup.
Features
\\), EOL (\r\n) and executable extension (.exe).gcc main.c lib.c -o main).Address this issue compiledb returns nothing when compiling headers with
-xswitch nickdiego/compiledb#140Address this issue [Feature Request] Support non-standard make command in directory parsing nickdiego/compiledb#146
Address this issue Different results betweent "compiledb make" and "make | compiledb" nickdiego/compiledb#102
Address this issue Support ccache (and other 'wrappers') nickdiego/compiledb#2
Two additional features
1. No Make mode
I'm a big fan of the "unity build" compilation technique (like the one used in u-config).
Therefore, I often don't have a use for a makefiles in my projects.
That said, I still need
compiler_commands.jsonfor my IDE to work.How great would it be to just pipe my build command into
make2compdb?Well you can!
2.
--verboseI believe that there's a lot of value in providing your technical users tools to help them self-diagnose issues.
In my experience, this usually leads to better bug reports and therefore help maintaining the project.
This is why I have added the
--verboseCLI flag.When it's passed to
make2compdb, the stdout contains debug information.Limitations
As a non-native English speaker, I can empathize with this being a pain point.
That said, I didn't find a robust way to parse the Makefile output in different languages.
Note for reviewer
I've learn a lot building this project: Arena, fuzzing, CRT-less windows programming.
When starting this project, I think I underestimated the number of corner cases to handle.
To be honest, the shell parsing humbled me a little bit. :^)
One of the reasons I appreciate w64devkit, is its high standard when it comes to programming.
I think I have a lot to learn from the maintainers of this project, so I welcome any of your suggestions on how to improve
make2compdb.Closes #251