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

Add option to specify language of CSourceFiles #20687

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GalaxyShard
Copy link

@GalaxyShard GalaxyShard commented Jul 20, 2024

Closes #20655

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.

@GalaxyShard GalaxyShard force-pushed the master branch 2 times, most recently from 2156522 to f73ed36 Compare July 21, 2024 04:26
@GalaxyShard GalaxyShard changed the title Add std.Build.Module.addForeignSourceFile (non-breaking) Add option to specify language of CSourceFiles Jul 21, 2024
@xxxbxxx
Copy link
Contributor

xxxbxxx commented Jul 22, 2024

I have a similar commit in #17956:
650a335

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...

@GalaxyShard
Copy link
Author

I have a similar commit in #17956: 650a335

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...

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.

@GalaxyShard GalaxyShard force-pushed the master branch 2 times, most recently from 6581419 to c4dfa85 Compare July 23, 2024 19:35
@xxxbxxx
Copy link
Contributor

xxxbxxx commented Jul 24, 2024

I have a similar commit in #17956: 650a335
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...

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.

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 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.

You're right! thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants