Code Monkey home page Code Monkey logo

Comments (6)

Civitasv avatar Civitasv commented on July 30, 2024 1

That's an interesting idea! Currently, for generate step, this plugin already supports setting env by using kits or variants(though we don't support env option yet). So we should consider the precedence of them.

For build and run step, currently there is no convenient way to do this. Maybe we can try to implement your idea.

from cmake-tools.nvim.

hfn92 avatar hfn92 commented on July 30, 2024 1

Since since you seem to be okay with the general idea of the feature I started with a bit of a Prototype.

https://github.com/hfn92/cmake-tools.nvim/commits/env-feature

This should already work for launch target but not for building and debugging. And probably only for unix but its a start

from cmake-tools.nvim.

Civitasv avatar Civitasv commented on July 30, 2024

Bravo 👏

from cmake-tools.nvim.

rohit-kumar-j avatar rohit-kumar-j commented on July 30, 2024

@hfn92 , this is a good feature, and I would like to test it out fully for windows. Do you have a test project covering all the test cases for this?

In the mean time, I found an issue on windows, and now pushed a fix....

This was when executing :CMakeRun in terminal mode:

~$ cd "C:\Kdev" && cmake --build C:\Kdev\build --target Ktest_compiler_test && cmd /C "cd "C:\Kdev\build\" && C:\Kdev\build\test/Ktest_compiler_test.exe"  

The ideal command should be:

~$ cd "C:\Kdev" && cmake --build C:\Kdev\build --target Ktest_compiler_test && cmd /C "cd C:\Kdev\build\ && C:\Kdev\build\test/Ktest_compiler_test.exe"

I think Windows didn't expect and additional " for within the cmd /C " ... " command.

launch_path = terminal.prepare_launch_path(launch_path)
full_cmd = "cd " .. launch_path .. " &&"
...
if osys.iswin32 then -- wrap in sub process to prevent env vars from being persited
full_cmd = 'cmd /C "' .. full_cmd .. '"'
end

In terminal.prepare_launch_path:

if osys.iswin32 then
path = '"' .. path .. '"' -- The path is kept in double quotes ... Windows Duh!

from cmake-tools.nvim.

hfn92 avatar hfn92 commented on July 30, 2024

Hi @rohit-kumar-j. I don't really use windows so it's always hard for me to test 😅 .

But this should cover most cases

int main(int argc, char **argv) {
  auto str = std::getenv("str");
  auto str_with_ws = std::getenv("str_with_ws");
  auto number = std::getenv("number");

  assert(str && str == std::string("test_str"));
  assert(str_with_ws && str_with_ws == std::string("test str"));
  assert(number && number == std::string("1234"));
  return 0;
}

with the config

  env = {
    number = 1234,
    str = "test_str",
    str_with_ws = "test str"
  },

It always depends on the os and the tool whether not " needs to be included on the command line :/

Bit OT but I was wondering if cmake-tools should even handle execution itself at all. Maybe it would make sense to depend on overseer.nvim. It should handle args and env var correctly. And I assume it works for windows too. Maybe thats better than trying to implement and test everything again for every os.

I'm currently on a branch that runs all command trough overseer (hfn92@d256a43). It works fine for me at aleast.

from cmake-tools.nvim.

Civitasv avatar Civitasv commented on July 30, 2024

Currently, overseer.nvim is already a choice of executor, and now the only runner is the terminal, we can also make overseer a runner too.

from cmake-tools.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.