Author Topic: commandline build with no gui  (Read 39256 times)

devd

  • Guest
commandline build with no gui
« on: December 09, 2008, 12:29:39 pm »
Im using putty on a remote ubuntu box. I work on a project which is using codeblocks project/workspace files.

Im trying to get codeblocks to work in console mode, is there a way not to display the gui build-log window ? So it will
compile on a machine without x-windows ?

so far this is what I get :
codeblocks --rebuild --target="Debug" test.workspace --no-splash-screen

Regards 

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: commandline build with no gui
« Reply #1 on: December 09, 2008, 12:43:51 pm »
No.

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: commandline build with no gui
« Reply #2 on: December 10, 2008, 11:49:01 pm »
This would in fact be extremely useful if it worked.

In the past I used to use Visual Studio with large workspaces/many projects with interdependencies. We always did the nightly build as command line builds without IDE GUI, using the workspace file. Something similar would be nice with Code::Blocks in my opinion.... as Code::Blocks is now my preferred IDE   :D

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: commandline build with no gui
« Reply #3 on: December 11, 2008, 12:27:57 pm »
It won't work in the foreseeable future, though. The application uses wxWidgets components which depend on other components that require the whole GUI stuff. While it is theoretically possible to build wxWidgets without GUI, it is not possible to build Code::Blocks with such a build.
I remember we tried (maybe 2 years ago) to implement a console-only mode with normal wxWidgets linkage that simply didn't create any windows, hoping it might just work. However, this was not successful. I forgot the actual reason why it didn't work, but the complications were of such nature that we dropped the idea entirely.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: commandline build with no gui
« Reply #4 on: December 11, 2008, 06:50:04 pm »
It won't work in the foreseeable future, though. The application uses wxWidgets components which depend on other components that require the whole GUI stuff. While it is theoretically possible to build wxWidgets without GUI, it is not possible to build Code::Blocks with such a build.
I remember we tried (maybe 2 years ago) to implement a console-only mode with normal wxWidgets linkage that simply didn't create any windows, hoping it might just work. However, this was not successful. I forgot the actual reason why it didn't work, but the complications were of such nature that we dropped the idea entirely.

I realise the original poster asked for a build without GUI, and I appreciate that it may not be easy to do.

However, there are situations such as this where it would be desirable to run C::B as if it was a console application, even though it is obviously a full-blown GUI application. I just did a small experiment using a wxWidgets dialog based GUI app, to see if I could make it behave like a console application when command line parameters were provided, and I could do it quite easily. I realise the code below is Windows only, but I imagine it wouldn't be impossible to do the same thing on Linux?

Code
#include "DateTimeApp.h"

//(*AppHeaders
#include "DateTimeMain.h"
#include <wx/image.h>
//*)

#include <iostream>
#include <fstream>
using namespace std;

IMPLEMENT_APP(DateTimeApp);

bool DateTimeApp::OnInit()
{
   bool wxsOK = true;
   if(wxApp::argc > 1) {

      // If command line arguments are given, we run as if we are in console mode
      // Example is MSW specific

      AttachConsole(ATTACH_PARENT_PROCESS);  // <== MS WINDOWS API CALL
      ifstream conin("con"); //input/output to the console
      ofstream conout("con");
      cout.rdbuf(conout.rdbuf()); //attach standard stream objects to console
      cerr.rdbuf(conout.rdbuf()); //(if you don't use cerr and clog you can of course leave them out)
      clog.rdbuf(conout.rdbuf());
      cin.rdbuf(conin.rdbuf());

      //now you can use regular cout/cin I/O as if in a console
      std::cout << "Hello GUI World" << std::endl;

      FreeConsole(); // <== MS WINDOWS API CALL
      wxsOK = false;
   }
   else {

       //(*AppInitialize
       wxInitAllImageHandlers();
       if ( wxsOK )
       {
         DateTimeDialog Dlg(0);
         SetTopWindow(&Dlg);
         Dlg.ShowModal();
         wxsOK = false;
       }
   }

   //*)
   return wxsOK;

}

So what you have above, is a small example of a wxWidgets GUI application that behaves as a GUI application when no command line parameters are present, and as a console application when command line parameters are present. Obviously, it could be made to react to a certain command line parameter for console mode use.

So a suggestion might be to consider this technique for the standard C::B GUI build, so that we could build workspaces from the command line without starting the GUI.

