Add option to specify language of CSourceFiles
Closes #20655 (without the proposed breaking changes)
The addCSourceFile functions gain an optional language field which defaults to the current behavior (find the language by the file extension of each input).
This does not add support for any new languages beyond what addCSourceFile already supports: the C languages and assembly.
I have a similar commit in #17956: https://github.com/ziglang/zig/pull/17956/commits/650a335befc37dd54dda7fc90c0ac5e03169768c
The main difference is that I don't put the -x flag inside the --cflags ... -- section since it is recognized by zig. But I don't know which one is correct/best...
I have a similar commit in #17956: 650a335
The main difference is that I don't put the
-xflag inside the--cflags ... --section since it is recognized by zig. But I don't know which one is correct/best...
Actually the -x flag is outside of the cflags section in this PR as well, so it gets handled by src/main.zig instead of getting passed as a C flag.
I did notice though, in your PR there is no -x none after the source files were added. If I'm not mistaken, doing addCSourceFile once specifying a language (lets say C), then doing another addCSourceFile not specifying a language, would result in both files being forced to compile as a C file, even if the second file is C++ or something else.
I have a similar commit in #17956: 650a335 The main difference is that I don't put the
-xflag inside the--cflags ... --section since it is recognized by zig. But I don't know which one is correct/best...Actually the
-xflag is outside of the cflags section in this PR as well, so it gets handled by src/main.zig instead of getting passed as a C flag.
ah my bad, I casually read the diff in the web interface and misread.
I did notice though, in your PR there is no
-x noneafter the source files were added. If I'm not mistaken, doingaddCSourceFileonce specifying a language (lets say C), then doing anotheraddCSourceFilenot specifying a language, would result in both files being forced to compile as a C file, even if the second file is C++ or something else.
You're right! thanks.
Is there anything that needs to be done before merging? Thanks.