Search code examples
cmdnotepad++nppexec

running an exe from NppExec


I'm making a script to compile and run an entire project on Notepad++ using NppExec.

I keep each project on a folder and each folder has a makefile to compile the entire project, the compiler will produce a single .exe file so in each folder there is just one executable that has the same name of the folder (with the .exe extension).

I made the first part of the script (compiling with the makefile) but I don't know how to make the second part (running the executable). I know how to run an executable in NppExec but I'm trying to do something different: I want to compile the exe without specifying its name in the commands so that I can use the script to compile and run every project organized as I explained above (each folder with only one .exe that has the same name of the folder).

How can I do it? If you don't know how to do that in NppExec, how can I do the same thing in cmd? (I can then write that in NppExec by adding cmd \c at the and of the command)


Solution

  • There are some special targets make knows about:

    • all: to compile everything
    • run: to run the program, if this depends on all, then the program is recompiled if necessary
    • clean: for necessary clean ups

    So what you need are two npp_exec scripts which you can bind to different keyboard shortcuts (save the scripts under some names, in the menu use Plugins, Nppexec, Advanced options: add the scripts to the menu using the controls on the left; give the menu items different menu_names; restart notepad++; goto Settings, Shortcut mapper, Plugins commands: you will find the menu_names somewhere in this list, you can assign keyboard shortcuts to them).

    The second ingredient are the targets in the makefile:

    • all: depends on your binary
    • run: depends on all, the command would normally be something like
      ./$(ProgName)
      
      but in your case (windows with mingw32-make, as explained in the comments, and you need a command window) your run target would look like
      run: all
           cmd /C $(ESEGUIBILE)
      

    This way you have one setup in Notepad++ that works for all your folders, the interface is

    • make all
    • make run

    The makefiles in each folder know the name of the folder specific binary, you only need to add the run section to each makefile.