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

builder,pref: Allow thirdparty objects compilation with CPP compiler #19124

Merged
merged 8 commits into from
Aug 13, 2023

Conversation

lenaing
Copy link
Contributor

@lenaing lenaing commented Aug 12, 2023

Hi,

As I was working on a binding for an external CPP library, I was hit by:

  • not finding CPP files to compile
  • standard C compilations flags that depends on wether we are compiling a C file or a CPP one

This PR enable one to bind and build such binding, by keeping the #flag @VEXEROOT/thirdparty/path/to/object.o compatibilty.

Kind regards,

🤖 Generated by Copilot at 231859a

This pull request adds support for custom C++ compilers in V and enables compiling third party modules that use C++ code. It modifies the Preferences struct, the cc.v and pref.v files, and adds a -c++ flag to choose the compiler.

🤖 Generated by Copilot at 231859a

  • Define constants for C and C++ standards in vlib/v/builder/cc.v (link)
  • Remove hard-coded C standard flags from C compiler options (link)
  • Add C standard flags to source-specific arguments based on OS and no_std preference (link)
  • Pass file type argument to thirdparty_object_args function (link, link)
  • Add C or C++ standard flags to thirdparty_object_args function based on OS, no_std preference, and file type (link)
  • Check if guessed C file exists and set file type flag accordingly in build_thirdparty_obj_file function (link)
  • Switch to C++ compiler if file type is C++ in build_thirdparty_obj_file function (link)
  • Set default C++ compiler if not specified by user in default_ccompiler function in vlib/v/pref/default.v (link)
  • Add default_cpp_compiler function to Preferences struct in vlib/v/pref/default.v (link)
  • Add cppcompiler field to Preferences struct in vlib/v/pref/pref.v (link)
  • Add -c++ option to command line parser in vlib/v/pref/pref.v (link)

Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work. It does need a small test to keep it from regressing. I'll add it asap.

@spytheman spytheman force-pushed the feature/thirdparty-cpp-compilation branch from 921b5a4 to 52536f6 Compare August 13, 2023 10:14
@spytheman spytheman force-pushed the feature/thirdparty-cpp-compilation branch from 810cb79 to 5bc50c5 Compare August 13, 2023 15:29
@spytheman spytheman merged commit 492e918 into vlang:master Aug 13, 2023
48 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.

2 participants