2005-11-22 12:26:26 +00:00
|
|
|
/*
|
|
|
|
* build.h - this file is part of Geany, a fast and lightweight IDE
|
|
|
|
*
|
2009-01-04 18:30:42 +00:00
|
|
|
* Copyright 2005-2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
|
|
|
* Copyright 2006-2009 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
2005-11-22 12:26:26 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
2006-01-03 12:39:25 +00:00
|
|
|
* $Id$
|
2005-11-22 12:26:26 +00:00
|
|
|
*/
|
|
|
|
|
2009-08-24 12:39:13 +00:00
|
|
|
/* * @file build.h Interface to the Build menu functionality. */
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
#ifndef GEANY_BUILD_H
|
|
|
|
#define GEANY_BUILD_H 1
|
|
|
|
|
2009-04-24 19:31:00 +00:00
|
|
|
#define GEANY_BUILD_ERR_HIGHLIGHT_MAX 100
|
2009-04-21 20:54:50 +00:00
|
|
|
|
2009-07-28 01:38:41 +00:00
|
|
|
/* Order is important (see GBO_TO_GBG, GBO_TO_CMD below) */
|
|
|
|
/** Geany Known Build Commands.
|
|
|
|
* These commands are named after their default use.
|
|
|
|
* Only these commands can currently have keybindings.
|
|
|
|
**/
|
2009-07-09 06:49:42 +00:00
|
|
|
typedef enum
|
2006-10-16 14:15:04 +00:00
|
|
|
{
|
2009-07-30 02:04:08 +00:00
|
|
|
GEANY_GBO_COMPILE, /**< default compile file */
|
|
|
|
GEANY_GBO_BUILD, /**< default build file */
|
|
|
|
GEANY_GBO_MAKE_ALL, /**< default make */
|
|
|
|
GEANY_GBO_CUSTOM, /**< default make user specified target */
|
|
|
|
GEANY_GBO_MAKE_OBJECT, /**< default make object, make %e.o */
|
|
|
|
GEANY_GBO_EXEC, /**< default execute ./%e */
|
|
|
|
GEANY_GBO_COUNT /**< count of how many */
|
2008-05-16 14:35:41 +00:00
|
|
|
} GeanyBuildType;
|
2006-10-16 14:15:04 +00:00
|
|
|
|
2009-07-22 03:04:17 +00:00
|
|
|
/** Groups of Build menu items. */
|
|
|
|
typedef enum
|
2009-07-09 06:49:42 +00:00
|
|
|
{
|
2009-07-30 02:04:08 +00:00
|
|
|
GEANY_GBG_FT, /**< filetype items */
|
|
|
|
GEANY_GBG_NON_FT, /**< non filetype items.*/
|
|
|
|
GEANY_GBG_EXEC, /**< execute items */
|
|
|
|
GEANY_GBG_COUNT /**< count of groups. */
|
2009-07-09 06:49:42 +00:00
|
|
|
} GeanyBuildGroup;
|
|
|
|
|
2009-07-14 07:15:31 +00:00
|
|
|
/* include the fixed widgets in an array indexed by groups */
|
2009-07-30 02:04:08 +00:00
|
|
|
#define GBG_FIXED GEANY_GBG_COUNT
|
2009-07-09 06:49:42 +00:00
|
|
|
|
2009-07-28 12:13:45 +00:00
|
|
|
/** Convert @c GeanyBuildType to @c GeanyBuildGroup.
|
|
|
|
*
|
|
|
|
* This macro converts @c GeanyBuildType enum values (the "known" commands)
|
2009-07-28 01:38:41 +00:00
|
|
|
* to the group they are part of.
|
2009-07-28 12:13:45 +00:00
|
|
|
*
|
2009-07-28 01:38:41 +00:00
|
|
|
* @param gbo the @c GeanyBuildType value.
|
2009-07-28 12:13:45 +00:00
|
|
|
*
|
2009-07-28 01:38:41 +00:00
|
|
|
* @return the @c GeanyBuildGroup group that @a gbo is in.
|
2009-07-28 12:13:45 +00:00
|
|
|
*
|
|
|
|
* Note this is a macro so that it can be used in static initialisers.
|
2009-07-28 01:38:41 +00:00
|
|
|
**/
|
2009-07-30 02:04:08 +00:00
|
|
|
#define GBO_TO_GBG(gbo) ((gbo)>GEANY_GBO_EXEC?GEANY_GBG_COUNT:((gbo)>=GEANY_GBO_EXEC?GEANY_GBG_EXEC: \
|
2009-09-16 14:13:38 +00:00
|
|
|
((gbo) >= GEANY_GBO_MAKE_ALL ? GEANY_GBG_NON_FT : GEANY_GBG_FT)))
|
2009-07-28 01:38:41 +00:00
|
|
|
|
|
|
|
/** Convert @c GeanyBuildType to command index.
|
2009-07-28 12:13:45 +00:00
|
|
|
*
|
2009-07-28 01:38:41 +00:00
|
|
|
* This macro converts @c GeanyBuildType enum values (the "known" commands)
|
|
|
|
* to the index within the group.
|
2009-07-28 12:13:45 +00:00
|
|
|
*
|
2009-07-28 01:38:41 +00:00
|
|
|
* @param gbo the @c GeanyBuildType value.
|
2009-07-28 12:13:45 +00:00
|
|
|
*
|
2009-07-28 01:38:41 +00:00
|
|
|
* @return the index of the @a gbo command in its group.
|
2009-07-28 12:13:45 +00:00
|
|
|
*
|
|
|
|
* Note this is a macro so that it can be used in static initialisers.
|
2009-07-28 01:38:41 +00:00
|
|
|
**/
|
2009-07-30 02:04:08 +00:00
|
|
|
#define GBO_TO_CMD(gbo) ((gbo)>=GEANY_GBO_COUNT?(gbo)-GEANY_GBO_COUNT:((gbo)>=GEANY_GBO_EXEC?(gbo)-GEANY_GBO_EXEC: \
|
2009-09-16 14:13:38 +00:00
|
|
|
((gbo) >= GEANY_GBO_MAKE_ALL ? (gbo)-GEANY_GBO_MAKE_ALL : (gbo))))
|
2009-07-09 06:49:42 +00:00
|
|
|
|
|
|
|
enum GeanyBuildFixedMenuItems
|
|
|
|
{
|
|
|
|
GBF_NEXT_ERROR,
|
|
|
|
GBF_PREV_ERROR,
|
|
|
|
GBF_COMMANDS,
|
|
|
|
GBF_SEP_1,
|
|
|
|
GBF_SEP_2,
|
|
|
|
GBF_SEP_3,
|
|
|
|
GBF_SEP_4,
|
|
|
|
GBF_COUNT
|
|
|
|
};
|
|
|
|
|
2009-07-22 03:04:17 +00:00
|
|
|
/** Build menu item sources in increasing priority */
|
|
|
|
typedef enum
|
2009-07-09 06:49:42 +00:00
|
|
|
{
|
2009-07-30 02:04:08 +00:00
|
|
|
GEANY_BCS_DEF, /**< Default values. */
|
|
|
|
GEANY_BCS_FT, /**< System filetype values. */
|
|
|
|
GEANY_BCS_HOME_FT, /**< Filetypes in ~/.config/geany/filedefs */
|
|
|
|
GEANY_BCS_PREF, /**< Preferences file ~/.config/geany/geany.conf */
|
|
|
|
GEANY_BCS_PROJ, /**< Project file if open. */
|
|
|
|
GEANY_BCS_COUNT /**< Count of sources. */
|
2009-07-09 06:49:42 +00:00
|
|
|
} GeanyBuildSource;
|
|
|
|
|
2008-05-16 14:35:41 +00:00
|
|
|
typedef struct GeanyBuildInfo
|
2006-10-16 14:15:04 +00:00
|
|
|
{
|
2009-07-09 06:49:42 +00:00
|
|
|
GeanyBuildGroup grp;
|
|
|
|
gint cmd;
|
2008-05-16 14:35:41 +00:00
|
|
|
GPid pid; /* process id of the spawned process */
|
|
|
|
gchar *dir;
|
|
|
|
guint file_type_id;
|
|
|
|
gchar *custom_target;
|
2009-04-21 20:54:50 +00:00
|
|
|
gint message_count;
|
2008-05-16 14:35:41 +00:00
|
|
|
} GeanyBuildInfo;
|
|
|
|
|
|
|
|
extern GeanyBuildInfo build_info;
|
2006-10-16 14:15:04 +00:00
|
|
|
|
2009-07-22 03:04:17 +00:00
|
|
|
/** The entries of a command for a menu item */
|
2009-07-15 06:55:12 +00:00
|
|
|
typedef enum GeanyBuildCmdEntries
|
|
|
|
{
|
2009-07-30 02:04:08 +00:00
|
|
|
GEANY_BC_LABEL, /**< The menu item label, _ marks mnemonic */
|
|
|
|
GEANY_BC_COMMAND, /**< The command to run. */
|
|
|
|
GEANY_BC_WORKING_DIR, /**< The directory to run in */
|
|
|
|
GEANY_BC_CMDENTRIES_COUNT, /**< Count of entries */
|
2009-07-15 06:55:12 +00:00
|
|
|
} GeanyBuildCmdEntries;
|
|
|
|
|
2009-07-22 03:04:17 +00:00
|
|
|
/** The command for a menu item. */
|
2009-07-09 06:49:42 +00:00
|
|
|
typedef struct GeanyBuildCommand
|
|
|
|
{
|
2009-07-28 12:13:45 +00:00
|
|
|
/** Pointers to g_string values of the command entries.
|
2009-07-22 03:04:17 +00:00
|
|
|
* Must be freed if the pointer is changed. */
|
2009-07-30 02:04:08 +00:00
|
|
|
gchar *entries[GEANY_BC_CMDENTRIES_COUNT];
|
2009-07-22 03:04:17 +00:00
|
|
|
gboolean exists; /**< If the entries have valid values. */
|
|
|
|
gboolean changed; /**< Save on exit if @c changed, remove if not @c exist. */
|
|
|
|
gboolean old; /**< Converted from old format. */
|
2009-07-09 06:49:42 +00:00
|
|
|
} GeanyBuildCommand;
|
|
|
|
|
2009-09-06 16:50:20 +00:00
|
|
|
/* project command array pointers */
|
|
|
|
extern GeanyBuildCommand *non_ft_proj;
|
|
|
|
extern GeanyBuildCommand *exec_proj;
|
2009-07-14 07:15:31 +00:00
|
|
|
extern gchar *regex_proj; /* project non-fileregex string */
|
2007-09-17 11:16:48 +00:00
|
|
|
|
|
|
|
typedef struct BuildMenuItems
|
2006-11-30 15:42:52 +00:00
|
|
|
{
|
|
|
|
GtkWidget *menu;
|
2009-09-06 16:50:20 +00:00
|
|
|
GtkWidget **menu_item[GEANY_GBG_COUNT + 1]; /* +1 for fixed items */
|
2006-11-30 15:42:52 +00:00
|
|
|
} BuildMenuItems;
|
|
|
|
|
2009-07-14 07:15:31 +00:00
|
|
|
/* a structure defining the destinations for a set of groups of commands & regex */
|
|
|
|
typedef struct BuildDestination
|
|
|
|
{
|
2009-07-30 02:04:08 +00:00
|
|
|
GeanyBuildCommand **dst[GEANY_GBG_COUNT];
|
2009-07-14 07:15:31 +00:00
|
|
|
gchar **fileregexstr;
|
|
|
|
gchar **nonfileregexstr;
|
|
|
|
} BuildDestination;
|
|
|
|
|
2009-07-09 06:49:42 +00:00
|
|
|
/* opaque pointers returned from build functions and passed back to them */
|
|
|
|
typedef struct TableFields *TableData;
|
2006-10-16 14:15:04 +00:00
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
void build_init(void);
|
2007-08-23 11:34:06 +00:00
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
void build_finalize(void);
|
2006-10-16 14:41:57 +00:00
|
|
|
|
2009-07-09 06:49:42 +00:00
|
|
|
/* menu configuration dialog functions */
|
2009-09-06 16:50:20 +00:00
|
|
|
GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, TableData *data, GeanyFiletype *ft);
|
2009-07-09 06:49:42 +00:00
|
|
|
|
2009-09-06 16:50:20 +00:00
|
|
|
gboolean build_read_commands(BuildDestination *dst, TableData data, gint response);
|
2007-08-23 11:34:06 +00:00
|
|
|
|
2009-09-06 16:50:20 +00:00
|
|
|
void build_free_fields(TableData data);
|
2009-07-09 06:49:42 +00:00
|
|
|
|
2009-08-26 17:25:28 +00:00
|
|
|
void build_set_non_ft_wd_to_proj(TableData table_data);
|
2009-07-19 09:20:37 +00:00
|
|
|
|
2009-07-09 06:49:42 +00:00
|
|
|
/* build response decode assistance function */
|
2007-01-04 11:49:14 +00:00
|
|
|
gboolean build_parse_make_dir(const gchar *string, gchar **prefix);
|
2006-12-30 16:16:59 +00:00
|
|
|
|
2009-07-09 06:49:42 +00:00
|
|
|
/* build menu functions */
|
2009-07-22 03:04:17 +00:00
|
|
|
|
|
|
|
/** Update the build menu to reflect changes in configuration or status.
|
2009-07-27 16:37:23 +00:00
|
|
|
*
|
2009-07-22 03:04:17 +00:00
|
|
|
* Sets the labels and number of visible items to match the highest
|
|
|
|
* priority configured commands. Also sets sensitivity if build commands are
|
|
|
|
* running and switches executes to stop when commands are running.
|
2009-07-27 16:37:23 +00:00
|
|
|
*
|
2009-07-22 03:04:17 +00:00
|
|
|
* @param doc The current document, if available, to save looking it up.
|
|
|
|
* If @c NULL it will be looked up.
|
2009-07-27 16:37:23 +00:00
|
|
|
*
|
2009-07-22 03:04:17 +00:00
|
|
|
* Call this after modifying any fields of a GeanyBuildCommand structure.
|
2009-07-27 16:37:23 +00:00
|
|
|
*
|
2009-07-22 03:04:17 +00:00
|
|
|
* @see Build Menu Configuration section of the Manual.
|
2009-07-27 16:37:23 +00:00
|
|
|
*
|
2009-07-22 03:04:17 +00:00
|
|
|
**/
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
void build_menu_update(GeanyDocument *doc);
|
2006-10-18 19:35:42 +00:00
|
|
|
|
2006-11-30 15:42:52 +00:00
|
|
|
|
2009-01-17 17:59:20 +00:00
|
|
|
void build_toolbutton_build_clicked(GtkAction *action, gpointer user_data);
|
|
|
|
|
2009-07-22 03:04:17 +00:00
|
|
|
/** Remove the specified Build menu item.
|
2009-07-27 16:37:23 +00:00
|
|
|
*
|
2009-07-22 03:04:17 +00:00
|
|
|
* Makes the specified menu item configuration no longer exist. This
|
|
|
|
* is different to setting fields to blank because the menu item
|
2009-07-27 16:37:23 +00:00
|
|
|
* will be deleted from the configuration file on saving
|
|
|
|
* (except the system filetypes settings @see Build Menu Configuration
|
|
|
|
* section of the Manual).
|
|
|
|
*
|
2009-07-22 03:04:17 +00:00
|
|
|
* @param src the source of the menu item to remove.
|
|
|
|
* @param grp the group of the command to remove.
|
2009-07-27 16:37:23 +00:00
|
|
|
* @param cmd the index (from 0) of the command within the group. A negative
|
2009-07-22 03:04:17 +00:00
|
|
|
* value will remove the whole group.
|
2009-07-27 16:37:23 +00:00
|
|
|
*
|
2009-07-22 03:04:17 +00:00
|
|
|
* If any parameter is out of range does nothing.
|
2009-07-27 16:37:23 +00:00
|
|
|
*
|
2009-07-22 03:04:17 +00:00
|
|
|
* @see build_menu_update
|
|
|
|
**/
|
|
|
|
|
|
|
|
void build_remove_menu_item(GeanyBuildSource src, GeanyBuildGroup grp, gint cmd);
|
|
|
|
|
|
|
|
/** Get the @a GeanyBuildCommand structure for the specified Build menu item.
|
2009-07-27 16:37:23 +00:00
|
|
|
*
|
|
|
|
* Get the command for any menu item specified by @a src, @a grp and @a cmd even if it is
|
2009-07-22 03:04:17 +00:00
|
|
|
* hidden by higher priority commands.
|
2009-07-27 16:37:23 +00:00
|
|
|
*
|
2009-07-22 03:04:17 +00:00
|
|
|
* @param src the source of the specified menu item.
|
|
|
|
* @param grp the group of the specified menu item.
|
|
|
|
* @param cmd the index of the command within the group.
|
2009-07-27 16:37:23 +00:00
|
|
|
*
|
2009-07-22 03:04:17 +00:00
|
|
|
* @return a pointer to the @a GeanyBuildCommand structure or @a NULL if it doesn't exist.
|
|
|
|
* This is a pointer to an internal structure and must not be freed.
|
2009-07-27 16:37:23 +00:00
|
|
|
*
|
2009-07-22 03:04:17 +00:00
|
|
|
* @see build_menu_update
|
|
|
|
**/
|
|
|
|
|
|
|
|
GeanyBuildCommand *build_get_menu_item(GeanyBuildSource src, GeanyBuildGroup grp, gint cmd);
|
|
|
|
|
|
|
|
/** Get the @a GeanyBuildCommand structure for the menu item.
|
2009-07-27 16:37:23 +00:00
|
|
|
*
|
|
|
|
* Get the current highest priority command specified by @a grp and @a cmd. This is the one
|
2009-07-22 03:04:17 +00:00
|
|
|
* that the menu item will use if activated.
|
2009-07-27 16:37:23 +00:00
|
|
|
*
|
2009-07-22 03:04:17 +00:00
|
|
|
* @param grp the group of the specified menu item.
|
|
|
|
* @param cmd the index of the command within the group.
|
|
|
|
* @param src pointer to @a gint to return which source provided the command. Ignored if @a NULL.
|
|
|
|
* Values are one of @a GeanyBuildSource but returns a signed type not the enum.
|
2009-07-27 16:37:23 +00:00
|
|
|
*
|
2009-07-22 03:04:17 +00:00
|
|
|
* @return a pointer to the @a GeanyBuildCommand structure or @a NULL if it doesn't exist.
|
|
|
|
* This is a pointer to an internal structure and must not be freed.
|
2009-07-27 16:37:23 +00:00
|
|
|
*
|
2009-07-22 03:04:17 +00:00
|
|
|
* @see build_menu_update
|
|
|
|
**/
|
|
|
|
|
|
|
|
GeanyBuildCommand *build_get_current_menu_item(GeanyBuildGroup grp, gint cmd, gint *src);
|
|
|
|
|
|
|
|
BuildMenuItems *build_get_menu_items(gint filetype_idx);
|
2009-07-09 06:49:42 +00:00
|
|
|
|
|
|
|
/* load and store menu configuration */
|
2009-09-06 16:50:20 +00:00
|
|
|
void build_load_menu(GKeyFile *config, GeanyBuildSource dst, gpointer ptr);
|
2009-07-19 09:20:37 +00:00
|
|
|
|
2009-09-06 16:50:20 +00:00
|
|
|
void build_save_menu(GKeyFile *config, gpointer ptr, GeanyBuildSource src);
|
2009-07-09 06:49:42 +00:00
|
|
|
|
2009-07-28 01:38:41 +00:00
|
|
|
void build_set_group_count(GeanyBuildGroup grp, gint count);
|
2009-01-17 17:59:20 +00:00
|
|
|
|
2009-07-28 01:38:41 +00:00
|
|
|
gint build_get_group_count(GeanyBuildGroup grp);
|
2006-10-18 19:35:42 +00:00
|
|
|
|
2009-07-28 01:38:41 +00:00
|
|
|
gchar **build_get_regex(GeanyBuildGroup grp, GeanyFiletype *ft, gint *from);
|
2009-07-14 07:15:31 +00:00
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
#endif
|