News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

New scripts through plugin installation

Started by yop, August 05, 2007, 01:15:07 PM

Previous topic - Next topic

yop

I 'm going to need a few scripts installed with my plugin:

  • A new project template
  • A new target template
  • Some new debugger stuff (understanding of QString much like wxString is already implemented)

My questions are:

  • How can these be available to the user after the plugin installation?
  • How can I set the "Make commands" and the "Using Make" attributes of the project using the project and target creation scripts?
  • How can I set "Extended" (you know the ones provided by the plugins) attributes of the project using the project creation scripts?

Life would be so much easier if we could just look at the source code.

mandrav

QuoteHow can these be available to the user after the plugin installation?
Read this.


QuoteHow can I set the "Make commands" and the "Using Make" attributes of the project using the project and target creation scripts?
Use the script counterparts of CompileTargetBase::GetMakeCommandFor and CompileTargetBase::SetMakeCommandFor (they are basically the same both in C++ and scripts).


QuoteHow can I set "Extended" (you know the ones provided by the plugins) attributes of the project using the project creation scripts?
You can't. Not by scripts. These are plugin-specific sections and no generic script interface is provided for it. What are you interested in?
Be patient!
This bug will be fixed soon...

yop

#2
Quote from: mandrav on August 05, 2007, 05:55:56 PM
Read this.

So I can have relative paths in the manifest.xml and drop them to wherever the project generation scripts are right? For the debugger I don't have to touch the original script but provide a new one and it will automagically be used? (Haven't searched the last one enough yet)

Quote from: mandrav on August 05, 2007, 05:55:56 PM
Use the script counterparts of CompileTargetBase::GetMakeCommandFor and CompileTargetBase::SetMakeCommandFor (they are basically the same both in C++ and scripts).

Clear enough

Quote from: mandrav on August 05, 2007, 05:55:56 PM
You can't. Not by scripts. These are plugin-specific sections and no generic script interface is provided for it. What are you interested in?

I did see this coming... Let me explain where QtWorkbench is going. You have a typical C::B project and then the user can request that it will use QtWorkbench in the build process (there is a dialog for doing so in the Project Properties). The choice of the user is written in the project file (remember this thread?). Now when the user requests a build I catch the build started event and run qmake to generate the Makefiles and then leave C::B alone to handle the rest of the build process (using custom Makefile and some specific build commands). The whole process from the user perspective has become really transparent he just has to press "Build" and everything happens automagically (just like I always had in mind for the plugin). As you can tell from the rest of my questions there are some prerequisites for using the plugin:

  • The user must select a custom Makefile build - OK, we got this covered
  • The user must change the "make" commands - also covered
  • The user must select that he will use QtWorkbench - :-(

To provide a project creation wizard I 'm going to need to set all three of the above attributes of the project. The first two are native, the third is an "Extended" attribute.

Oh and a sidenote for possible current QtWorkbench users that don't see the above features in the current implementation (0.5.x). These are mostly new features I 'm talking about that are in the plugin svn and will be available in future releases.
Life would be so much easier if we could just look at the source code.

mandrav

#3
You have to excuse me but I haven't used your plugin (qt programming doesn't interest me :)). Obviously I am missing something.

QuoteThe first two are native, the third is an "Extended" attribute.

The <Extensions> node in the project file provides a way for plugins to store per-project attributes that are only of interest to the specific plugin.
From what I have understood, you want your plugin to know that a specific project should be "treated" by it. This is a property of your plugin and it shouldn't matter (at runtime) whether it is written inside the <Extensions> node or not. This xml node is useful only when loading a project so your plugin can see that it should "handle" this project in a special way (or whatever it is your plugin is doing).

As I said, I might have not understood the problem completely so feel free to explain more :).

Anyway, if you prove that reading/writing the <Extensions> node at runtime (i.e. outside project loading/saving scope) is needed/useful, it should be pretty easy to expose such functionality. For a few revisions now this node is being kept in memory throughout the project's lifetime so all it would take is expose it through the SDK API.
Be patient!
This bug will be fixed soon...

yop

Quote from: mandrav on August 06, 2007, 10:35:27 AM
The <Extensions> node in the project file provides a way for plugins to store per-project attributes that are only of interest to the specific plugin.
From what I have understood, you want your plugin to know that a specific project should be "treated" by it. This is a property of your plugin and it shouldn't matter (at runtime) whether it is written inside the <Extensions> node or not. This xml node is useful only when loading a project so your plugin can see that it should "handle" this project in a special way (or whatever it is your plugin is doing).

You got everything right and what you describe is exactly what I do.

