AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   Compile plugins easily in Notepad++ (https://forums.alliedmods.net/showthread.php?t=263560)

blaacky 05-28-2015 00:17

Compile plugins easily in Notepad++
 
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

http://i.imgur.com/OvRkRCp.png

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

http://imgur.com/N9wLIhw.png

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

http://imgur.com/Z2qfXvK.png

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"


Wliu 05-28-2015 08:30

Re: Compile plugins easily in Notepad++
 
Off-topic but you might want to try out the new SPEdit program written by _AeonOne_.

Or maybe Atom :wink:

ThatOneGuy 05-29-2015 00:54

Re: Compile plugins easily in Notepad++
 
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.

RedSword 05-29-2015 06:04

Re: Compile plugins easily in Notepad++
 
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

KissLick 05-29-2015 07:48

Re: Compile plugins easily in Notepad++
 
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 


aexi0n 05-29-2015 12:21

Re: Compile plugins easily in Notepad++
 
Finally no more "YourPlugin.sp is already compiled."

Powerlord 05-29-2015 14:29

Re: Compile plugins easily in Notepad++
 
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!

ThatOneGuy 05-29-2015 23:02

Re: Compile plugins easily in Notepad++
 
Quote:

Originally Posted by aexi0n (Post 2302446)
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 (Post 2302485)
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

11530 05-31-2015 07:37

Re: Compile plugins easily in Notepad++
 
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)"

ThatOneGuy 05-31-2015 15:46

Re: Compile plugins easily in Notepad++
 
Quote:

Originally Posted by 11530 (Post 2303144)
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.


All times are GMT -4. The time now is 18:28.

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