Raised This Month: $32 Target: $400
 8% 

Compile plugins easily in Notepad++


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
blaacky
Senior Member
Join Date: Oct 2012
Old 05-28-2015 , 00:17   Compile plugins easily in Notepad++
Reply With Quote #1

This crap took me forever to figure out because I don't know much about the cmd nor spcomp but hopefully this will help you. I am switching to using Notepad++ because PawnStudio seems too outdated with the new syntax change.

First you need to install NppExec



It can be downloaded in this window, you just gotta look for it.



Press F6 after it's installed and you've restarted Notepad++, then this window should show up.



Place this into the textbox, save the script, and now it should work to compile by hitting F6 every time you want to compile, and then OK. Ctrl + F6 will always execute the last script you did. So that is even faster.

Code:
NPP_SAVE
cd $(CURRENT_DIRECTORY)
spcomp $(FULL_CURRENT_PATH)
cmd /c move "$(CURRENT_DIRECTORY)\$(NAME_PART).smx" "$(CURRENT_DIRECTORY)\..\plugins\$(NAME_PART).smx"
__________________

Last edited by blaacky; 06-14-2017 at 18:53.
blaacky is offline
Wliu
Veteran Member
Join Date: Apr 2013
Old 05-28-2015 , 08:30   Re: Compile plugins easily in Notepad++
Reply With Quote #2

Off-topic but you might want to try out the new SPEdit program written by _AeonOne_.

Or maybe Atom
__________________
~Wliu
Wliu is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 05-29-2015 , 00:54   Re: Compile plugins easily in Notepad++
Reply With Quote #3

This was already posted by some in the sourcemod highlighting threads, as well as other shortcuts (binding to keyboard, etc.). I've personally adapted the script to the following:

Code:
NPP_SAVE
cd "$(CURRENT_DIRECTORY)"
cmd /q /c del /q "$(CURRENT_DIRECTORY)\$(NAME_PART).smx"
cmd /q /c del /q "$(CURRENT_DIRECTORY)\compiled\$(NAME_PART).smx"
spcomp.exe $(FILE_NAME)
cmd /q /c copy "$(CURRENT_DIRECTORY)\$(NAME_PART).smx" "$(CURRENT_DIRECTORY)\compiled\$(NAME_PART).smx"
Ensures all old versions are gone (no more "already compiled" message), then copies it from the main directory to the compiled folder as well. Makes life easy. Hope this helps ya.
__________________
ThatOneGuy is offline
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 05-29-2015 , 06:04   Re: Compile plugins easily in Notepad++
Reply With Quote #4

Thanks for sharing. I always knew I had to do something like that some day (I did a batch file to help but I never pushed further than you did).

Red
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work
RedSword is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 05-29-2015 , 07:48   Re: Compile plugins easily in Notepad++
Reply With Quote #5

My ultimate compiler script, compiles current .sp, .c, .cpp or .py file.
PHP Code:
set SourcePawn_compiler D:/Dropbox/SourcePawn/spcomp.exe
set SourcePawn_output 
D:/Dropbox/SourcePawn/compiled
set C_compiler 
= $(NPP_DIRECTORY)/bin/gcc.exe
set Cpp_compiler 
= $(NPP_DIRECTORY)/bin/cpp.exe
set Python_interpreter 
D:/Python/python.exe

if "$(EXT_PART)" == ".sp" goto @SourcePawn
if "$(EXT_PART)" == ".cpp" goto @C++
if 
"$(EXT_PART)" == ".c" goto @C
if "$(EXT_PART)" == ".py" goto @Python

echo !!! File extension not found !!!
goto @
end

:@SourcePawn
    NPP_SAVE
    
