0
votes

I'm using Notepad++ for write my SA:MP server system, but i have a issue trying to organize my folders: I want to put my compiled files (.amx - like a resulting .exe for non-Pawn devs) in a separated folder called bin, with the same subfolder structure than the sources folder (src).

For clarify, the desired folder structure is this:

Root folder
├── src
│   ├── filterscripts
│   │   ├── file1.pwn
│   │   └── file2.pwn
│   └── gamemodes
│       └── gm_main.pwn
├── bin
│   ├── filterscripts
│   │   ├── file1.amx
│   │   └── file2.amx
│   └── gamemodes
│       └── gm_main.amx

What i want is when i compile a .pwn file, the resulting .amx should go to the equivalent original subfolder but in bin.

My current execute script is this:

NPP_SAVE
cd $(CURRENT_DIRECTORY)
"C:\Pawn\bin\samp\pawncc.exe" "$(FILE_NAME)" -; -(

Is possible to do this only using NppExec?

1
1. You dont not need to cd to $(CURRENT_DIRECTORY). You are already there. 2. What is CURRENT_DIRECTORY? Is it src? I suppose it is src\filterscripts and you need to somehow get that part out from CURRENT_DIRECTORY, so that you can use ..\..\bin\MAGIC whith `MAGIC beeing derived from CURRENT_DIRECTORY. Right? - Lars Fischer
CURRENT_DIRECTORY i think is the directory the current opened file is located. By default the pointed directory at NppExec startup is the folder where notepad++.exe is in. - Vico
And about the second question: exacly. I just need to translate src\filterscripts or src\gamemodes into bin\filterscripts or bin\gamemodes. - Vico
let me think about it a few minutes. - Lars Fischer
Please note that the tag cmd refers to the Windows command prompt, so please correct that... - aschipfl

1 Answers

0
votes

You can use this NppExec script, to derive the needed paths and feed them into some arguments of your compiler:

NPP_SAVE
echo Sourcefile         : $(FULL_CURRENT_PATH)

// ---------------------------------------------------------------------------------
// -- use string function to get ROOT and SRC path and then BIN path:

//  set <var> ~ strrfind <s> <t> - returns the LAST position of <t> in <s>
set Pos_Root ~ strrfind $(FULL_CURRENT_PATH) \src\
//  set <var> ~ <math expression> - calculates the math expression
set Pos_Src ~ $(Pos_Root) + 4
// echo $(Pos_Src), $(Pos_Root)

//   returns the substring
set Dir_Root ~ substr 0 $(Pos_Root) $(FULL_CURRENT_PATH)
set Dir_Src ~ substr 0 $(Pos_Src) $(FULL_CURRENT_PATH)
echo Src-Directory      : $(Dir_Src)
echo Project-Directory  : $(Dir_Root)

set Dir_Bin = $(Dir_Root)\bin
echo Bin-Directory      : $(Dir_bin)

// -- Now use the previously determined substring to get the BIN path and then
// -- derive the Target path with src replace by bin 

// get the target dir:
// set <var> ~ strreplace <s> <t0> <t1> - replaces all <t0> with <t1>
set TARGET_PATH ~ strreplace $(CURRENT_DIRECTORY) $(Dir_Src) $(Dir_Bin)
echo Target-Directory   : $(TARGET_PATH)

// ----------------------------------

// use compile with $(FULL_CURRENT_PATH) and $(TARGET_PATH)
"C:\Pawn\bin\samp\pawncc.exe" $(FULL_CURRENT_PATH) whatever-output-option $(TARGET_PATH)

Notes

  • the NppExec documentation explains all the different set possibilities, check them out
  • alternatives to dynamically derive the paths would be a static definition of the paths:
    • place the "PATH settings" as static paths to ROOT, BIN, SRC, etc inside the NppExec script
    • define the paths as environment variables that you access from the NppExec script
    • a complete different approach would be to store several $(FULL_CURRENT_PATH) and do some change directories between :
      1. a cd.. to jump from src subdir to src
      2. to ROOT,
      3. to bin
      4. then do the string replacement