Author Topic: a Qt plugin : QtPregenForCB => AddOnForQt  (Read 130016 times)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: a new plugin : QtPregenForCB
« Reply #15 on: February 13, 2015, 09:40:22 am »
Sorry, have no time to do it...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: a new plugin : QtPregenForCB
« Reply #16 on: February 14, 2015, 11:18:01 pm »
Sorry, have no time to do it...
So you had no time but I had. Indeed, it works. I think you are wrong on that topic. And reverting a commit without proof that is does NOT work is not nice you know...  :(
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: a new plugin : QtPregenForCB
« Reply #17 on: February 14, 2015, 11:41:31 pm »
Morten:
I've not reverted it because it doesn't work, but because it is bad design (this is a personal opinion/vision).
I would have reverted it even if I've tried it and it has worked.
Obviously we need to implement this feature as a new event that is fired at the correct time and it doesn't depend on a state variable.

p.s. Can you reason about why it works? How on earth the plugin matches correctly the id of the context menu items, when it has never requested them?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: a new plugin : QtPregenForCB
« Reply #18 on: February 15, 2015, 09:04:54 am »
@MortenMacFly
Thank you for taking the time to test this plugin.
Is it possible to use the 'Build log' to display messages generated by the pre-generate ?
This would be more consistent than display them in 'Code::Blocks log'.

@oBFusCATed
Quote
when it has never requested them
See 2-

1- It retrieves the ids menus created by the plugin 'CompilerGcc' by :
Code
void QtPregen::BuildMenu(wxMenuBar* menuBar)
{
if (!IsAttached())
        return;

int pos = menuBar->FindMenu(_("Build"));
if (pos !=-1) {
wxMenu * builder = menuBar->GetMenu(pos);
m_IdBuild = builder->FindItem(_("Build"));
m_IdCompile = builder->FindItem(_("Compile current file"));
m_IdRun = builder->FindItem(_("Run"));
m_IdBuildRun = builder->FindItem(_("Build and run"));
m_IdRebuild = builder->FindItem(_("Rebuild"));
m_IdClean = builder->FindItem(_("Clean"));
}
}

2- It retrieves the ids context menus created by the plugin 'CompilerGcc' by :
Code
void QtPregen::BuildModuleMenu(const ModuleType type, wxMenu* menu, const FileTreeData* data)
{
if (!IsAttached())
        return;

// we 're only interested in m_project manager's menus
    if (!menu || type != mtProjectManager)
        return;

// right click on item menu ...else -> 0
    if (data) {
    FileTreeData::FileTreeDataKind typedata  = data->GetKind();
    // ... click project
bool preproject = typedata == FileTreeData::ftdkProject  ;
// ... click file
bool prefile = typedata == FileTreeData::ftdkFile ;

if (preproject)  {
// popup menu on a project
m_IdpClean  = menu->FindItem(_("Clean"));
m_IdpBuild  = menu->FindItem(_("Build"));
m_IdpRebuild  = menu->FindItem(_("Rebuild"));
}
else
if (prefile) {
// popup menu on a file
m_IdfBuild  = menu->FindItem(_("Build file"));
m_IdfClean  = menu->FindItem(_("Clean file"));
}
      }
}

3- Id are used to select the treatment  in :
Code
void QtPregen::OnPrebuild(CodeBlocksEvent& event) 
{
      int eventId = event.GetId();
      ....
}
Note that from one session to another, id's remain the same!
While compiling a new version of svn 'Code::Block'.

Quote
Obviously we need to implement this feature as a new event that is fired at the correct time and it doesn't depend on a state variable.

Well, how so ?
« Last Edit: February 15, 2015, 09:57:50 am by LETARTARE »
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: a new plugin : QtPregenForCB
« Reply #19 on: February 15, 2015, 10:42:33 am »
Hello,
- new 'QtPregenForCB-0.2.4'
- all private variables are prefixed with 'm_',
- improved user dialogs on error Qt utilities
Best regards
« Last Edit: February 15, 2015, 11:00:01 am by LETARTARE »
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: a new plugin : QtPregenForCB
« Reply #20 on: February 15, 2015, 11:29:03 am »
2- It retrieves the ids context menus created by the plugin 'CompilerGcc' by :
Code
void QtPregen::BuildModuleMenu(const ModuleType type, wxMenu* menu, const FileTreeData* data)
{
if (!IsAttached())
        return;

// we 're only interested in m_project manager's menus
    if (!menu || type != mtProjectManager)
        return;

// right click on item menu ...else -> 0
    if (data) {
    FileTreeData::FileTreeDataKind typedata  = data->GetKind();
    // ... click project
bool preproject = typedata == FileTreeData::ftdkProject  ;
// ... click file
bool prefile = typedata == FileTreeData::ftdkFile ;

if (preproject)  {
// popup menu on a project
m_IdpClean  = menu->FindItem(_("Clean"));
m_IdpBuild  = menu->FindItem(_("Build"));
m_IdpRebuild  = menu->FindItem(_("Rebuild"));
}
else
if (prefile) {
// popup menu on a file
m_IdfBuild  = menu->FindItem(_("Build file"));
m_IdfClean  = menu->FindItem(_("Clean file"));
}
      }
}
What  a really clever hack. I'm stunned!


Quote
Obviously we need to implement this feature as a new event that is fired at the correct time and it doesn't depend on a state variable.

Well, how so ?
1. Create new event or even two events. One for starting and one for finishing.
2. Make an enum with all the possible types of actions you're interested in
3. Inspect the switch in CompilerGCC::BuildStateManagement and in every interesting case statement fire the appropriate event.
4. Test if all this is reliable... And doesn't slow the build process.
5. Probably it will be good if these events can be used to cancel the build process.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: a new plugin : QtPregenForCB
« Reply #21 on: February 15, 2015, 11:40:32 am »
Is it possible to use the 'Build log' to display messages generated by the pre-generate ?
This would be more consistent than display them in 'Code::Blocks log'.
I don't think there is a way.
Loggers have no name or id, so you cannot query them to obtain the index.
Only the one that has created them knows their index and can use them.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: a new plugin : QtPregenForCB
« Reply #22 on: February 15, 2015, 02:57:53 pm »
@oBFusCATed
Quote
What  a really clever hack. I'm stunned!
Sir, is it a mockery or not ?
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: a new plugin : QtPregenForCB
« Reply #23 on: February 15, 2015, 05:04:21 pm »
Hm. I don't think it is a mockery. I'm just amazed what you've done to solve your problem.  8)

p.s. Keep in mind that English is not my native language, so I may use the inappropriate words at times.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: a new plugin : QtPregenForCB
« Reply #24 on: February 15, 2015, 05:23:05 pm »
Hello,
I would rather. I also use 'Google Translation' and that's why I asked for you. It's over.

Quote
3. Inspect the switch in CompilerGCC::BuildStateManagement and in every interesting case statement fire the appropriate event.
I do not know what to do ?
Regards
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: a new plugin : QtPregenForCB
« Reply #25 on: February 15, 2015, 07:57:31 pm »
This is how you send and event:
Code
        CodeBlocksEvent evt(<event type>, <parameters>);
        Manager::Get()->ProcessEvent(evt);

And you have to create one or more new events.
To see how to do it inspect the sdk_events.h/cpp files to see how the other events are declared/defined.
Copy/paste/modify the code until it fits you needs and post a patch.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: a new plugin : QtPregenForCB
« Reply #26 on: February 21, 2015, 07:15:25 pm »
Hello,
- new 'QtPregenForCB-0.4.2'
- it uses a new organization for use of two new events:
Quote
'cbEVT_PRECOMPILER_STARTED' and
'cbEVT_PRECOMPILE_FILE'
I adapted 'CompilerGCC' to have a state machine with a state of more
Quote
bsTargetPreGen
see
Code
'CompilerGCC::GetNextStateBasedOnJob()' and 'CompilerGCC::BuildStateManagement()'

I provide a patch to svn 10118, see to :
https://github.com/LETARTARE/QtPregenForCB

Best regards
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: a new plugin : QtPregenForCB
« Reply #27 on: February 21, 2015, 07:56:27 pm »
I hope you know that in the c++ world precompile and precompiled mean totally different things. So if these features stay, then you'll need to find better names.  Probably use a name similar to already use names like xxxxPreBuild.

Have you tried the solution I've proposed? What are its problems? Because the propose solution looks way more complex than it needs to be.

p.s. This struct "struct s_rebuild { bool workspace, clean, build; } ;" should be made public, if the code stays the same.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: a new plugin : QtPregenForCB
« Reply #28 on: February 21, 2015, 08:16:42 pm »
Thank you for watching.
I suspected that the names will be to adapt. No problem, I look...
I used what you recommended, but to treat all cases, I arrived at this solution.
I can have a workspace with very different projects (Compilers, libraries ...), and it works.
I can use context menus('Build file', ...).

Quote
This struct "struct s_rebuild { bool workspace, clean, build; } ;" should be made public, if the code stays the same.
Of course, but I do not know where ?
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: a new plugin : QtPregenForCB
« Reply #29 on: February 21, 2015, 08:52:37 pm »
I used what you recommended, but to treat all cases, I arrived at this solution.
What cases are not handled by my solution?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]