Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Batch build - optionally not show BatchLogWin dialog

(1/2) > >>

AndrewCot:
I have started to work on modifying the code to not show the BatchLogWindow dialog (only) when running in batch mode if you add "--batch-headless-build" option to the command line.

I could not find if anyone has worked on doing this in the past, but I may have used the wrong keywords or missed a post in the forum. Has anyone worked on this before? If you did can you point me at your changes and if possible let me know why it did not make it into the C::B svn repo?

I have C::B not running headless, but when running headless both the app and debug logs are sent to the console. This will change as I need to add support for the following when running in the headless mode:
   "no-log"
   "log-to-file"
   "debug-log"
   "debug-log-to-file"

I am not proposing at this point in time stopping the global variable GUI dialog from pop up due to missing variables.

BlueHazzard:
> I am not proposing at this point in time stopping the global variable GUI dialog from pop up due to missing variables.
i work on this

> I have started to work on modifying the code to not show the BatchLogWindow dialog (only) when running in batch mode if you add "--batch-headless-build" option to the command line.
isn't this possible already?

AndrewCot:
>> I am not proposing at this point in time stopping the global variable GUI dialog from pop up due to missing variables.
>i work on this
This is why I am not going to work on it.

>> I have started to work on modifying the code to not show the BatchLogWindow dialog (only) when running in batch mode if you add "--batch-headless-build" option to the command line.
>isn't this possible already?
Not that I could find or see in the code. Some things to check out are (there are more, but these show the main issues/problem areas):
   * main.cpp search for "MainFrame::SetupGUILogging" and have a look at it as it has GUI code
   * app.cpp - search for "TextCtrlLogger"  - cannot use TextCtrlLogger if there is no GUI...
   * compilergcc.cpp check out the "CompilerGCC::OnAttach()" function and the first call to Manager::Get()->ProcessEvent(...) should not be called when running headless.



I got a bit ahead of myself in that I have it working for the minimal C::B build, but it is failing when I build everything as I think some of the plugins have code that uses/creates something related to the GUI and therefore I get a silent failure and I need to do some more changes in one or more of the plugins to stop it/them using a GUI when running headless once I find the plugs I need to modify.

BlueHazzard:
I would like to think about a strategy to remove the  UI dependent code.

Obfuscated used a

--- Code: ---BaseClass -
          |- UI Class
          |- Non UI Class

--- End code ---
way, and i quite like it, but later he said it is to complicated...
How do you think you want to remove ui code? Simply with

--- Code: ---if(!BatchBuild)
   show message box
else
   log to console

--- End code ---
or some other way?

AndrewCot:
It gets a bit more complex as the more I understand it the more things have to be taken care of.

My current thinking is below at a high level, which has changed a few times as I find things and get more familiar with the code in the area that needs mods or I have looked at.


--- Code: ---if(!IsBatchBuild)
   show C::B normal IDE
else
{
    if(IsHeadlessBuild)
   {
     log to console or log to file
   }
   else
      show batch build dialog
}
--- End code ---

NOTE: for a Headless build then both IsBatchBuild & IsHeadlessBuild are true.



The change to remove the GUI is painless and relatively easy, but other parts of the code need to be modded to not try and use the GUI. The following is my WIP SetupGUILogging() in main.cpp to that removed the GUI. The main change was to add another if check in the else code ("if (!Manager::IsHeadlessBuild())"). The call to m_pInfoPane->SetDropTarget(...) now has protection around is m_pInfoPane does not exist in a headless build.


--- Code: ---void MainFrame::SetupGUILogging(int uiSize16)
{
    // allow new docked windows to use be 3/4 of the available space, the default (0.3) is sometimes too small, especially for "Logs & others"
    m_LayoutManager.SetDockSizeConstraint(0.75,0.75);

    int bottomH = Manager::Get()->GetConfigManager(_T("app"))->ReadInt(_T("/main_frame/layout/bottom_block_height"), 150);
    wxSize clientsize = GetClientSize();

    LogManager* mgr = Manager::Get()->GetLogManager();
    Manager::Get()->SetImageSize(uiSize16, Manager::UIComponent::InfoPaneNotebooks);
    Manager::Get()->SetUIScaleFactor(cbGetContentScaleFactor(*this),
                                     Manager::UIComponent::InfoPaneNotebooks);

    if (!Manager::IsBatchBuild())
    {
        m_pInfoPane = new InfoPane(this);
        m_LayoutManager.AddPane(m_pInfoPane, wxAuiPaneInfo().
                                  Name(wxT("MessagesPane")).Caption(_("Logs & others")).
                                  BestSize(wxSize(clientsize.GetWidth(), bottomH)).//MinSize(wxSize(50,50)).
                                  Bottom());

        wxWindow* log;

        for (size_t i = LogManager::app_log; i < LogManager::max_logs; ++i)
        {
            if ((log = mgr->Slot(i).GetLogger()->CreateControl(m_pInfoPane)))
                m_pInfoPane->AddLogger(mgr->Slot(i).GetLogger(), log, mgr->Slot(i).title, mgr->Slot(i).icon);
        }

        m_findReplace.CreateSearchLog();
    }
    else
    {
        if (!Manager::IsHeadlessBuild())
        {
            m_pBatchBuildDialog = new BatchLogWindow(this, _("Code::Blocks - Batch build"));
            wxSizer* s = new wxBoxSizer(wxVERTICAL);
            m_pInfoPane = new InfoPane(m_pBatchBuildDialog);
            s->Add(m_pInfoPane, 1, wxEXPAND);
            m_pBatchBuildDialog->SetSizer(s);

            // setting &g_null_log causes the app to crash on exit for some reason...
            mgr->SetLog(new NullLogger, LogManager::app_log);
            mgr->SetLog(new NullLogger, LogManager::debug_log);
        }
    }

    mgr->NotifyUpdate();
    if (m_pInfoPane)
        m_pInfoPane->SetDropTarget(new cbFileDropTarget(this));
}

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version