Author Topic: Backticks in Windows Shell/Code::Blocks?  (Read 21220 times)

takeshimiya

  • Guest
Backticks in Windows Shell/Code::Blocks?
« on: January 16, 2006, 08:47:21 am »
Hi. I've been thinking, there is any way (either from Windows Shell or C::B side) to support backticks in C::B?

For example, I'm thinking of backticks in the Linker project section, calling something like `wx-config --libs`. In Bourne Shell (Linux) systems that's pretty common.

So, how could we use something like that, as `sdl-config.bat --cflags` in Windows?
The solution I'm thinking, is simulating support for backticks from the C::B side, as I don't think it will be possible from the Windows Shell side.

What do you think?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Backticks in Windows Shell/Code::Blocks?
« Reply #1 on: January 16, 2006, 08:59:43 am »
It would be possible to simulate this simply by invoking cmd and capturing stdout. Under Linux, you don't need to do anything, it is a shell feature anyway.

However, I don't think this is a good idea for several reasons, most importantly for this one:
Variable expansion may run many times.

Invoking a shell is a prohibitively expensive operation when it may happen many times, at all times. Also, backticks may have side effects (a script may actually write out some config to the disk, for example) which may not have to be executed many times. You are not in control of this, because variable expansion is done many times (for example when opening the compiler options dialog).
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Backticks in Windows Shell/Code::Blocks?
« Reply #2 on: January 16, 2006, 09:01:14 am »
That could be easily added.
But the point is what would you achieve? I mean, someone has to write this sdl-config.bat and it will not be universal, i.e. "take this batch file and you 're done"...
If you explain your thoughts about this, we might find some better way to do this (like using scripting for example).
Be patient!
This bug will be fixed soon...

takeshimiya

  • Guest
Re: Backticks in Windows Shell/Code::Blocks?
« Reply #3 on: January 16, 2006, 09:16:06 am »
Well, my main concern is to make cbp projects more or less the same for all platforms, thus alivianating the problem:

Sadly, you will have to create a cbp with wx-config and all that stuff.
It's a real pity that the projects files can't be multi-platform (when using any library other than STL).

However I've been thinking, and it seems there isn't any easy solution for that. The main problem is the configure (and the detection of library/include paths) stuff.

As you know, autofriends are not multiplatform (so in Windows they can be used only in a *nix like environment like msys/cygwin, which are very uncommon). But, they are very popular in linux land.

So in Windows:
Automake is currently perfectly replaced by C::B own build system.
Autoconf/Libtool is almost inexistant, but Global Variables can alivianate a bit the problem.

However, a tool I didn't knew, called pkg-config, which is pretty common in Linux land, and not-so-common on WIndows, but it works outside msys/cygwin. can really alivianate most of this.

Quoting:
Quote
pkg-config is a helper tool used when compiling applications and libraries. It helps you insert the correct compiler options on the command line so an application can use  gcc -o test test.c `pkg-config --libs --cflags glib-2.0`  for instance, rather than hard-coding values on where to find glib (or other libraries). It is language-agnostic, so it can be used for defining the location of documentation tools, for instance.

pkg-config works on multiple platforms: Linux and other UNIX-like operating systems, Mac OS X and Windows. It does not require anything but a reasonably well working C compiler and a C library

So, my current thoughts is something like mixing pkg-config with Global Variables. (Having values for Global Variables being read from pkg-config database perhaps).

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Backticks in Windows Shell/Code::Blocks?
« Reply #4 on: January 16, 2006, 09:23:08 am »
As you know, autofriends are not multiplatform (so in Windows they can be used only in a *nix like environment like msys/cygwin, which are very uncommon). But, they are very popular in linux land.
Luckily, we have somebody working on autotools import now, so that will solve that issue. :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

takeshimiya

  • Guest
Re: Backticks in Windows Shell/Code::Blocks?
« Reply #5 on: January 16, 2006, 09:30:14 am »
Yes, that issue (really? who? :D nice to hear).