Again, I realise this may be slightly different that what the OP asked for, but anyway.

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: commandline build with no gui
« Reply #5 on: December 17, 2008, 07:43:55 pm »
I've been doing experiments with my video editing project, and I've found a successful way to make an app which does not actually start up the wxWidgets GUI.

http://svn.berlios.de/svnroot/repos/saya/trunk/src/ui/app.cpp
http://svn.berlios.de/svnroot/repos/saya/trunk/src/main.cpp

The trick is using the unpopular wxEntryStart and wxEntryCleanup() functions (of course, if you don't have a wxApp, you won't be able to rely on the wxWidgets event handling, which is the tricky part). Once you make an application object that is not a subclass of wxApplication, everything is smooth.

I've also been successful at making an independent but wxWidgets compatible string
(see http://svn.berlios.de/svnroot/repos/saya/trunk/src/saya/core/systring.h and
http://svn.berlios.de/svnroot/repos/saya/trunk/src/saya/core/systring.cpp ). This was because I was asked to port the application to QT, so I'm making a combination of replacement / wrapper classes in the ui directory. This has given me A LOT of control over my application's features.

Just in case you wanted to start working on the "commandline codeblocks" project again.

steedhorse

  • Guest
Re: commandline build with no gui
« Reply #6 on: December 22, 2008, 07:12:41 am »
In my opinion, although it might be hard to implement, it is a very important feature that we can build project or workspace from raw character console device.
Otherwise, we often have to use other tools, such as automake to set up another set of configurations to be used in daily build server.
But I have get used to get everything done in C::B: define projects dependencies, define and use variables, set up pre-build and post-build steps, configure include and lib paths....... It's a misery to repeats all these using automake.:-(

If the using of wx of current C::B makes it hard to accomplish this, I think at least we can set up another separated small sub-project, using no wxWidget stuffs, just a console app that parse .cbp or .workspace files, extracting all configurations, and then do what should be done accordingly.
I really need this feature.:(

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: commandline build with no gui
« Reply #7 on: December 23, 2008, 12:47:36 am »
If the using of wx of current C::B makes it hard to accomplish this, I think at least we can set up another separated small sub-project, using no wxWidget stuffs, just a console app that parse .cbp or .workspace files, extracting all configurations, and then do what should be done accordingly.
I really need this feature.:(

I was just wondering what plug-ins do you think should be able to work with an command-line only Code::Blocks?
Compiler is needed, but the others are questionable.

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline grischka

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: commandline build with no gui
« Reply #8 on: December 23, 2008, 02:42:24 am »
I've once made a small commandline tool ("cbp2mak") that converts codeblocks projectfiles (.cbp) and workspace files (.workspace) to makefiles for mingw.

It's probably far from being complete but it works for the codeblocks project itself.  It's only tested with mingw, porting it might need some work.

Anyway, code is attached. See readme.txt for details.

Regards


[attachment deleted by admin]
« Last Edit: December 23, 2008, 03:25:43 am by grischka »

kgb98egr

  • Guest
Re: commandline build with no gui
« Reply #9 on: February 03, 2009, 07:53:41 pm »
grischka,

I am new to codeblocks and am trying to use it as the IDE for our developers who work on code that has automatic nightly builds.  Your tool cbp2mak could be useful.  Could I get a copy of your code and readme.txt?

In your last post you say code is attached, but I don't see how to get it.

Thanks

Offline grischka

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: commandline build with no gui
« Reply #10 on: February 03, 2009, 09:01:35 pm »
Log in to see it.

More recent version: http://bblean.berlios.de/cbp2mak-0.2.zip
« Last Edit: February 03, 2009, 10:30:08 pm by grischka »

zabzonk

  • Guest
Re: commandline build with no gui
« Reply #11 on: March 01, 2009, 01:00:11 am »
Forget this - to tired when I wrote it
« Last Edit: March 01, 2009, 11:31:29 am by zabzonk »

Offline zack8686

  • Single posting newcomer
  • *
  • Posts: 5
Re: commandline build with no gui
« Reply #12 on: March 19, 2009, 12:18:37 pm »
Where can I get "DateTimeMain.h" ?   
And where can I download your headers as well as others ?

Feel free to visit my new programming forum :
-http://www.z-techprogramming.proboards.com/index.cgi




-Thanks-
« Last Edit: March 19, 2009, 12:24:31 pm by zack8686 »