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

Substitution for fortran.gfortranExecutable #213

Closed
okhlybov opened this issue Feb 15, 2021 · 8 comments
Closed

Substitution for fortran.gfortranExecutable #213

okhlybov opened this issue Feb 15, 2021 · 8 comments

Comments

@okhlybov
Copy link

Hi,

It would be very nice to have the fortran.gfortranExecutable command substitution in order to set it up programmically, for example to keep it in sync with the toolchain in effect, instead of having it hard coded.

Consider something like

{
  "fortran.gfortranExecutable": "${command:cmake.buildkit.fc}"
}
@machsix
Copy link
Contributor

machsix commented Mar 5, 2021

Totally agree. I think the extension should set header and compiler path based on something like compile_commands.json similar to clangd server. This file can be generated by most high level make tools https://www.jetbrains.com/help/clion/compilation-database.html#compdb_generate

@gnikit
Copy link
Member

gnikit commented Mar 5, 2021

That would certainly be an interesting feature to have. I am not a big user of CMake, I tend to use GNU autotools, but I suspect that if we were to integrate build systems like CMake in the extension, it would have to happen at a level that does not affect the VSCode settings, since depending how you have setup VSCode project these settings could be synced across all other projects.

I suspect that a similar option could be applied for the includePaths option as well, allowing for Modern Fortran to locate modules that are not in the default include directories and in linterExtraArgs which would include the compilation flags used.

I am more than happy to hear your thoughts on how this could be implemented in a reasonable manner.

@okhlybov
Copy link
Author

okhlybov commented Mar 5, 2021

Well, to be more specific, I run the MSYS2 extension for VS Code where C/C++ support is pretty complete though the MS' CMakeTools and CppTools extensions and FORTRAN support is lagging behind due to lack of such substitution.

@gnikit
Copy link
Member

gnikit commented Jun 8, 2021

@okhlybov Out of curiosity wouldn't ${config:cmake.buildkit.fc} also do the trick?

@okhlybov
Copy link
Author

okhlybov commented Jun 8, 2021

@okhlybov Out of curiosity wouldn't ${config:cmake.buildkit.fc} also do the trick?

No. The cmake.buildkit.fc is not a static configuration parameter but a function which lazily creates the path according to the build kit currently in effect.

@gnikit
Copy link
Member

gnikit commented Jun 9, 2021

That is unfortunate, I was hoping we could squeeze this into PR #238 but if the settings string uses ${command:} we might not be able to. Would you be able to provide a Minimal Working Example using CMake with fortran for me to have a look?
On a related note, is the functionality that you are mentioning available in the C/C++ extension?

@okhlybov
Copy link
Author

Well, I don't think that the ${command:} handling is any different from the ${config:}.

As for example, take a look at my CMakeWorks project.
It covers both the CMake and the VS Code and is meant to be a complete
new project template.

On a related note, is the functionality that you are mentioning available in the C/C++ extension?

Yes, the C/C++ part works pretty well.
There are some glitches even within the core VS Code's code itself concerned with various string interpolation issues in certain parts of the code, though. For instance, the terminal.integrated.shell setting is not interpolated, so ${command:} can't be used here to obtain the build kit -specific shell. Also, while the cmake.cmakePath gets interpolated so the ${command:cmake.buildkit.cmake.exe} can be used to obtain the build kit -specific CMake executable, its value gets evaluated eagerly resulting in an inability to track the subsequant changes to the build kit. Hence, a window reload is required after the build kit switch in order a new value of the cmake.cmakePath to take effect.

These issues should be considered when adding interpolation support to the Fortran extension.

@gnikit
Copy link
Member

gnikit commented Nov 17, 2021

Variable interpolation has been added to v2.6.1 it probably is unable to do what is requested in this issue but we are tracking this request in #133 . Please move any further queries there or if not applicable open a new issue.

@gnikit gnikit closed this as completed Nov 17, 2021
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

No branches or pull requests

3 participants