But my main concern still remains, for projects written from scratch (without any use of autotools), what I'm saying is still valid (pkg-config is not autotools, and can be used).

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Backticks in Windows Shell/Code::Blocks?
« Reply #6 on: January 16, 2006, 09:38:35 am »
really? who? :D nice to hear
You.

So I'm thinking if we can do a simple "configure"-like system [...]

Ok, I wanted to know if the idea was welcomed or not, so I could think next.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

takeshimiya

  • Guest
Re: Backticks in Windows Shell/Code::Blocks?
« Reply #7 on: January 16, 2006, 10:05:13 am »
Well, I'm trying to attack the current problem of "cbp projects are very different from linux to windows".

I'm yet not convinced by any existant or not existant solution, so there isn't any final word.

Anyways I (researched) more, and maybe pkg-config could suffice, for now (moreover it's standard on linux).

Just a side note: simple "configure"-like system idea is very very far away from autotools import idea.

So, any thoughts on what I'm talking on #3?
« Last Edit: January 16, 2006, 10:07:35 am by Takeshi Miya »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Backticks in Windows Shell/Code::Blocks?
« Reply #8 on: January 16, 2006, 10:43:15 am »
Just a side note: simple "configure"-like system idea is very very far away from autotools import idea.
Well, in the other thread (out of which I only quoted two lines), you were referring to "Any project that uses a configure script in linux (SDL, GTK, wx, QT,  etc), and even personal projects" and "the concept "./configure" in Windows".
This pretty much sounded like "autotools import" to me. Personally, I was amazed then, and I still am, because I don't have even the faintest idea how one could implement such a thing.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

takeshimiya

  • Guest
Re: Backticks in Windows Shell/Code::Blocks?
« Reply #9 on: January 16, 2006, 10:58:05 am »
This pretty much sounded like "autotools import" to me.

Sorry for the confusion, to clear it up: "./configure" != simple "./configure-like".

Personally, I was amazed then, and I still am, because I don't have even the faintest idea how one could implement such a thing.
lol, neither I do. Parsing m4 in heavy cryptic 700KB configure scripts is something that we never live enough to see, probably. :lol:

Now that that is clear (I have to learn english), what about pkg-config ~ global variables interaction ?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Backticks in Windows Shell/Code::Blocks?
« Reply #10 on: January 16, 2006, 11:01:47 am »
If it does not break anything, sure.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

takeshimiya

  • Guest
Re: Backticks in Windows Shell/Code::Blocks?
« Reply #11 on: January 16, 2006, 11:19:55 am »
I'm asking because I'm kind of lost. My 2nd approach was to use `pkg-config --libs` kind of things in Windows. That's why I asked first if backticks was feasible.

If it's not feasible, or another (better) approach can be used (trough global/compiler/project variables, or any other kind), great.
But yet, something like support for backticks will be more user-friendly to users coming from other *nix IDEs (KDevelop/Anjuta/etc), wanting to use his/her cbp in windows.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Backticks in Windows Shell/Code::Blocks?
« Reply #12 on: January 16, 2006, 12:02:43 pm »
Well you see, backticks are possible (and not hard to implement). But the problem is that they may get executed many times (at least once while the project is loaded and at least twice per build, and every time you open the build options dialog).

You would not want to wait for 20 seconds each time when opening a project or when changing build options just because someone had the brilliant idea to put very-complex-script into backticks, would you? Likewise, you would not want modify-and-delete-files-script to run every time you open a dialog.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Backticks in Windows Shell/Code::Blocks?
« Reply #13 on: January 16, 2006, 12:25:14 pm »
Here you go. Revision 1766.
Let us know of your progress :)
Be patient!
This bug will be fixed soon...

takeshimiya

  • Guest
Re: Backticks in Windows Shell/Code::Blocks?
« Reply #14 on: January 16, 2006, 12:35:42 pm »
lol, I'm on Ubuntu 64 from 5 days ago (yes, I finally could get it working on this pc -note: never buy a motherboard with an ati chipset-), and not rebooted the pc in Windows from that day. :)

I couldn't compile C::B on it yet (lot's of AngelScript errors, and it isn't #ifdef'ed...).

Now I'll reboot to that thing called Windows.
I'm going to check out if it's still alive :P