$(SourcePawn_compiler"$(FULL_CURRENT_PATH)" -o"$(SourcePawn_output)/$(NAME_PART).smx"
    
// place to copy compiled plugin somewhere else
    
goto @end
    
:@C
    NPP_SAVE
    
$(C_compiler"$(FULL_CURRENT_PATH)" -o"$(CURRENT_DIRECTORY)/$(NAME_PART).exe" -pedantic -Wall -Werror -std=c99
    
$(CURRENT_DIRECTORY)/$(NAME_PART).exe
    
goto @end

:@C++
    
NPP_SAVE
    
$(Cpp_compiler"$(FULL_CURRENT_PATH)" -o"$(CURRENT_DIRECTORY)/$(NAME_PART).exe" 
    
$(CURRENT_DIRECTORY)/$(NAME_PART).exe
    
goto @end

:@Python
    NPP_SAVE
    
$(Python_interpreter"$(FULL_CURRENT_PATH)"
    
goto @end

:@end 

Last edited by KissLick; 05-29-2015 at 07:52.
KissLick is offline
aexi0n
AlliedModders Donor
Join Date: Nov 2014
Location: bhop_deluxe
Old 05-29-2015 , 12:21   Re: Compile plugins easily in Notepad++
Reply With Quote #6

Finally no more "YourPlugin.sp is already compiled."
aexi0n is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-29-2015 , 14:29   Re: Compile plugins easily in Notepad++
Reply With Quote #7

I think Bacardi might have had a guide similar to this one somewhere in the SourcePawn Syntax Highlighting for Notepad++ thread. Wherever that thread went.

On a side note: NppExec "helpfully" rebound its help page to Ctrl-Shift-B during its most recent upgrade despite that being the hotkey for compiling in every major IDE everywhere. Which unbound my NppExec shortcut for doing SourcePawn compiling. THANKS NppExec DEVS!
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-29-2015 at 14:30.
Powerlord is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 05-29-2015 , 23:02   Re: Compile plugins easily in Notepad++
Reply With Quote #8

Quote:
Originally Posted by aexi0n View Post
Finally no more "YourPlugin.sp is already compiled."
You're welcome! That shit was annoying, so I had to script it.

Quote:
Originally Posted by Powerlord View Post
I think Bacardi might have had a guide similar to this one somewhere in the SourcePawn Syntax Highlighting for Notepad++ thread. Wherever that thread went.
He does. That is where I originally got mine, actually, which matched the OP code. Then, I tweaked it to do a bit more.

EDIT: Here is my modified script, tweaking it a little based on KissLick's code so that it compiles from any location.
Code:
set COMPILER = C:\path_to_my_compiler\spcomp.exe
set COMPILE_FOLDER = C:\some_destination_folder\compiled
NPP_SAVE
cd "$(CURRENT_DIRECTORY)"
cmd /q /c del /q "$(CURRENT_DIRECTORY)\$(NAME_PART).smx"
cmd /q /c del /q "$(COMPILE_FOLDER)\$(NAME_PART).smx"
$(COMPILER) "$(FULL_CURRENT_PATH)" -o"$(CURRENT_DIRECTORY)\$(NAME_PART).smx"
cmd /q /c copy "$(FULL_CURRENT_PATH)" "$(COMPILE_FOLDER)\$(NAME_PART).smx"
Explanation of components for your own tweaking:
Spoiler
__________________

Last edited by ThatOneGuy; 05-30-2015 at 00:49.
ThatOneGuy is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 05-31-2015 , 07:37   Re: Compile plugins easily in Notepad++
Reply With Quote #9

Seems a bit overly large, I just use this in NppExec and it will compile from everywhere and anywhere too, placing the .smx next to the .sp. I just hit Ctrl+Shift+C and done. Bind to whatever you want from the Plugin Commands section in Shortcut Mapper.

Code:
D:\Link\To\Your\spcomp.exe -D"$(CURRENT_DIRECTORY)" "$(FILE_NAME)"
__________________
11530 is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 05-31-2015 , 15:46   Re: Compile plugins easily in Notepad++
Reply With Quote #10

Quote:
Originally Posted by 11530 View Post
Seems a bit overly large, I just use this in NppExec and it will compile from everywhere and anywhere too, placing the .smx next to the .sp. I just hit Ctrl+Shift+C and done. Bind to whatever you want from the Plugin Commands section in Shortcut Mapper.

Code:
D:\Link\To\Your\spcomp.exe -D"$(CURRENT_DIRECTORY)" "$(FILE_NAME)"
Again, see above for why there is extra code. If the plugin was already compiled once, you will get an error saying that it is already compiled. Hence the code to delete any existing instances first.
__________________
ThatOneGuy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode