2
* JB, the Jean-Yves Lefort's Build System
3
* Copyright (C) 2008 Jean-Yves Lefort <jylefort@brutele.be>
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.
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.
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.
21
#include "jb-resource.h"
23
#include "jb-variable.h"
25
#include "jb-feature.h"
26
#include "jb-action.h"
28
#define INTLTOOL_MERGE_IN "jbsrc/tools/intltool-merge.in"
29
#define INTLTOOL_MERGE_OUT "build/jbsrc/tools/intltool-merge"
30
#define INTLTOOL_MERGE_CACHE "build/jbsrc/tools/intltool-merge-cache"
33
has_template (const char *filename)
38
if (jb_templates == NULL)
41
template_input = g_strdup_printf("%s.in", filename);
42
result = jb_string_hash_set_contains(jb_templates, template_input);
43
g_free(template_input);
49
get_input_file (const char *filename)
51
if (has_template(filename))
52
return g_strdup_printf("build/%s", filename);
54
return g_strdup(filename);
58
get_output_file (const char *filename)
63
g_return_val_if_fail(filename != NULL, NULL);
64
g_return_val_if_fail(g_str_has_suffix(filename, ".in"), NULL);
66
tmp = jb_strip_extension(filename);
69
* If the input file is already in build/, do not put the output
70
* file in build/build/.
72
if (g_str_has_prefix(tmp, "build/"))
73
result = g_strdup(tmp);
75
result = g_strdup_printf("build/%s", tmp);
82
G_DEFINE_ABSTRACT_TYPE(JBResource, jb_resource, G_TYPE_OBJECT)
85
jb_resource_to_string (JBResource *self)
87
JBResourceClass *class;
89
g_return_val_if_fail(JB_IS_RESOURCE(self), NULL);
91
class = JB_RESOURCE_GET_CLASS(self);
93
if (class->to_string != NULL)
94
return class->to_string(self);
97
g_error("to_string() not implemented for resource type %s", G_OBJECT_TYPE_NAME(self));
103
jb_resource_pre_build (JBResource *self)
105
JBResourceClass *class;
107
g_return_if_fail(JB_IS_RESOURCE(self));
109
class = JB_RESOURCE_GET_CLASS(self);
111
if (class->pre_build != NULL)
112
class->pre_build(self);
116
jb_resource_build (JBResource *self)
118
JBResourceClass *class;
120
g_return_if_fail(JB_IS_RESOURCE(self));
122
class = JB_RESOURCE_GET_CLASS(self);
124
if (class->build != NULL)
129
jb_resource_install (JBResource *self)
131
JBResourceClass *class;
133
g_return_if_fail(JB_IS_RESOURCE(self));
135
class = JB_RESOURCE_GET_CLASS(self);
137
if (class->install != NULL)
138
class->install(self);
142
jb_resource_makedist (JBResource *self)
144
JBResourceClass *class;
146
g_return_if_fail(JB_IS_RESOURCE(self));
148
class = JB_RESOURCE_GET_CLASS(self);
150
if (class->makedist != NULL)
151
class->makedist(self);
155
jb_resource_clean (JBResource *self)
157
JBResourceClass *class;
159
g_return_if_fail(JB_IS_RESOURCE(self));
161
class = JB_RESOURCE_GET_CLASS(self);
163
if (class->clean != NULL)
168
jb_resource_distclean (JBResource *self)
170
JBResourceClass *class;
172
g_return_if_fail(JB_IS_RESOURCE(self));
174
class = JB_RESOURCE_GET_CLASS(self);
176
if (class->distclean != NULL)
177
class->distclean(self);
181
jb_resource_maintainerclean (JBResource *self)
183
JBResourceClass *class;
185
g_return_if_fail(JB_IS_RESOURCE(self));
187
class = JB_RESOURCE_GET_CLASS(self);
189
if (class->maintainerclean != NULL)
190
class->maintainerclean(self);
194
jb_resource_init (JBResource *self)
199
jb_resource_class_init (JBResourceClass *class)
204
resource_action_message (JBResource *self, const char *action)
208
g_return_if_fail(JB_IS_RESOURCE(self));
209
g_return_if_fail(action != NULL);
211
repr = jb_resource_to_string(self);
212
jb_message("%s %s", action, repr);
217
resource_message_building (JBResource *self)
219
g_return_if_fail(JB_IS_RESOURCE(self));
221
resource_action_message(self, "building");
224
G_DEFINE_ABSTRACT_TYPE(JBGroupResource, jb_group_resource, JB_TYPE_RESOURCE)
227
jb_group_resource_init (JBGroupResource *self)
232
jb_group_resource_class_init (JBGroupResourceClass *class)
236
G_DEFINE_ABSTRACT_TYPE(JBObjectResource, jb_object_resource, JB_TYPE_RESOURCE)
239
jb_object_resource_init (JBObjectResource *self)
244
jb_object_resource_class_init (JBObjectResourceClass *class)
249
object_resource_get_object_file (JBObjectResource *self)
251
JBObjectResourceClass *class;
253
g_return_val_if_fail(JB_IS_OBJECT_RESOURCE(self), NULL);
255
class = JB_OBJECT_RESOURCE_GET_CLASS(self);
257
if (class->get_object_file != NULL)
258
return class->get_object_file(self);
261
g_error("get_object_file() not implemented for object resource type %s", G_OBJECT_TYPE_NAME(self));
266
G_DEFINE_TYPE(JBTemplate, jb_template, JB_TYPE_GROUP_RESOURCE)
269
jb_template_new (const char *filename)
273
g_return_val_if_fail(filename != NULL, NULL);
274
g_return_val_if_fail(g_str_has_suffix(filename, ".in"), NULL);
276
self = g_object_new(JB_TYPE_TEMPLATE, NULL);
277
self->filename = g_strdup(filename);
283
template_to_string (JBResource *res)
285
JBTemplate *self = JB_TEMPLATE(res);
287
return g_strdup_printf("template %s", self->filename);
291
template_get_files (JBTemplate *self, char **infile, char **outfile)
293
JBGroupResource *gres = JB_GROUP_RESOURCE(self);
296
*infile = g_strdup_printf("%s/%s", gres->group->srcdir, self->filename);
301
tmp = jb_strip_extension(self->filename);
302
*outfile = g_strdup_printf("%s/%s", gres->group->builddir, tmp);
308
template_build (JBResource *res)
310
JBTemplate *self = JB_TEMPLATE(res);
314
template_get_files(self, &infile, &outfile);
316
if (! jb_is_uptodate(outfile, infile))
318
static GHashTable *variables = NULL;
320
resource_message_building(res);
322
if (variables == NULL)
326
variables = g_hash_table_new(g_str_hash, g_str_equal);
328
JB_LIST_FOREACH(l, jb_variables)
330
JBVariable *variable = l->data;
332
g_hash_table_insert(variables, variable->name, jb_variable_evaluate(variable));
336
jb_mkdir_of_file(outfile);
338
jb_subst(infile, outfile, variables);
346
template_makedist (JBResource *res)
348
JBTemplate *self = JB_TEMPLATE(res);
351
template_get_files(self, &infile, NULL);
353
jb_action_add_to_dist(infile);
359
template_clean (JBResource *res)
361
JBTemplate *self = JB_TEMPLATE(res);
364
template_get_files(self, NULL, &outfile);
366
jb_action_rm(outfile);
372
jb_template_init (JBTemplate *self)
377
jb_template_class_init (JBTemplateClass *class)
379
JBResourceClass *rclass = JB_RESOURCE_CLASS(class);
381
rclass->to_string = template_to_string;
382
rclass->build = template_build;
383
rclass->makedist = template_makedist;
384
rclass->clean = template_clean;
387
G_DEFINE_TYPE(JBDataFile, jb_data_file, JB_TYPE_GROUP_RESOURCE)
390
jb_data_file_new (const char *filename)
394
g_return_val_if_fail(filename != NULL, NULL);
396
self = g_object_new(JB_TYPE_DATA_FILE, NULL);
397
self->filename = g_strdup(filename);
403
data_file_to_string (JBResource *res)
405
JBDataFile *self = JB_DATA_FILE(res);
407
return g_strdup_printf("data file %s", self->filename);
411
data_file_install (JBResource *res)
413
JBDataFile *self = JB_DATA_FILE(res);
414
JBGroupResource *gres = JB_GROUP_RESOURCE(res);
419
srcfile = g_strdup_printf("%s/%s", gres->group->srcdir, self->filename);
420
real_srcfile = get_input_file(srcfile);
421
dstfile = g_path_get_basename(self->filename);
423
jb_install_options_install_data(&self->install_options, real_srcfile, dstfile);
426
g_free(real_srcfile);
431
data_file_makedist (JBResource *res)
433
JBDataFile *self = JB_DATA_FILE(res);
434
JBGroupResource *gres = JB_GROUP_RESOURCE(res);
437
file = g_strdup_printf("%s/%s", gres->group->srcdir, self->filename);
439
if (! has_template(file))
440
jb_action_add_to_dist(file);
446
jb_data_file_init (JBDataFile *self)
448
jb_install_options_init(&self->install_options);
452
jb_data_file_class_init (JBDataFileClass *class)
454
JBResourceClass *rclass = JB_RESOURCE_CLASS(class);
456
rclass->to_string = data_file_to_string;
457
rclass->install = data_file_install;
458
rclass->makedist = data_file_makedist;
462
parse_depsfile (const char *depsfile)
469
contents = jb_read_file(depsfile, NULL);
470
if (contents == NULL)
471
return NULL; /* depsfile is optional */
473
lines = g_strsplit(contents, "\n", 0);
476
for (i = 0; lines[i] != NULL; i++)
482
p = strchr(lines[i], ':');
488
files = g_strsplit(p, " ", 0);
490
for (j = 0; files[j] != NULL; j++)
494
file = g_strdup(files[j]);
495
file = g_strstrip(file);
497
if (*file != '\0' && *file != '\\')
498
deps = g_slist_prepend(deps, g_strdup(file));
510
object_file_get_depsfile (const char *ofile)
512
return g_strdup_printf("%s.deps", ofile);
516
object_file_is_uptodate (const char *ofile, const char *cfile)
521
if (! jb_variable_get_bool("cc-dependency-tracking"))
524
if (! jb_is_uptodate(ofile, cfile))
527
depsfile = object_file_get_depsfile(ofile);
528
deps = parse_depsfile(depsfile);
533
gboolean is_uptodate;
535
is_uptodate = jb_is_uptodate_list(ofile, deps);
537
jb_g_slist_free_deep(deps);
546
object_file_build (JBObject *object, const char *ofile, const char *cfile)
548
JBGroupResource *gres = JB_GROUP_RESOURCE(object);
549
JBObjectClass *object_class;
551
char *depsflags = NULL;
553
object_class = JB_OBJECT_GET_CLASS(object);
555
depsfile = object_file_get_depsfile(ofile);
557
if (jb_variable_get_bool("cc-dependency-tracking"))
558
depsflags = jb_variable_expand(" -MT $ofile -MD -MP -MF $depsfile",
560
"depsfile", depsfile,
563
jb_mkdir_of_file(ofile);
565
jb_action_exec("$cc $package-cflags $group-cflags $object-cflags $stock-cflags $cflags"
566
" $package-cppflags $group-cppflags $object-cppflags $stock-cppflags $cppflags"
567
" $depsflags -c -o $ofile $cfile",
568
"package-cflags", jb_compile_options.cflags->str,
569
"group-cflags", gres->group->compile_options.cflags->str,
570
"object-cflags", object->compile_options.cflags->str,
571
"stock-cflags", object_class->stock_cflags,
572
"package-cppflags", jb_compile_options_get_effective_cppflags(&jb_compile_options),
573
"group-cppflags", jb_compile_options_get_effective_cppflags(&gres->group->compile_options),
574
"object-cppflags", jb_compile_options_get_effective_cppflags(&object->compile_options),
575
"stock-cppflags", object_class->stock_cppflags,
576
"depsflags", depsflags,
586
object_file_clean (const char *ofile)
590
depsfile = object_file_get_depsfile(ofile);
593
jb_action_rm(depsfile);
598
G_DEFINE_TYPE(JBSource, jb_source, JB_TYPE_OBJECT_RESOURCE)
601
jb_source_new (const char *filename)
605
g_return_val_if_fail(filename != NULL, NULL);
607
self = g_object_new(JB_TYPE_SOURCE, NULL);
608
self->filename = g_strdup(filename);
614
source_to_string (JBResource *res)
616
JBSource *self = JB_SOURCE(res);
620
base_filename = g_path_get_basename(self->filename);
621
str = g_strdup_printf("C source %s", base_filename);
622
g_free(base_filename);
628
source_get_files (JBSource *self, char **ofile, char **cfile)
630
JBObjectResource *ores = JB_OBJECT_RESOURCE(self);
631
JBGroupResource *gres = JB_GROUP_RESOURCE(ores->object);
635
base_filename = g_path_get_basename(self->filename);
636
base_prefix = jb_strip_extension(base_filename);
639
*ofile = g_strdup_printf("%s/%s-%s.o",
640
gres->group->builddir,
644
*cfile = g_strdup_printf("%s/%s", gres->group->srcdir, self->filename);
646
g_free(base_filename);
651
source_build (JBResource *res)
653
JBObjectResource *ores = JB_OBJECT_RESOURCE(res);
654
JBSource *self = JB_SOURCE(res);
658
source_get_files(self, &ofile, &cfile);
660
if (! object_file_is_uptodate(ofile, cfile))
662
resource_message_building(res);
663
object_file_build(ores->object, ofile, cfile);
671
source_makedist (JBResource *res)
673
JBSource *self = JB_SOURCE(res);
676
source_get_files(self, NULL, &cfile);
678
jb_action_add_to_dist(cfile);
684
source_clean (JBResource *res)
686
JBSource *self = JB_SOURCE(res);
689
source_get_files(self, &ofile, NULL);
691
object_file_clean(ofile);
697
source_get_object_file (JBObjectResource *res)
699
JBSource *self = JB_SOURCE(res);
702
source_get_files(self, &ofile, NULL);
708
jb_source_init (JBSource *self)
713
jb_source_class_init (JBSourceClass *class)
715
JBResourceClass *rclass = JB_RESOURCE_CLASS(class);
716
JBObjectResourceClass *orclass = JB_OBJECT_RESOURCE_CLASS(class);
718
rclass->to_string = source_to_string;
719
rclass->build = source_build;
720
rclass->makedist = source_makedist;
721
rclass->clean = source_clean;
723
orclass->get_object_file = source_get_object_file;
726
G_DEFINE_TYPE(JBGobClass, jb_gob_class, JB_TYPE_OBJECT_RESOURCE)
729
jb_gob_class_new (const char *name)
733
g_return_val_if_fail(name != NULL, NULL);
734
g_return_val_if_fail(jb_feature_is_enabled(&jb_gob2_feature), NULL);
736
self = g_object_new(JB_TYPE_GOB_CLASS, NULL);
737
self->name = g_strdup(name);
743
gob_class_get_gob_files (JBGobClass *self, char **gobfile, char **stamp)
745
JBGroupResource *gres = JB_GROUP_RESOURCE(JB_OBJECT_RESOURCE(self)->object);
748
prefix = g_strdelimit(g_ascii_strdown(self->name, -1), ":", '-');
750
*gobfile = g_strdup_printf("%s/%s.gob", gres->group->srcdir, prefix);
752
*stamp = g_strdup_printf("%s/%s.gob.stamp", gres->group->builddir, prefix);
757
gob_class_pre_build (JBResource *res)
759
JBGobClass *self = JB_GOB_CLASS(res);
763
gob_class_get_gob_files(self, &gobfile, &stamp);
765
if (! jb_is_uptodate(stamp, gobfile))
767
JBObjectResource *ores = JB_OBJECT_RESOURCE(res);
768
JBGroupResource *gres = JB_GROUP_RESOURCE(ores->object);
771
error = jb_variable_get_string_or_null("gob2-error");
773
jb_error("%s", error);
775
jb_message("building GOB class %s", self->name);
777
jb_mkdir(gres->group->builddir);
779
jb_action_exec("$gob2 $package-gob2flags $group-gob2flags $object-gob2flags $gobfile",
780
"package-gob2flags", jb_compile_options.gob2flags->str,
781
"group-gob2flags", gres->group->compile_options.gob2flags->str,
782
"object-gob2flags", ores->object->compile_options.gob2flags->str,
786
jb_action_exec("touch $stamp",
796
gob_class_get_c_files (JBGobClass *self,
802
JBObjectResource *ores = JB_OBJECT_RESOURCE(self);
803
JBGroupResource *gres = JB_GROUP_RESOURCE(ores->object);
806
prefix = g_strdelimit(g_ascii_strdown(self->name, -1), ":", '-');
809
*ofile = g_strdup_printf("%s/%s-%s.o",
810
gres->group->builddir,
814
*cfile = g_strdup_printf("%s/%s.c", gres->group->builddir, prefix);
816
*hfile = g_strdup_printf("%s/%s.h", gres->group->builddir, prefix);
818
*phfile = g_strdup_printf("%s/%s-private.h", gres->group->builddir, prefix);
824
gob_class_build (JBResource *res)
826
JBGobClass *self = JB_GOB_CLASS(res);
830
gob_class_get_c_files(self, &ofile, &cfile, NULL, NULL);
832
if (! object_file_is_uptodate(ofile, cfile))
834
JBObjectResource *ores = JB_OBJECT_RESOURCE(res);
837
class_name = jb_strip_chars(self->name, ":");
838
jb_message("building class %s", class_name);
841
object_file_build(ores->object, ofile, cfile);
849
gob_class_makedist (JBResource *res)
851
JBGobClass *self = JB_GOB_CLASS(res);
858
gob_class_get_gob_files(self, &gobfile, &stamp);
859
gob_class_get_c_files(self, NULL, &cfile, &hfile, &phfile);
861
jb_action_add_to_dist(gobfile);
862
jb_action_add_to_dist(stamp);
863
jb_action_add_to_dist(cfile);
864
jb_action_add_to_dist(hfile);
865
jb_action_add_to_dist(phfile);
875
gob_class_clean (JBResource *res)
877
JBGobClass *self = JB_GOB_CLASS(res);
880
gob_class_get_c_files(self, &ofile, NULL, NULL, NULL);
882
object_file_clean(ofile);
888
gob_class_maintainerclean (JBResource *res)
890
JBGobClass *self = JB_GOB_CLASS(res);
896
gob_class_get_gob_files(self, NULL, &stamp);
897
gob_class_get_c_files(self, NULL, &cfile, &hfile, &phfile);
902
jb_action_rm(phfile);
911
gob_class_get_object_file (JBObjectResource *res)
913
JBGobClass *self = JB_GOB_CLASS(res);
916
gob_class_get_c_files(self, &ofile, NULL, NULL, NULL);
922
jb_gob_class_init (JBGobClass *self)
927
jb_gob_class_class_init (JBGobClassClass *class)
929
JBResourceClass *rclass = JB_RESOURCE_CLASS(class);
930
JBObjectResourceClass *orclass = JB_OBJECT_RESOURCE_CLASS(class);
932
rclass->pre_build = gob_class_pre_build;
933
rclass->build = gob_class_build;
934
rclass->makedist = gob_class_makedist;
935
rclass->clean = gob_class_clean;
936
rclass->maintainerclean = gob_class_maintainerclean;
938
orclass->get_object_file = gob_class_get_object_file;
941
G_DEFINE_TYPE(JBDBusInterfaceClient, jb_dbus_interface_client, JB_TYPE_GROUP_RESOURCE)
943
JBDBusInterfaceClient *
944
jb_dbus_interface_client_new (const char *name, const char *client)
946
JBDBusInterfaceClient *self;
948
g_return_val_if_fail(name != NULL, NULL);
949
g_return_val_if_fail(client != NULL, NULL);
950
g_return_val_if_fail(jb_feature_is_enabled(&jb_dbus_feature), NULL);
952
self = g_object_new(JB_TYPE_DBUS_INTERFACE_CLIENT, NULL);
953
self->name = g_strdup(name);
954
self->client = g_strdup(client);
960
dbus_interface_client_to_string (JBResource *res)
962
JBDBusInterfaceClient *self = JB_DBUS_INTERFACE_CLIENT(res);
964
return g_strdup_printf("client of D-Bus interface %s", self->name);
968
dbus_interface_client_get_files (JBDBusInterfaceClient *self,
972
JBGroupResource *gres = JB_GROUP_RESOURCE(self);
975
cprefix = jb_strdelimit(self->name, ".", '-');
977
*xmlfile = g_strdup_printf("%s/%s.xml", gres->group->srcdir, cprefix);
978
if (clientfile != NULL)
979
*clientfile = g_strdup_printf("%s/%s", gres->group->builddir, self->client);
984
dbus_interface_client_pre_build (JBResource *res)
986
JBDBusInterfaceClient *self = JB_DBUS_INTERFACE_CLIENT(res);
990
dbus_interface_client_get_files(self, &xmlfile, &clientfile);
992
if (! jb_is_uptodate(clientfile, xmlfile))
994
JBGroupResource *gres = JB_GROUP_RESOURCE(res);
996
resource_message_building(res);
998
jb_mkdir(gres->group->builddir);
1000
jb_action_exec("$dbus-binding-tool --mode=glib-client $xmlfile > $clientfile.tmp && mv -f $clientfile.tmp $clientfile",
1002
"clientfile", clientfile,
1011
dbus_interface_client_makedist (JBResource *res)
1013
JBDBusInterfaceClient *self = JB_DBUS_INTERFACE_CLIENT(res);
1016
dbus_interface_client_get_files(self, &xmlfile, NULL);
1018
jb_action_add_to_dist(xmlfile);
1024
dbus_interface_client_clean (JBResource *res)
1026
JBDBusInterfaceClient *self = JB_DBUS_INTERFACE_CLIENT(res);
1029
dbus_interface_client_get_files(self, NULL, &clientfile);
1031
jb_action_rm(clientfile);
1037
jb_dbus_interface_client_init (JBDBusInterfaceClient *self)
1042
jb_dbus_interface_client_class_init (JBDBusInterfaceClientClass *class)
1044
JBResourceClass *rclass = JB_RESOURCE_CLASS(class);
1046
rclass->to_string = dbus_interface_client_to_string;
1047
rclass->pre_build = dbus_interface_client_pre_build;
1048
rclass->makedist = dbus_interface_client_makedist;
1049
rclass->clean = dbus_interface_client_clean;
1052
G_DEFINE_TYPE(JBDBusInterfaceServer, jb_dbus_interface_server, JB_TYPE_GROUP_RESOURCE)
1054
JBDBusInterfaceServer *
1055
jb_dbus_interface_server_new (const char *name,
1057
const char *server_prefix)
1059
JBDBusInterfaceServer *self;
1061
g_return_val_if_fail(name != NULL, NULL);
1062
g_return_val_if_fail(server != NULL, NULL);
1063
g_return_val_if_fail(server_prefix != NULL, NULL);
1064
g_return_val_if_fail(jb_feature_is_enabled(&jb_dbus_feature), NULL);
1066
self = g_object_new(JB_TYPE_DBUS_INTERFACE_SERVER, NULL);
1067
self->name = g_strdup(name);
1068
self->server = g_strdup(server);
1069
self->server_prefix = g_strdup(server_prefix);
1075
dbus_interface_server_to_string (JBResource *res)
1077
JBDBusInterfaceServer *self = JB_DBUS_INTERFACE_SERVER(res);
1079
return g_strdup_printf("server of D-Bus interface %s", self->name);
1083
dbus_interface_server_get_files (JBDBusInterfaceServer *self,
1087
JBGroupResource *gres = JB_GROUP_RESOURCE(self);
1090
cprefix = jb_strdelimit(self->name, ".", '-');
1091
if (xmlfile != NULL)
1092
*xmlfile = g_strdup_printf("%s/%s.xml", gres->group->srcdir, cprefix);
1093
if (serverfile != NULL)
1094
*serverfile = g_strdup_printf("%s/%s", gres->group->builddir, self->server);
1099
dbus_interface_server_pre_build (JBResource *res)
1101
JBDBusInterfaceServer *self = JB_DBUS_INTERFACE_SERVER(res);
1105
dbus_interface_server_get_files(self, &xmlfile, &serverfile);
1107
if (! jb_is_uptodate(serverfile, xmlfile))
1109
JBGroupResource *gres = JB_GROUP_RESOURCE(res);
1111
resource_message_building(res);
1113
jb_mkdir(gres->group->builddir);
1115
jb_action_exec("$dbus-binding-tool --mode=glib-server --prefix=$server-prefix $xmlfile > $serverfile.tmp && mv -f $serverfile.tmp $serverfile",
1116
"server-prefix", self->server_prefix,
1118
"serverfile", serverfile,
1127
dbus_interface_server_makedist (JBResource *res)
1129
JBDBusInterfaceServer *self = JB_DBUS_INTERFACE_SERVER(res);
1132
dbus_interface_server_get_files(self, &xmlfile, NULL);
1134
jb_action_add_to_dist(xmlfile);
1140
dbus_interface_server_clean (JBResource *res)
1142
JBDBusInterfaceServer *self = JB_DBUS_INTERFACE_SERVER(res);
1145
dbus_interface_server_get_files(self, NULL, &serverfile);
1147
jb_action_rm(serverfile);
1153
jb_dbus_interface_server_init (JBDBusInterfaceServer *self)
1158
jb_dbus_interface_server_class_init (JBDBusInterfaceServerClass *class)
1160
JBResourceClass *rclass = JB_RESOURCE_CLASS(class);
1162
rclass->to_string = dbus_interface_server_to_string;
1163
rclass->pre_build = dbus_interface_server_pre_build;
1164
rclass->makedist = dbus_interface_server_makedist;
1165
rclass->clean = dbus_interface_server_clean;
1168
G_DEFINE_TYPE(JBIntltoolFile, jb_intltool_file, JB_TYPE_GROUP_RESOURCE)
1171
jb_intltool_file_new (const char *type,
1172
const char *filename,
1173
const char *merge_flags)
1175
JBIntltoolFile *self;
1177
g_return_val_if_fail(type != NULL, NULL);
1178
g_return_val_if_fail(filename != NULL, NULL);
1179
g_return_val_if_fail(g_str_has_suffix(filename, ".in"), NULL);
1180
g_return_val_if_fail(merge_flags != NULL, NULL);
1182
self = g_object_new(JB_TYPE_INTLTOOL_FILE, NULL);
1183
self->type = g_strdup(type);
1184
self->filename = g_strdup(filename);
1185
self->merge_flags = g_strdup(merge_flags);
1191
intltool_file_to_string (JBResource *res)
1193
JBIntltoolFile *self = JB_INTLTOOL_FILE(res);
1195
return g_strdup_printf("%s %s", self->type, self->filename);
1199
intltool_file_get_files (JBIntltoolFile *self, char **infile, char **outfile)
1201
JBGroupResource *gres = JB_GROUP_RESOURCE(self);
1204
filename = g_strdup_printf("%s/%s", gres->group->srcdir, self->filename);
1207
*infile = get_input_file(filename);
1208
if (outfile != NULL)
1209
*outfile = get_output_file(filename);
1215
intltool_file_build (JBResource *res)
1217
JBIntltoolFile *self = JB_INTLTOOL_FILE(res);
1220
GSList *deps = NULL;
1222
if (! jb_is_uptodate(INTLTOOL_MERGE_OUT, INTLTOOL_MERGE_IN))
1224
GHashTable *variables;
1226
jb_message("building intltool-merge");
1228
jb_mkdir_of_file(INTLTOOL_MERGE_OUT);
1230
variables = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
1231
g_hash_table_insert(variables, "INTLTOOL_PERL", jb_variable_expand("$perl", NULL));
1232
g_hash_table_insert(variables, "INTLTOOL_LIBDIR", jb_variable_expand("$perl", NULL));
1234
jb_subst(INTLTOOL_MERGE_IN, INTLTOOL_MERGE_OUT, variables);
1236
g_hash_table_destroy(variables);
1238
jb_chmod(INTLTOOL_MERGE_OUT, 0755);
1241
intltool_file_get_files(self, &infile, &outfile);
1243
deps = g_slist_append(deps, g_strdup(infile));
1244
deps = g_slist_append(deps, g_strdup(INTLTOOL_MERGE_OUT));
1245
deps = g_slist_concat(deps, jb_match_files("po/*.po"));
1247
if (! jb_is_uptodate_list(outfile, deps))
1249
resource_message_building(res);
1251
jb_mkdir_of_file(outfile);
1252
jb_mkdir_of_file(INTLTOOL_MERGE_CACHE);
1254
jb_action_exec("LC_ALL=C " INTLTOOL_MERGE_OUT " $merge-flags -u -c " INTLTOOL_MERGE_CACHE " po $infile $outfile",
1255
"merge-flags", self->merge_flags,
1263
jb_g_slist_free_deep(deps);
1267
intltool_file_install (JBResource *res)
1269
JBIntltoolFile *self = JB_INTLTOOL_FILE(res);
1272
intltool_file_get_files(self, NULL, &outfile);
1274
jb_install_options_install_data(&self->install_options, outfile, NULL);
1280
intltool_file_makedist (JBResource *res)
1282
JBIntltoolFile *self = JB_INTLTOOL_FILE(res);
1283
JBGroupResource *gres = JB_GROUP_RESOURCE(res);
1286
filename = g_strdup_printf("%s/%s", gres->group->srcdir, self->filename);
1288
jb_action_add_to_dist(INTLTOOL_MERGE_IN);
1290
if (! has_template(filename))
1291
jb_action_add_to_dist(filename);
1297
intltool_file_clean (JBResource *res)
1299
JBIntltoolFile *self = JB_INTLTOOL_FILE(res);
1302
intltool_file_get_files(self, NULL, &outfile);
1304
jb_action_rm(INTLTOOL_MERGE_OUT);
1305
jb_action_rm(INTLTOOL_MERGE_CACHE);
1306
jb_action_rm(outfile);
1312
intltool_file_maintainerclean (JBResource *res)
1314
jb_action_rm(INTLTOOL_MERGE_IN);
1318
jb_intltool_file_init (JBIntltoolFile *self)
1320
jb_install_options_init(&self->install_options);
1324
jb_intltool_file_class_init (JBIntltoolFileClass *class)
1326
JBResourceClass *rclass = JB_RESOURCE_CLASS(class);
1328
rclass->to_string = intltool_file_to_string;
1329
rclass->build = intltool_file_build;
1330
rclass->install = intltool_file_install;
1331
rclass->makedist = intltool_file_makedist;
1332
rclass->clean = intltool_file_clean;
1333
rclass->maintainerclean = intltool_file_maintainerclean;
1336
G_DEFINE_TYPE(JBGnomeHelp, jb_gnome_help, JB_TYPE_GROUP_RESOURCE)
1339
jb_gnome_help_new (const char *lang, const char *entities)
1343
g_return_val_if_fail(lang != NULL, NULL);
1344
g_return_val_if_fail(jb_feature_is_enabled(&jb_gnome_help_feature), NULL);
1346
self = g_object_new(JB_TYPE_GNOME_HELP, NULL);
1347
self->name = g_strdup(jb_variable_get_string("package"));
1348
self->lang = g_strdup(lang);
1349
self->entities = g_strsplit(entities != NULL ? entities : "", " ", 0);
1355
gnome_help_to_string (JBResource *res)
1357
JBGnomeHelp *self = JB_GNOME_HELP(res);
1359
return g_strdup_printf("GNOME help %s [%s]", self->name, self->lang);
1363
gnome_help_get_files (JBGnomeHelp *self,
1371
JBGroupResource *gres = JB_GROUP_RESOURCE(self);
1374
_inomf = g_strdup_printf("%s/%s/%s-%s.omf.in",
1375
gres->group->srcdir,
1381
*inomf = g_strdup(_inomf);
1383
*outomf = get_output_file(_inomf);
1384
if (helpdir != NULL)
1385
*helpdir = jb_variable_expand("$help-dir/$name/$lang",
1389
if (xmlfile != NULL)
1390
*xmlfile = g_strdup_printf("%s/%s/%s.xml",
1391
gres->group->srcdir,
1394
if (entities != NULL)
1397
GSList *list = NULL;
1399
for (i = 0; self->entities[i] != NULL; i++)
1400
list = g_slist_append(list, g_strdup_printf("%s/%s/%s",
1401
gres->group->srcdir,
1403
self->entities[i]));
1407
if (figures != NULL)
1411
pattern = g_strdup_printf("%s/%s/figures/*.png",
1412
gres->group->srcdir,
1414
*figures = jb_match_files(pattern);
1422
gnome_help_build (JBResource *res)
1424
JBGnomeHelp *self = JB_GNOME_HELP(res);
1429
gnome_help_get_files(self, &inomf, &outomf, &helpdir, NULL, NULL, NULL);
1431
if (! jb_is_uptodate(outomf, inomf))
1433
resource_message_building(res);
1435
jb_mkdir_of_file(outomf);
1437
jb_action_exec("$scrollkeeper-preinstall \"$helpdir/$helpname.xml\" $inomf $outomf",
1439
"helpname", self->name,
1451
gnome_help_install (JBResource *res)
1453
JBGnomeHelp *self = JB_GNOME_HELP(res);
1462
gnome_help_get_files(self, NULL, &outomf, &helpdir, &xmlfile, &entities, &figures);
1464
omfdir = g_strdup_printf("$omf-dir/%s", self->name);
1466
figdir = g_strdup_printf("%s/figures", helpdir);
1468
jb_action_install_data(xmlfile, helpdir);
1470
jb_action_install_data_list(entities, helpdir);
1472
jb_action_install_data_list(figures, figdir);
1474
jb_action_install_data(outomf, omfdir);
1476
jb_action_exec("-$scrollkeeper-update -p \"$destdir$scrollkeeper-dir\" -o \"$destdir$omfdir\"",
1484
jb_g_slist_free_deep(entities);
1485
jb_g_slist_free_deep(figures);
1490
gnome_help_makedist (JBResource *res)
1492
JBGnomeHelp *self = JB_GNOME_HELP(res);
1498
gnome_help_get_files(self, &inomf, NULL, NULL, &xmlfile, &entities, &figures);
1500
jb_action_add_to_dist(inomf);
1501
jb_action_add_to_dist(xmlfile);
1502
jb_action_add_to_dist_list(entities);
1503
jb_action_add_to_dist_list(figures);
1507
jb_g_slist_free_deep(entities);
1508
jb_g_slist_free_deep(figures);
1512
gnome_help_clean (JBResource *res)
1514
JBGnomeHelp *self = JB_GNOME_HELP(res);
1517
gnome_help_get_files(self, NULL, &outomf, NULL, NULL, NULL, NULL);
1519
jb_action_rm(outomf);
1525
jb_gnome_help_init (JBGnomeHelp *self)
1530
jb_gnome_help_class_init (JBGnomeHelpClass *class)
1532
JBResourceClass *rclass = JB_RESOURCE_CLASS(class);
1534
rclass->to_string = gnome_help_to_string;
1535
rclass->build = gnome_help_build;
1536
rclass->install = gnome_help_install;
1537
rclass->makedist = gnome_help_makedist;
1538
rclass->clean = gnome_help_clean;
1541
G_DEFINE_TYPE(JBTranslations, jb_translations, JB_TYPE_GROUP_RESOURCE)
1544
translations_get_files (JBTranslations *self, char **infile, char **outfile)
1546
JBGroupResource *gres = JB_GROUP_RESOURCE(self);
1549
*infile = g_strdup_printf("%s/%s.po", gres->group->srcdir, self->lang);
1550
if (outfile != NULL)
1551
*outfile = g_strdup_printf("%s/%s.mo", gres->group->builddir, self->lang);
1555
jb_translations_new (const char *lang)
1557
JBTranslations *self;
1559
g_return_val_if_fail(lang != NULL, NULL);
1560
g_return_val_if_fail(jb_feature_is_enabled(&jb_gettext_feature), NULL);
1562
self = g_object_new(JB_TYPE_TRANSLATIONS, NULL);
1563
self->lang = g_strdup(lang);
1569
translations_to_string (JBResource *res)
1571
JBTranslations *self = JB_TRANSLATIONS(res);
1573
return g_strdup_printf("%s translations", self->lang);
1577
translations_build (JBResource *res)
1579
JBTranslations *self = JB_TRANSLATIONS(res);
1583
translations_get_files(self, &infile, &outfile);
1585
if (! jb_is_uptodate(outfile, infile))
1587
resource_message_building(res);
1589
jb_mkdir_of_file(outfile);
1591
jb_action_exec("$msgfmt -o $outfile.tmp $infile && mv -f $outfile.tmp $outfile",
1602
translations_install (JBResource *res)
1604
JBTranslations *self = JB_TRANSLATIONS(res);
1608
translations_get_files(self, NULL, &outfile);
1610
installfile = g_strdup_printf("$prefix/share/locale/%s/LC_MESSAGES/$package.mo", self->lang);
1612
jb_action_install_data_to_file(outfile, installfile);
1615
g_free(installfile);
1619
translations_makedist (JBResource *res)
1621
JBTranslations *self = JB_TRANSLATIONS(res);
1624
translations_get_files(self, &infile, NULL);
1626
jb_action_add_to_dist(infile);
1632
translations_clean (JBResource *res)
1634
JBTranslations *self = JB_TRANSLATIONS(res);
1637
translations_get_files(self, NULL, &outfile);
1639
jb_action_rm(outfile);
1645
jb_translations_init (JBTranslations *self)
1650
jb_translations_class_init (JBTranslationsClass *class)
1652
JBResourceClass *rclass = JB_RESOURCE_CLASS(class);
1654
rclass->to_string = translations_to_string;
1655
rclass->build = translations_build;
1656
rclass->install = translations_install;
1657
rclass->makedist = translations_makedist;
1658
rclass->clean = translations_clean;
1661
G_DEFINE_TYPE(JBRule, jb_rule, JB_TYPE_GROUP_RESOURCE)
1666
return g_object_new(JB_TYPE_RULE, NULL);
1670
* This could be inferred by mapping input files to the resources that
1671
* produce them, but it would require a more complex JBResource
1672
* design. For now this is good enough.
1675
jb_rule_add_dependency (JBRule *self, JBGroupResource *res)
1677
g_return_if_fail(JB_IS_RULE(self));
1678
g_return_if_fail(JB_IS_GROUP_RESOURCE(res));
1680
self->dependencies = g_slist_append(self->dependencies, g_object_ref(res));
1684
jb_rule_add_input_file (JBRule *self, const char *format, ...)
1688
g_return_if_fail(JB_IS_RULE(self));
1689
g_return_if_fail(format != NULL);
1691
va_start(args, format);
1692
self->input_files = g_slist_append(self->input_files, g_strdup_vprintf(format, args));
1697
jb_rule_add_output_file (JBRule *self, const char *format, ...)
1701
g_return_if_fail(JB_IS_RULE(self));
1702
g_return_if_fail(format != NULL);
1704
va_start(args, format);
1705
self->output_files = g_slist_append(self->output_files, g_strdup_vprintf(format, args));
1710
jb_rule_set_build_message (JBRule *self, const char *format, ...)
1714
g_return_if_fail(JB_IS_RULE(self));
1715
g_return_if_fail(format != NULL);
1717
g_free(self->build_message);
1719
va_start(args, format);
1720
self->build_message = g_strdup_vprintf(format, args);
1725
jb_rule_add_build_command (JBRule *self, const char *format, ...)
1729
g_return_if_fail(JB_IS_RULE(self));
1730
g_return_if_fail(format != NULL);
1732
va_start(args, format);
1733
self->build_commands = g_slist_append(self->build_commands, g_strdup_vprintf(format, args));
1738
jb_rule_set_install_message (JBRule *self, const char *format, ...)
1742
g_return_if_fail(JB_IS_RULE(self));
1743
g_return_if_fail(format != NULL);
1745
g_free(self->install_message);
1747
va_start(args, format);
1748
self->install_message = g_strdup_vprintf(format, args);
1753
jb_rule_add_install_command (JBRule *self, const char *format, ...)
1757
g_return_if_fail(JB_IS_RULE(self));
1758
g_return_if_fail(format != NULL);
1760
va_start(args, format);
1761
self->install_commands = g_slist_append(self->install_commands, g_strdup_vprintf(format, args));
1766
rule_expand_variables (JBRule *self, GSList *strings)
1768
JBGroupResource *gres = JB_GROUP_RESOURCE(self);
1769
GSList *result = NULL;
1772
JB_LIST_FOREACH(l, strings)
1774
const char *str = l->data;
1777
expanded = jb_variable_expand(str,
1778
"srcdir", gres->group->srcdir,
1779
"builddir", gres->group->builddir,
1782
result = g_slist_append(result, expanded);
1789
rule_perform (JBRule *self, const char *message, GSList *commands)
1791
JBGroupResource *gres = JB_GROUP_RESOURCE(self);
1794
if (commands == NULL)
1797
jb_message("%s", message);
1799
JB_LIST_FOREACH(l, commands)
1801
const char *command = l->data;
1803
jb_action_exec(command,
1804
"srcdir", gres->group->srcdir,
1805
"builddir", gres->group->builddir,
1811
rule_build (JBResource *res)
1813
JBRule *self = JB_RULE(res);
1816
JB_LIST_FOREACH(l, self->dependencies)
1818
JBResource *dep = l->data;
1819
jb_resource_build(dep);
1822
if (self->output_files != NULL)
1824
GSList *input_files;
1825
GSList *output_files;
1826
gboolean is_uptodate;
1828
input_files = rule_expand_variables(self, self->input_files);
1829
output_files = rule_expand_variables(self, self->output_files);
1831
is_uptodate = jb_is_uptodate_list_list(output_files, input_files);
1833
jb_g_slist_free_deep(input_files);
1834
jb_g_slist_free_deep(output_files);
1840
rule_perform(self, self->build_message, self->build_commands);
1844
rule_install (JBResource *res)
1846
JBRule *self = JB_RULE(res);
1848
rule_perform(self, self->install_message, self->install_commands);
1852
rule_clean (JBResource *res)
1854
JBRule *self = JB_RULE(res);
1855
GSList *output_files;
1857
output_files = rule_expand_variables(self, self->output_files);
1859
jb_action_rm_list(output_files);
1861
jb_g_slist_free_deep(output_files);
1865
jb_rule_init (JBRule *self)
1870
jb_rule_class_init (JBRuleClass *class)
1872
JBResourceClass *rclass = JB_RESOURCE_CLASS(class);
1874
rclass->build = rule_build;
1875
rclass->install = rule_install;
1876
rclass->clean = rule_clean;
1879
G_DEFINE_ABSTRACT_TYPE(JBObject, jb_object, JB_TYPE_GROUP_RESOURCE)
1882
object_to_string (JBResource *res)
1884
JBObject *self = JB_OBJECT(res);
1885
JBObjectClass *class = JB_OBJECT_GET_CLASS(self);
1887
return g_strdup_printf("%s %s", class->type, self->name);
1891
object_get_output_file (JBObject *self)
1893
JBObjectClass *class;
1895
g_return_val_if_fail(JB_IS_OBJECT(self), NULL);
1897
class = JB_OBJECT_GET_CLASS(self);
1899
if (class->get_output_file != NULL)
1900
return class->get_output_file(self);
1903
g_error("get_output_file() not implemented for object type %s", G_OBJECT_TYPE_NAME(self));
1909
object_get_object_files (JBObject *self)
1911
GSList *list = NULL;
1914
JB_LIST_FOREACH(l, self->resources)
1915
list = g_slist_append(list, object_resource_get_object_file(l->data));
1921
object_get_headers (JBObject *self)
1923
JBGroupResource *gres = JB_GROUP_RESOURCE(self);
1924
GSList *list = NULL;
1927
JB_LIST_FOREACH(l, self->headers)
1929
const char *header = l->data;
1931
list = g_slist_append(list, g_strdup_printf("%s/%s",
1932
gres->group->srcdir,
1940
object_pre_build (JBResource *res)
1942
JBObject *self = JB_OBJECT(res);
1945
JB_LIST_FOREACH(l, self->resources)
1946
jb_resource_pre_build(l->data);
1950
object_build (JBResource *res)
1952
JBObject *self = JB_OBJECT(res);
1954
GSList *object_files_list;
1957
JB_LIST_FOREACH(l, self->resources)
1958
jb_resource_build(l->data);
1960
outfile = object_get_output_file(self);
1961
object_files_list = object_get_object_files(self);
1963
if (! jb_is_uptodate_list(outfile, object_files_list))
1965
JBGroupResource *gres = JB_GROUP_RESOURCE(self);
1966
JBObjectClass *object_class;
1969
resource_message_building(res);
1971
object_class = JB_OBJECT_GET_CLASS(self);
1973
object_files = jb_string_list_join(object_files_list, " ");
1975
jb_mkdir(gres->group->builddir);
1977
jb_action_exec("$cc $package-cflags $group-cflags $object-cflags $cflags"
1978
" $package-ldflags $group-ldflags $object-ldflags $stock-ldflags $ldflags"
1979
" -o $outfile $object-files",
1980
"package-cflags", jb_compile_options.cflags->str,
1981
"group-cflags", gres->group->compile_options.cflags->str,
1982
"object-cflags", self->compile_options.cflags->str,
1983
"package-ldflags", jb_compile_options.ldflags->str,
1984
"group-ldflags", gres->group->compile_options.ldflags->str,
1985
"object-ldflags", self->compile_options.ldflags->str,
1986
"stock-ldflags", object_class->stock_ldflags,
1988
"object-files", object_files,
1991
g_free(object_files);
1995
jb_g_slist_free_deep(object_files_list);
1999
object_makedist (JBResource *res)
2001
JBObject *self = JB_OBJECT(res);
2005
JB_LIST_FOREACH(l, self->resources)
2006
jb_resource_makedist(l->data);
2008
headers = object_get_headers(self);
2009
jb_action_add_to_dist_list(headers);
2010
jb_g_slist_free_deep(headers);
2014
object_clean (JBResource *res)
2016
JBObject *self = JB_OBJECT(res);
2020
JB_LIST_FOREACH(l, self->resources)
2021
jb_resource_clean(l->data);
2023
outfile = object_get_output_file(self);
2025
jb_action_rm(outfile);
2031
object_distclean (JBResource *res)
2033
JBObject *self = JB_OBJECT(res);
2036
JB_LIST_FOREACH(l, self->resources)
2037
jb_resource_distclean(l->data);
2041
object_maintainerclean (JBResource *res)
2043
JBObject *self = JB_OBJECT(res);
2046
JB_LIST_FOREACH(l, self->resources)
2047
jb_resource_maintainerclean(l->data);
2051
object_add_resource (JBObject *self, JBObjectResource *res)
2053
g_return_if_fail(JB_IS_OBJECT(self));
2054
g_return_if_fail(JB_IS_OBJECT_RESOURCE(res));
2055
g_return_if_fail(res->object == NULL);
2059
self->resources = g_slist_append(self->resources, res);
2063
object_add_header (JBObject *self, const char *filename)
2065
g_return_if_fail(JB_IS_OBJECT(self));
2066
g_return_if_fail(filename != NULL);
2068
self->headers = g_slist_append(self->headers, g_strdup(filename));
2072
jb_object_add_source (JBObject *self, const char *name)
2074
g_return_if_fail(JB_IS_OBJECT(self));
2075
g_return_if_fail(name != NULL);
2077
if (strchr(name, ':') != NULL)
2078
object_add_resource(self, JB_OBJECT_RESOURCE(jb_gob_class_new(name)));
2079
else if (strchr(name, '.') == NULL)
2084
cfile = g_strdup_printf("%s.c", name);
2085
hfile = g_strdup_printf("%s.h", name);
2087
object_add_resource(self, JB_OBJECT_RESOURCE(jb_source_new(cfile)));
2088
object_add_header(self, hfile);
2095
if (g_str_has_suffix(name, ".c"))
2096
object_add_resource(self, JB_OBJECT_RESOURCE(jb_source_new(name)));
2097
else if (g_str_has_suffix(name, ".h"))
2098
object_add_header(self, name);
2100
g_error("the extension of source file \"%s\" is not .c or .h", name);
2105
jb_object_add_sources (JBObject *self, const char *name, ...)
2109
g_return_if_fail(JB_IS_OBJECT(self));
2111
va_start(args, name);
2113
while (name != NULL)
2115
jb_object_add_source(self, name);
2116
name = va_arg(args, const char *);
2123
jb_object_init (JBObject *self)
2125
jb_compile_options_init(&self->compile_options);
2126
jb_install_options_init(&self->install_options);
2130
jb_object_class_init (JBObjectClass *class)
2132
JBResourceClass *rclass = JB_RESOURCE_CLASS(class);
2134
rclass->to_string = object_to_string;
2135
rclass->pre_build = object_pre_build;
2136
rclass->build = object_build;
2137
rclass->makedist = object_makedist;
2138
rclass->clean = object_clean;
2139
rclass->distclean = object_distclean;
2140
rclass->maintainerclean = object_maintainerclean;
2143
G_DEFINE_TYPE(JBProgram, jb_program, JB_TYPE_OBJECT)
2146
jb_program_new (const char *name)
2150
g_return_val_if_fail(name != NULL, NULL);
2152
self = g_object_new(JB_TYPE_PROGRAM, NULL);
2153
JB_OBJECT(self)->name = g_strdup(name);
2159
program_install (JBResource *res)
2161
JBObject *object = JB_OBJECT(res);
2164
outfile = object_get_output_file(object);
2166
jb_install_options_install_program(&object->install_options, outfile, NULL);
2172
program_get_output_file (JBObject *object)
2174
JBGroupResource *gres = JB_GROUP_RESOURCE(object);
2176
return g_strdup_printf("%s/%s", gres->group->builddir, object->name);
2180
jb_program_init (JBProgram *self)
2182
JBObject *object = JB_OBJECT(self);
2184
jb_install_options_set_installdir(&object->install_options, "$bindir");
2188
jb_program_class_init (JBProgramClass *class)
2190
JBResourceClass *rclass = JB_RESOURCE_CLASS(class);
2191
JBObjectClass *oclass = JB_OBJECT_CLASS(class);
2193
rclass->install = program_install;
2195
oclass->type = "program";
2196
oclass->get_output_file = program_get_output_file;
2199
G_DEFINE_TYPE(JBModule, jb_module, JB_TYPE_OBJECT)
2202
jb_module_new (const char *name)
2206
g_return_val_if_fail(name != NULL, NULL);
2208
self = g_object_new(JB_TYPE_MODULE, NULL);
2209
JB_OBJECT(self)->name = g_strdup(name);
2215
module_install (JBResource *res)
2217
JBObject *object = JB_OBJECT(res);
2220
outfile = object_get_output_file(object);
2222
jb_install_options_install_library(&object->install_options, outfile, NULL);
2228
module_get_output_file (JBObject *object)
2230
JBGroupResource *gres = JB_GROUP_RESOURCE(object);
2232
return g_strdup_printf("%s/%s.so", gres->group->builddir, object->name);
2236
jb_module_init (JBModule *self)
2238
JBObject *object = JB_OBJECT(self);
2240
jb_install_options_set_installdir(&object->install_options, "$pkglibdir");
2244
jb_module_class_init (JBModuleClass *class)
2246
JBResourceClass *rclass = JB_RESOURCE_CLASS(class);
2247
JBObjectClass *oclass = JB_OBJECT_CLASS(class);
2249
rclass->install = module_install;
2251
oclass->type = "module";
2252
oclass->stock_cflags = "-fPIC";
2253
oclass->stock_cppflags = "-DPIC";
2254
oclass->stock_ldflags = "-shared -fPIC";
2255
oclass->get_output_file = module_get_output_file;