0

I'm trying to make a script that will compile C++ code using cl. Currently, I have to run vcvarsall.bat every time I run the script, because running another script seems to totally reset the NppExec console. That wastes time re-initializing the environment on every compile, which is kind of annoying. I'd like to run vcvarsall.bat once when Notepad++ starts up, and then have a separate script to actually compile, which assumes that's already been done.

So, is there a way to make a script that will run in the existing instance of the NppExec console, rather than starting a new one and resetting everything?

I've tried searching for this problem, but I couldn't find anything, or maybe I just couldn't find the right way to phrase the question. I've tried doing it using "call" on the .bat files in scripts, but it seems like NppExec doesn't understand that.

1 Answers1

0

You may use a copy of NppExec.dll to have an additional NppExec's Console that will be dedicated to running the VC's command-line tools. You may name it e.g. NppExecVC.dll as described here: https://htmlpreview.github.io/?https://raw.githubusercontent.com/d0vgan/nppexec/develop/NppExec/doc/NppExec/NppExec_Manual/2.4.html

Note: in today's Notepad++, you need to make a copy of the entire folder "plugins\NppExec", giving that copy a name of e.g. "plugins\NppExecVC", and then rename "plugins\NppExecVC\NppExec.dll" to "plugins\NppExecVC\NppExecVC.dll" to match the .dll name with the folder name.

Then you may create a start-up script for that instance of NppExecVC.dll. The start-up script may be e.g.

set local @exit_cmd = exit  // sends "exit" when NppExec's Console is closed
cmd /K "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x86

To read more on NppExec's start-up script, refer to https://htmlpreview.github.io/?https://raw.githubusercontent.com/d0vgan/nppexec/develop/NppExec/doc/NppExec/NppExec_Manual/4.2.html

Then, while the VS Developer Command Prompt is running in NppExec's Console, you'll be able to e.g. compile the current file via the following command in NppExec's Console:

cd /D "$(CURRENT_DIRECTORY)" && cl "$(FILE_NAME)"
DVV
  • 204
  • 2
  • 5