User forums > Using Code::Blocks

Passing exe filename to an external tool

(1/3) > >>

vserghi:
Is there a way to pass the exe filename to an external tool?

I have a graphical version of Insite installed, and it needs the exe name passed to it for it to work from C::B. I could manually open the exe from Insite when it opens, but it would be useful to pass it the exe from C::B.

I can only see;
PROJECT_FILENAME
PROJECT_NAME
PROJECT_DIR
ACTIVE_EDITOR_FILENAME
ALL_PROJECT_FILES
MAKEFILE

and just so I'm not making a mistake; I type in "${macro name}" (no quotes) into the Parameters box, this is correct isn't it?

Vasilis.

thomas:
The six vars you stated are the only builtin ones unless I am mistaken (--> macrosmanager.cpp).
However, there is a "Custom variables" tab where you can enter whatever you want, so as a temporary workaround, you could use that.

Maybe you want to submit a feature request on the SF project site as this sure is something more people might find useful.

thomas:
Back from dinner, thinking about it again... looks quite simple, actually.
Did not compile this, but it might just work:

--- Code: ---Index: src/sdk/macrosmanager.cpp
===================================================================
RCS file: /cvsroot/codeblocks/codeblocks/src/sdk/macrosmanager.cpp,v
retrieving revision 1.5
diff -u -r1.5 macrosmanager.cpp
--- src/sdk/macrosmanager.cpp 8 Jul 2005 09:49:04 -0000 1.5
+++ src/sdk/macrosmanager.cpp 1 Aug 2005 17:39:22 -0000
@@ -34,6 +34,7 @@
 #include "cbproject.h"
 #include "cbeditor.h"
 #include "managerproxy.h"
+#include "compiletargetbase.h"
 
 MacrosManager* MacrosManager::Get()
 {
@@ -100,6 +101,7 @@
  ${ACTIVE_EDITOR_FILENAME}
  ${ALL_PROJECT_FILES}
  ${MAKEFILE}
+ ${OUTPUT_EXECUTABLE}
 
  ${AMP} TODO: implement AddMacro() for custom macros (like this)
  */
@@ -118,7 +120,7 @@
  buffer.Replace("${PROJECT_NAME}", project->GetTitle());
  buffer.Replace("${PROJECT_DIR}", UnixFilename(project->GetBasePath()));
  buffer.Replace("${MAKEFILE}", UnixFilename(project->GetMakefile()));
-
+ buffer.Replace("${OUTPUT_EXECUTABLE}", UnixFilename(project->GetTargetType() == ttExecutable ? project->GetExecutableFilename() : ""));
  wxString files;
  for (int i = 0; i < project->GetFilesCount(); ++i)
  files << UnixFilename(project->GetFile(i)->relativeFilename) << " ";
@@ -131,6 +133,7 @@
  buffer.Replace("${PROJECT_DIR}", wxEmptyString);
  buffer.Replace("${MAKEFILE}", wxEmptyString);
  buffer.Replace("${ALL_PROJECT_FILES}", wxEmptyString);
+ buffer.Replace("${OUTPUT_EXECUTABLE}", UnixFilename(project->GetTargetType() == ttExecutable ? project->GetExecutableFilename() : ""));
  }
 
  EditorBase* editor = Manager::Get()->GetEditorManager()->GetActiveEditor();

--- End code ---

rickg22:
Why don't you send that to the patch requests after you test it?

I had submitted a RFE for exactly this feature and forgot it after a couple of months of waiting.

Urxae:
thomas, your patch seems to restrict this to executables. Why? In some cases it might be handy to pass other output filenames to tools (to pass .dll to strip, for example).

As an added bonus, the code to get it will be shorter and simpler:

--- Code: ---UnixFilename(project->GetOutputFilename())
--- End code ---
instead of

--- Code: ---UnixFilename(project->GetTargetType() == ttExecutable ? project->GetExecutableFilename() : "")
--- End code ---

If you change this, don't forget to change the macro name to something more general like $(OUTPUT_FILE).

Oh, and that last added line should probably have wxEmptyString instead of the above code fragment. Unless you like null-pointer dereferences, of course ;)

EDIT: used <> instead of [] :?

Navigation

[0] Message Index

[#] Next page

Go to full version