jbsrc/lib/src/core/jb-resource.h (10767B) - raw
1 /* 2 * JB, the Jean-Yves Lefort's Build System 3 * Copyright (C) 2008 Jean-Yves Lefort <jylefort@brutele.be> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 20 #ifndef _JB_RESOURCE_H 21 #define _JB_RESOURCE_H 22 23 #include <stdarg.h> 24 #include <glib-object.h> 25 #include "jb-decls.h" 26 #include "jb-compile-options.h" 27 #include "jb-install-options.h" 28 29 #define JB_TYPE_RESOURCE (jb_resource_get_type()) 30 #define JB_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JB_TYPE_RESOURCE, JBResource)) 31 #define JB_RESOURCE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST((class), JB_TYPE_RESOURCE, JBResourceClass)) 32 #define JB_IS_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), JB_TYPE_RESOURCE)) 33 #define JB_RESOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), JB_TYPE_RESOURCE, JBResourceClass)) 34 35 typedef struct 36 { 37 GObject parent; 38 } JBResource; 39 40 typedef struct 41 { 42 GObjectClass parent; 43 44 char * (*to_string) (JBResource *self); 45 46 void (*pre_build) (JBResource *self); 47 void (*build) (JBResource *self); 48 void (*install) (JBResource *self); 49 void (*makedist) (JBResource *self); 50 void (*clean) (JBResource *self); 51 void (*distclean) (JBResource *self); 52 void (*maintainerclean) (JBResource *self); 53 } JBResourceClass; 54 55 GType jb_resource_get_type (void); 56 57 char *jb_resource_to_string (JBResource *self); 58 59 void jb_resource_pre_build (JBResource *self); 60 void jb_resource_build (JBResource *self); 61 void jb_resource_install (JBResource *self); 62 void jb_resource_makedist (JBResource *self); 63 void jb_resource_clean (JBResource *self); 64 void jb_resource_distclean (JBResource *self); 65 void jb_resource_maintainerclean (JBResource *self); 66 67 void jb_resource_message_building (JBResource *self); 68 69 #define JB_TYPE_GROUP_RESOURCE (jb_group_resource_get_type()) 70 #define JB_GROUP_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JB_TYPE_GROUP_RESOURCE, JBGroupResource)) 71 #define JB_IS_GROUP_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), JB_TYPE_GROUP_RESOURCE)) 72 73 struct JBGroupResource 74 { 75 JBResource parent; 76 77 JBGroup *group; 78 }; 79 80 typedef struct 81 { 82 JBResourceClass parent; 83 } JBGroupResourceClass; 84 85 GType jb_group_resource_get_type (void); 86 87 #define JB_TYPE_OBJECT_RESOURCE (jb_object_resource_get_type()) 88 #define JB_OBJECT_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JB_TYPE_OBJECT_RESOURCE, JBObjectResource)) 89 #define JB_OBJECT_RESOURCE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST((class), JB_TYPE_OBJECT_RESOURCE, JBObjectResourceClass)) 90 #define JB_IS_OBJECT_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), JB_TYPE_OBJECT_RESOURCE)) 91 #define JB_OBJECT_RESOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), JB_TYPE_OBJECT_RESOURCE, JBObjectResourceClass)) 92 93 typedef struct 94 { 95 JBResource parent; 96 97 JBObject *object; 98 } JBObjectResource; 99 100 typedef struct 101 { 102 JBResourceClass parent; 103 104 char * (*get_object_file) (JBObjectResource *self); 105 } JBObjectResourceClass; 106 107 GType jb_object_resource_get_type (void); 108 109 #define JB_TYPE_TEMPLATE (jb_template_get_type()) 110 #define JB_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JB_TYPE_TEMPLATE, JBTemplate)) 111 #define JB_IS_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), JB_TYPE_TEMPLATE)) 112 113 typedef struct 114 { 115 JBGroupResource parent; 116 117 char *filename; 118 } JBTemplate; 119 120 typedef struct 121 { 122 JBGroupResourceClass parent; 123 } JBTemplateClass; 124 125 GType jb_template_get_type (void); 126 127 JBTemplate *jb_template_new (const char *filename); 128 129 #define JB_TYPE_DATA_FILE (jb_data_file_get_type()) 130 #define JB_DATA_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JB_TYPE_DATA_FILE, JBDataFile)) 131 #define JB_IS_DATA_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), JB_TYPE_DATA_FILE)) 132 133 typedef struct 134 { 135 JBGroupResource parent; 136 137 char *filename; 138 139 JBInstallOptions *install_options; 140 } JBDataFile; 141 142 typedef struct 143 { 144 JBGroupResourceClass parent; 145 } JBDataFileClass; 146 147 GType jb_data_file_get_type (void); 148 149 JBDataFile *jb_data_file_new (const char *filename); 150 151 #define JB_TYPE_SOURCE (jb_source_get_type()) 152 #define JB_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JB_TYPE_SOURCE, JBSource)) 153 #define JB_IS_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), JB_TYPE_SOURCE)) 154 155 typedef struct 156 { 157 JBObjectResource parent; 158 159 char *filename; 160 } JBSource; 161 162 typedef struct 163 { 164 JBObjectResourceClass parent; 165 } JBSourceClass; 166 167 GType jb_source_get_type (void); 168 169 JBSource *jb_source_new (const char *filename); 170 171 #define JB_TYPE_GOB_CLASS (jb_gob_class_get_type()) 172 #define JB_GOB_CLASS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JB_TYPE_GOB_CLASS, JBGobClass)) 173 #define JB_IS_GOB_CLASS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), JB_TYPE_GOB_CLASS)) 174 175 typedef struct 176 { 177 JBObjectResource parent; 178 179 char *name; /* Foo:Bar */ 180 } JBGobClass; 181 182 typedef struct 183 { 184 JBObjectResourceClass parent; 185 } JBGobClassClass; 186 187 GType jb_gob_class_get_type (void); 188 189 JBGobClass *jb_gob_class_new (const char *name); 190 191 #define JB_TYPE_INTLTOOL_FILE (jb_intltool_file_get_type()) 192 #define JB_INTLTOOL_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JB_TYPE_INTLTOOL_FILE, JBIntltoolFile)) 193 #define JB_IS_INTLTOOL_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), JB_TYPE_INTLTOOL_FILE)) 194 195 typedef struct 196 { 197 JBGroupResource parent; 198 199 char *type; 200 char *filename; 201 char *merge_flags; 202 203 JBInstallOptions *install_options; 204 } JBIntltoolFile; 205 206 typedef struct 207 { 208 JBGroupResourceClass parent; 209 } JBIntltoolFileClass; 210 211 GType jb_intltool_file_get_type (void); 212 213 JBIntltoolFile *jb_intltool_file_new (const char *type, 214 const char *filename, 215 const char *merge_flags); 216 217 #define JB_TYPE_GCONF_SCHEMAS (jb_gconf_schemas_get_type()) 218 #define JB_GCONF_SCHEMAS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JB_TYPE_GCONF_SCHEMAS, JBGConfSchemas)) 219 #define JB_IS_GCONF_SCHEMAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), JB_TYPE_GCONF_SCHEMAS)) 220 221 typedef struct 222 { 223 JBIntltoolFile parent; 224 } JBGConfSchemas; 225 226 typedef struct 227 { 228 JBIntltoolFileClass parent; 229 } JBGConfSchemasClass; 230 231 GType jb_gconf_schemas_get_type (void); 232 233 JBGConfSchemas *jb_gconf_schemas_new (const char *filename); 234 235 #define JB_TYPE_GNOME_HELP (jb_gnome_help_get_type()) 236 #define JB_GNOME_HELP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JB_TYPE_GNOME_HELP, JBGnomeHelp)) 237 #define JB_IS_GNOME_HELP(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), JB_TYPE_GNOME_HELP)) 238 239 typedef struct 240 { 241 JBGroupResource parent; 242 243 char *name; 244 char *lang; 245 char **entities; 246 } JBGnomeHelp; 247 248 typedef struct 249 { 250 JBGroupResourceClass parent; 251 } JBGnomeHelpClass; 252 253 GType jb_gnome_help_get_type (void); 254 255 JBGnomeHelp *jb_gnome_help_new (const char *lang, const char *entities); 256 257 #define JB_TYPE_TRANSLATIONS (jb_translations_get_type()) 258 #define JB_TRANSLATIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JB_TYPE_TRANSLATIONS, JBTranslations)) 259 #define JB_IS_TRANSLATIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), JB_TYPE_TRANSLATIONS)) 260 261 typedef struct 262 { 263 JBGroupResource parent; 264 265 char *lang; 266 } JBTranslations; 267 268 typedef struct 269 { 270 JBGroupResourceClass parent; 271 } JBTranslationsClass; 272 273 GType jb_translations_get_type (void); 274 275 JBTranslations *jb_translations_new (const char *lang); 276 277 #define JB_TYPE_RULE (jb_rule_get_type()) 278 #define JB_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JB_TYPE_RULE, JBRule)) 279 #define JB_IS_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), JB_TYPE_RULE)) 280 281 typedef struct 282 { 283 JBGroupResource parent; 284 285 GSList *dependencies; 286 GSList *output_files; 287 GSList *input_files; 288 289 char *build_message; 290 GSList *build_commands; 291 292 char *install_message; 293 GSList *install_commands; 294 } JBRule; 295 296 typedef struct 297 { 298 JBGroupResourceClass parent; 299 } JBRuleClass; 300 301 GType jb_rule_get_type (void); 302 303 JBRule *jb_rule_new (void); 304 305 void jb_rule_add_dependency (JBRule *self, JBGroupResource *res); 306 307 void jb_rule_add_input_file (JBRule *self, const char *format, ...) G_GNUC_PRINTF(2, 3); 308 void jb_rule_add_output_file (JBRule *self, const char *format, ...) G_GNUC_PRINTF(2, 3); 309 310 void jb_rule_set_build_message (JBRule *self, const char *format, ...) G_GNUC_PRINTF(2, 3); 311 void jb_rule_add_build_command (JBRule *self, const char *format, ...) G_GNUC_PRINTF(2, 3); 312 313 void jb_rule_set_install_message (JBRule *self, const char *format, ...) G_GNUC_PRINTF(2, 3); 314 void jb_rule_add_install_command (JBRule *self, const char *format, ...) G_GNUC_PRINTF(2, 3); 315 316 #define JB_TYPE_OBJECT (jb_object_get_type()) 317 #define JB_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JB_TYPE_OBJECT, JBObject)) 318 #define JB_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST((class), JB_TYPE_OBJECT, JBObjectClass)) 319 #define JB_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), JB_TYPE_OBJECT)) 320 #define JB_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), JB_TYPE_OBJECT, JBObjectClass)) 321 322 struct JBObject 323 { 324 JBGroupResource parent; 325 326 char *name; 327 328 JBCompileOptions *compile_options; 329 JBInstallOptions *install_options; 330 331 GSList *resources; 332 GSList *headers; 333 }; 334 335 typedef struct 336 { 337 JBGroupResourceClass parent; 338 339 const char *type; 340 341 /* these fields can be NULL */ 342 const char *stock_cflags; 343 const char *stock_cppflags; 344 const char *stock_ldflags; 345 const char *stock_libs; 346 347 char * (*get_output_file) (JBObject *self); 348 } JBObjectClass; 349 350 GType jb_object_get_type (void); 351 352 void jb_object_add_source (JBObject *self, const char *name); 353 void jb_object_add_sources (JBObject *self, const char *name, ...) G_GNUC_NULL_TERMINATED; 354 355 #define JB_TYPE_PROGRAM (jb_program_get_type()) 356 #define JB_PROGRAM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JB_TYPE_PROGRAM, JBProgram)) 357 #define JB_IS_PROGRAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), JB_TYPE_PROGRAM)) 358 359 typedef struct 360 { 361 JBObject parent; 362 } JBProgram; 363 364 typedef struct 365 { 366 JBObjectClass parent; 367 } JBProgramClass; 368 369 GType jb_program_get_type (void); 370 371 JBProgram *jb_program_new (const char *name); 372 373 #define JB_TYPE_MODULE (jb_module_get_type()) 374 #define JB_MODULE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JB_TYPE_MODULE, JBModule)) 375 #define JB_IS_MODULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), JB_TYPE_MODULE)) 376 377 typedef struct 378 { 379 JBObject parent; 380 } JBModule; 381 382 typedef struct 383 { 384 JBObjectClass parent; 385 } JBModuleClass; 386 387 GType jb_module_get_type (void); 388 389 JBModule *jb_module_new (const char *name); 390 391 #endif /* _JB_RESOURCE_H */