New IAnjutaBuilder and IAnjutaBuildEnvironment interface

View: New views
1 Messages — Rating Filter:   Alert me  

New IAnjutaBuilder and IAnjutaBuildEnvironment interface

by Sébastien Granjoux :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

Here is a proposal for a new IAnjutaBuilder and IAnjutaBuildEnvironment
interface. Those two interfaces are planned to replace the current
IAnjutaBuildable.

IAnjutaBuilder allows to build a target.

I have removed the following:
- configure, generate:
I think 2 functions are not needed here and are confusing for the user,
and it's true in the build menu item too. I even don't really know
myself what is the difference between configure and generate. I see the
use of a configure function though allowing to create a new build
environment. But I don't know if it's useful to add it in the
IAnjutaBuilder interface.
- clean, install:
These functions are useful in the build plugin, but like configure I
don't really see a situation where another plugin need them, so I have
removed them for the moment. If you think they are useful, I will add them.
- execute:
I have moved this in the new run plugin. I don't think another plugin
need it too so there is no IAnjutaRun interface currently.
- get_command, reset_command, set_command:
I have moved this in the new IAnjutaBuildEnvironment interface described
  below.

I have added the following:
+ finished signal:
Allow to get a notification when a command is finished. It's useful when
another plugin (the debugger by example) needs to rebuild a target and
starts only when the build is completed. I'm using GQuark in the
interface as I think it's the simplest solution. I will perhaps use
IAnjutaCommand in the implementation though.
+ is_built:
Allow to check if a target is up to date. This can be done using make
-q, and is faster on my computer than running make doing nothing if the
target is already up to date. If it's too difficult to implement for
another build system, it's possible to always return FALSE.
+ cancel:
Allow to cancel a command, could be useful and not a big problem with
the GQuark.

One plugin could implement IAnjutaBuilder and IAnjutaBuildable to keep
backward compatibility.


interface IAnjutaBuilder
{

        /* Types */
        enum Error
        {
                OK              =  0,
                CANCEL,
                UNKNOWN_TARGET,
                UNKNOWN_ERROR,
                OTHER_ERROR
        }

        /**
        * IAnjutaBuilder::finished:
        * @obj: Self
        * @err: NULL if command succeed else GError object
        *
        * This signal is emitted when a command with a non
        * null command_id is finished. The command_id is used
        * as detail argument when the signal is emitted so
        * only the caller get the signal.
        */
        void ::finished (GError* err);

        /**
        * ianjuta_builder_is_built:
        * @obj: Self
        * @uri: target uri
        * @command_id: Quark used to identify command, could be 0
        * @err: Error propagation and reporting.
        *
        * Check if the corresponding target is up to date or not.
        *
        * Returns: TRUE if the target is already built.
        */
        gboolean is_built (const gchar *uri, GQuark command_id);

        /**
        * ianjuta_builder_build:
        * @obj: Self
        * @uri: target uri
        * @command_id: Quark used to identify command, could be 0
        * @err: Error propagation and reporting.
        *
        * Build the specified target
        *
        * Returns: FALSE if there is an error.
        */
        gboolean build (const gchar *uri, GQuark command_id);

        /**
        * ianjuta_builder_cancel:
        * @obj: Self
        * @command_id: Quark used to identify command
        * @err: Error propagation and reporting.
        *
        * Cancel specified command
        *
        * Returns: FALSE if there is an error.
        */
        void cancel (GQuark command_id);
}


The IAnjutaBuildEnvironment replaces the part of IAnjutaBuildable
allowing to override build commands.

I have removed this from the build plugin because it is useful for other
plugins, at least, the run plugin and the debugger plugin. Both could
need to launch the program in a special way (using a simulator by
example). But valgrind plugin could use this too.

Then, it's working in the other direction. I mean each plugin executing
some commands (build plugin, run plugin, debugger plugin) needs to check
if IAnjutaBuildEnvironment is here and call the override function to get
the change on the command. The build environment plugins (maemo plugin
or poky plugin) don't need to check for other plugins. They just need to
implement IAnjutaBuildEnvironment.

There is only one function passing to the build environment plugin, the
full command line and the additional environment variables in two
strings array. The build environment plugin can make all changes needed
reallocating the string array if necessary. By example for scratchbox,
it just needs to add "scratchbox/login -d". If necessary the plugin can
change the program name, replaces "gcc" by "arm-gcc" by example or
program options.

If a build environment plugin needs to do something specific for one
program, gcc by example, it has to check argv[0]. Perhaps adding a
command_id (like in the IAnjutaBuildable interface) would be easier. On
the other hand it adds some limitations.

All this is a first idea. It can change if I get some comments. Anyway I
will try to implement this but then I will check it and see if it's
working well together, so probably changing things.

interface IAnjutaBuildEnvironment
{
        /**
        * ianjuta_build_environment_override:
        * @obj: Self
        * @argv: a pointer on a NULL terminated string array
        * containing the command name in argv[0] and all
        * its argument
        * @env: a pointer on a NULL terminated string array
        * containing all additional environment variable
        * used by the command
        * @err: Error propagation and reporting.
        *
        * Override a command to work in another build environment
        *
        * Returns: FALSE if there is an error.
        */
        gboolean override (gchar ***argv, gchar ***envp);
}

Regards,

Sébastien

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Anjuta-devel mailing list
Anjuta-devel@...
https://lists.sourceforge.net/lists/listinfo/anjuta-devel
LightInTheBox - Buy quality products at wholesale price!