Author Topic: Howto get Workspace folder as Compiler variable  (Read 3906 times)

h4mb4l4ng

  • Guest
Howto get Workspace folder as Compiler variable
« on: June 26, 2007, 11:59:39 am »
Hi all,

Is there anyway to reference to workspace folder as a variable for compiler (e.g. MinGW GCC) ?  I've just imported a complex solution from VS2K5E with 3,4 projects having multiple-level of sub folders.  These projects reference to one another to compile.  In VS2KE, there is $(SolutionDir) variable, we need the same thing in C::B.  Also, cannot use absolute path because each developer can store the workspace in their own space and commit work to SVN.

Work around solution are also welcome :-).

Many many thanks for a nice IDE.

Cheers.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Howto get Workspace folder as Compiler variable
« Reply #1 on: June 26, 2007, 01:17:08 pm »
There is no such thing.

However, if you compile your Code::Blocks from source, you can add this feature rather easily.

Edit macrosmanager.cpp, insert at line 180:
wxFilename wsfn(Manager::Get()->GetProjectManager()->GetWorkspace()->GetFilename());
macros[_T("WORKSPACE")] = wsfn.GetFullPath();
macros[_T("WORKSPACE_PATH")] = wsfn.GetPath();


(untested)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

h4mb4l4ng

  • Guest
Re: Howto get Workspace folder as Compiler variable
« Reply #2 on: July 04, 2007, 06:59:58 am »
There is no such thing.

However, if you compile your Code::Blocks from source, you can add this feature rather easily.

Edit macrosmanager.cpp, insert at line 180:
wxFilename wsfn(Manager::Get()->GetProjectManager()->GetWorkspace()->GetFilename());
macros[_T("WORKSPACE")] = wsfn.GetFullPath();
macros[_T("WORKSPACE_PATH")] = wsfn.GetPath();


(untested)


Hmm, not a bad idea, but we can't public the source code to the world :).

It's much better if C::B can import output of external scripts/programs as environment variables.

Thanks anyway.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Howto get Workspace folder as Compiler variable
« Reply #3 on: July 04, 2007, 07:42:00 pm »
Quote
Hmm, not a bad idea, but we can't public the source code to the world
You don't need to do that, it is already public.
You can just checkout the sources, apply the change as pointed out above, and compile Code::Blocks.

Quote
It's much better if C::B can import output of external scripts/programs as environment variables.
What makes you think it can't? It's not what you originally asked for, though.

You may want to look into backticks, if you want to insert the output of external programs, or script variable expansion, if you want to run scripts during variable expansion.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."