This adds a compiler utility class that handles generating compile commands and running them. Instead of having to pass the compiler path and 3 groups of flags between the configuration and the test format this allows us to just pass the compiler object.
Details
Diff Detail
Event Timeline
I tried pretty hard to find a way that this wouldn't work under msvc, but it looks like it all should be fine. It won't pass along the compiler information for msvc, but it will still work.
Mostly LGTM, but I left some nits.
test/libcxx/test/compiler.py | ||
---|---|---|
5 | I probably would have put this directly in the libcxx module rather than libcxx.test, but nbd. | |
13 | This should maybe be just None, since you want it to abort if try to use it before it's initialized (and bool((None, None, None)) == True). | |
20 | Isn't this an error? Should probably raise an exception... | |
48 | I'm not a fan of using one argument to accept multiple types that don't conform to the same interface (or behave like the same duck, as it were). Just require that infiles is a list. The argument name is plural, after all. | |
102 | parsed_macros = {} | |
107 | macro, value = l.split() |
Address @danalbert's comments.
test/libcxx/test/compiler.py | ||
---|---|---|
5 | I think that's a good change. | |
13 | Oop, didn't think of that. Thanks. | |
20 | Perhaps dumpMacros() should throw an exception if the return code is non-zero, but I don't think it makes sense for _initTypeAndVersion() to throw because then CXXCompiler wouldn't work with compilers that didn't support the dump macro command. Any suggestion on the type of the exception? | |
48 | I'm not a big fan either but I think its the best option. I really hate forcing the transformation from string -> list at every call site, I think that makes the the calling code less clear. Even if we only accept a list of files we still have to diagnose being passed a string. Requiring a list is almost the same amount of work as just accepting it. If this were C++ I would almost certainly have two overloads for both a single file and for a list of files. Accepting both types is quite useful for the user and I don't believe it makes the code unclear. What problems do you envision this code causing? | |
107 | value can contain spaces. We only want to split on the first space, not all of them. |
I probably would have put this directly in the libcxx module rather than libcxx.test, but nbd.