2 * build.h - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2005-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 * Copyright 2006-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 /** @file build.h Interface to the Build menu functionality. */
25 #define GEANY_BUILD_H 1
28 #include "filetypes.h"
30 #include "gtkcompat.h"
34 /** Groups of Build menu items. */
37 GEANY_GBG_FT
, /**< filetype items */
38 GEANY_GBG_NON_FT
, /**< non filetype items.*/
39 GEANY_GBG_EXEC
, /**< execute items */
40 GEANY_GBG_COUNT
/**< count of groups. */
43 /** Build menu item sources in increasing priority */
46 GEANY_BCS_DEF
, /**< Default values. */
47 GEANY_BCS_FT
, /**< System filetype values. */
48 GEANY_BCS_HOME_FT
, /**< Filetypes in ~/.config/geany/filedefs */
49 GEANY_BCS_PREF
, /**< Preferences file ~/.config/geany/geany.conf */
50 GEANY_BCS_PROJ_FT
, /**< Project file filetype command */
51 GEANY_BCS_PROJ
, /**< Project file if open. */
52 GEANY_BCS_COUNT
/**< Count of sources. */
55 /** The entries of a command for a menu item */
56 typedef enum GeanyBuildCmdEntries
58 GEANY_BC_LABEL
, /**< The menu item label, _ marks mnemonic */
59 GEANY_BC_COMMAND
, /**< The command to run. */
60 GEANY_BC_WORKING_DIR
, /**< The directory to run in */
61 GEANY_BC_CMDENTRIES_COUNT
/**< Count of entries */
62 } GeanyBuildCmdEntries
;
64 void build_activate_menu_item(const GeanyBuildGroup grp
, const guint cmd
);
66 const gchar
*build_get_current_menu_item(const GeanyBuildGroup grp
, const guint cmd
,
67 const GeanyBuildCmdEntries field
);
69 void build_remove_menu_item(const GeanyBuildSource src
, const GeanyBuildGroup grp
, const gint cmd
);
71 void build_set_menu_item(const GeanyBuildSource src
, const GeanyBuildGroup grp
,
72 const guint cmd
, const GeanyBuildCmdEntries field
, const gchar
*value
);
74 guint
build_get_group_count(const GeanyBuildGroup grp
);
79 /* Order is important (see GBO_TO_GBG, GBO_TO_CMD below) */
80 /* * Geany Known Build Commands.
81 * These commands are named after their default use.
82 * Only these commands can currently have keybindings.
86 GEANY_GBO_COMPILE
, /* *< default compile file */
87 GEANY_GBO_BUILD
, /* *< default build file */
88 GEANY_GBO_MAKE_ALL
, /* *< default make */
89 GEANY_GBO_CUSTOM
, /* *< default make user specified target */
90 GEANY_GBO_MAKE_OBJECT
, /* *< default make object, make %e.o */
91 GEANY_GBO_EXEC
, /* *< default execute ./%e */
92 GEANY_GBO_COUNT
/* *< count of how many */
95 /* include the fixed widgets in an array indexed by groups */
96 #define GBG_FIXED GEANY_GBG_COUNT
98 /* * Convert @c GeanyBuildType to @c GeanyBuildGroup.
100 * This macro converts @c GeanyBuildType enum values (the "known" commands)
101 * to the group they are part of.
103 * @param gbo the @c GeanyBuildType value.
105 * @return the @c GeanyBuildGroup group that @a gbo is in.
107 * Note this is a macro so that it can be used in static initialisers.
109 #define GBO_TO_GBG(gbo) ((gbo)>GEANY_GBO_EXEC?GEANY_GBG_COUNT:((gbo)>=GEANY_GBO_EXEC?GEANY_GBG_EXEC: \
110 ((gbo) >= GEANY_GBO_MAKE_ALL ? GEANY_GBG_NON_FT : GEANY_GBG_FT)))
112 /* * Convert @c GeanyBuildType to command index.
114 * This macro converts @c GeanyBuildType enum values (the "known" commands)
115 * to the index within the group.
117 * @param gbo the @c GeanyBuildType value.
119 * @return the index of the @a gbo command in its group.
121 * Note this is a macro so that it can be used in static initialisers.
123 #define GBO_TO_CMD(gbo) ((gbo)>=GEANY_GBO_COUNT?(gbo)-GEANY_GBO_COUNT:((gbo)>=GEANY_GBO_EXEC?(gbo)-GEANY_GBO_EXEC: \
124 ((gbo) >= GEANY_GBO_MAKE_ALL ? (gbo)-GEANY_GBO_MAKE_ALL : (gbo))))
126 enum GeanyBuildFixedMenuItems
138 typedef struct GeanyBuildInfo
142 GPid pid
; /* process id of the spawned process */
145 gchar
*custom_target
;
149 extern GeanyBuildInfo build_info
;
151 /* * The command for a menu item. */
152 typedef struct GeanyBuildCommand
154 /* * Pointers to g_string values of the command entries.
155 * Must be freed if the pointer is changed. */
156 gchar
*label
; /* *< Menu item label */
157 gchar
*command
; /* *< Command to run */
158 gchar
*working_dir
; /* *< working directory */
159 gboolean exists
; /* *< If the entries have valid values. */
160 gboolean changed
; /* *< Save on exit if @c changed, remove if not @c exist. */
161 gboolean old
; /* *< Converted from old format. */
164 typedef struct BuildMenuItems
167 GtkWidget
**menu_item
[GEANY_GBG_COUNT
+ 1]; /* +1 for fixed items */
170 /* a structure defining the destinations for a set of groups of commands & regex */
171 typedef struct BuildDestination
173 GeanyBuildCommand
**dst
[GEANY_GBG_COUNT
];
174 gchar
**fileregexstr
;
175 gchar
**nonfileregexstr
;
178 /* opaque pointers returned from build functions and passed back to them */
179 typedef struct BuildTableFields
*BuildTableData
;
182 void build_init(void);
184 void build_finalize(void);
186 /* menu configuration dialog functions */
187 GtkWidget
*build_commands_table(GeanyDocument
*doc
, GeanyBuildSource dst
, BuildTableData
*data
, GeanyFiletype
*ft
);
189 void build_read_project(GeanyFiletype
*ft
, BuildTableData build_properties
);
191 void build_free_fields(BuildTableData data
);
193 /* build response decode assistance function */
194 gboolean
build_parse_make_dir(const gchar
*string
, gchar
**prefix
);
196 /* build menu functions */
198 void build_menu_update(GeanyDocument
*doc
);
200 void build_toolbutton_build_clicked(GtkAction
*action
, gpointer user_data
);
202 GeanyBuildCommand
*build_get_menu_item(const GeanyBuildSource src
, const GeanyBuildGroup grp
, const guint cmd
);
204 BuildMenuItems
*build_get_menu_items(gint filetype_idx
);
206 /* load and store menu configuration */
207 void build_load_menu(GKeyFile
*config
, GeanyBuildSource dst
, gpointer ptr
);
209 void build_save_menu(GKeyFile
*config
, gpointer ptr
, GeanyBuildSource src
);
211 void build_set_group_count(GeanyBuildGroup grp
, gint count
);
213 gchar
**build_get_regex(GeanyBuildGroup grp
, GeanyFiletype
*ft
, guint
*from
);
215 #endif /* GEANY_PRIVATE */
219 #endif /* GEANY_BUILD_H */