Quote from: mandrav on August 06, 2007, 10:35:27 AM
Anyway, if you prove that reading/writing the <Extensions> node at runtime (i.e. outside project loading/saving scope) is needed/useful, it should be pretty easy to expose such functionality. For a few revisions now this node is being kept in memory throughout the project's lifetime so all it would take is expose it through the SDK API.

What I need is a way to write that xml node from a project creation wizard, I don't actually know what this will mean internally. This project creation wizard will prepare projects that are "handled" by my plugin and I need a way to set the property that tells my plugin when the respective project opens to actually handle it.
Life would be so much easier if we could just look at the source code.

mandrav

Quote from: yop on August 06, 2007, 01:06:14 PM
What I need is a way to write that xml node from a project creation wizard, I don't actually know what this will mean internally. This project creation wizard will prepare projects that are "handled" by my plugin and I need a way to set the property that tells my plugin when the respective project opens to actually handle it.

OK, now I get what you want :).
Let me think about it for a while and get back to you.
Be patient!
This bug will be fixed soon...

mandrav

Update your C::B working copy and look for cbProject::AddToExtensions() [documented].
You should use it inside your script's SetupProject(theproject)...
Be patient!
This bug will be fixed soon...

yop

I can't get it to work  :(
In the script I have

project.AddToExtensions(_T("qtworkbench/+enabled:value=true"));

and I get in the cbp file

<qtworkbench>
<enabled value="false" />
</qtworkbench>

then I changed in the script to set a different attribute (just for testing) and I got the exact same results:

project.AddToExtensions(_T("qtworkbench/+enabled:price=1"));

output:

<qtworkbench>
<enabled value="false" />
</qtworkbench>


It seems that always the same attribute (named "value") gets set with "false"
Life would be so much easier if we could just look at the source code.

mandrav

Quote from: yop on October 03, 2007, 12:55:41 AM
I can't get it to work  :(
...
It seems that always the same attribute (named "value") gets set with "false"

Works For Me (tm) ;)
Seriously, I just tried it and it worked fine. Have a look at the code if you want. It's in cbproject.cpp, line 1978. You will see that there is no hardcoded "value" or "false" there (why would there be?).
My guess is that the script you 're editing is NOT the one actually ran by the wizard. Are you sure you 're editing the correct script?
Be patient!
This bug will be fixed soon...

yop

#9
I 'll check again, probably I did something wrong. The strange thing is that I never AFAIR set this thing to false either editing the correct script or not. Where on earth could it get it? Anyway I 'll check again...

As a side note many congratulations on the scripting facilities. They are impresive :-)
You know what comes next don't you? I 'll ask for adding new project wizards automatically ;-)
Life would be so much easier if we could just look at the source code.

mandrav

Quote from: yop on October 03, 2007, 01:05:01 PM
You know what comes next don't you? I 'll ask for adding new project wizards automatically ;-)

Hehe, I saw this one coming ;).
Be patient!
This bug will be fixed soon...

mandrav

@yop:

btw, have you seen this?. Maybe it could be of help for QT's moc/uic tools?
Be patient!
This bug will be fixed soon...

yop

Yeap I 've seen it (since I picked up on my plugin again I 'm watching the project closely ;)) and it sure can work. I am trying to find some time to check how it would work for Qt (moc has to be run on the project header files and uic in the ui (designer) files) and post it on the wiki. But still using the plugin will be easier to set the whole thing up and will feel closer to what Qt devs have learned to expect and use when setting up Qt projects (my ui ideas come from existing projects for Qt support like the eclipse integration, KDevelop etc). I can cover the whole Qt support either way, my issue is that I don't have that much time to work on it (I 'm trying though)
Life would be so much easier if we could just look at the source code.

yop

OK it was my fault, I regenerated the node in the plugin's registered hook for project loading, the script had nothing to do with it. I have a strange behavior though as it seems that the hook doesn't get called on the first project startup (or the "extended" project properties are not taken into account) right after the wizard has ended. If I reopen the project then everything is as expected. I 'll investigate a bit further.
Life would be so much easier if we could just look at the source code.

yop

I 'm on to something. I have this hooked to the project load/unload:

void QtWorkbench::OnProjectLoadingHook(cbProject* project, TiXmlElement* elem, bool loading)

Now when the new project wizard finishes this function get called 3 times and each time it gets called with loading = false  :?. This is why I had the strange behavior all the way. When the project gets loaded the plugin checks if it should handle the project and then when the project closes it writes back (depending on the user requests) if it should handle the specific project. Now since the loading never gets the true value my plugin doesn't get the state that it should handle the project and during the project closing it always writes the false value in the project file. What I would expect:

Wizard finishes -> hook gets called with loading = true and nothing else, just resume the typical handling of an open project.
Life would be so much easier if we could just look at the source code.