mirror of
https://github.com/pygos/pkg-utils.git
synced 2024-11-24 13:40:41 +01:00
Add option to buildstrategy to produce a dot graph
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
This commit is contained in:
parent
52f7bdc5c8
commit
4d48e374d8
3 changed files with 48 additions and 5 deletions
|
@ -91,10 +91,11 @@ static const struct option long_opts[] = {
|
|||
{ "prefere", required_argument, NULL, 'P' },
|
||||
{ "provides", required_argument, NULL, 'p' },
|
||||
{ "depends", required_argument, NULL, 'd' },
|
||||
{ "graph", no_argument, NULL, 'g' },
|
||||
{ NULL, 0, NULL, 0 },
|
||||
};
|
||||
|
||||
static const char *short_opts = "p:d:P:";
|
||||
static const char *short_opts = "p:d:P:g";
|
||||
|
||||
static void pkg_mark_deps(source_pkg_t *pkg)
|
||||
{
|
||||
|
@ -114,7 +115,7 @@ static void pkg_mark_deps(source_pkg_t *pkg)
|
|||
static int cmd_buildstrategy(int argc, char **argv)
|
||||
{
|
||||
const char *provides = NULL, *depends = NULL, *prefere = NULL;
|
||||
int i, ret = EXIT_FAILURE;
|
||||
int i, ret = EXIT_FAILURE, mode = MODE_BUILD_ORDER;
|
||||
source_pkg_t *pkg;
|
||||
|
||||
if (src_pkg_init())
|
||||
|
@ -138,6 +139,9 @@ static int cmd_buildstrategy(int argc, char **argv)
|
|||
case 'd':
|
||||
depends = optarg;
|
||||
break;
|
||||
case 'g':
|
||||
mode = MODE_BUILD_GRAPH;
|
||||
break;
|
||||
default:
|
||||
goto fail_arg;
|
||||
}
|
||||
|
@ -170,8 +174,17 @@ static int cmd_buildstrategy(int argc, char **argv)
|
|||
pkg_mark_deps(pkg);
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case MODE_BUILD_GRAPH:
|
||||
fputs("digraph buildgraph {\n\tcompound=true;\n", stdout);
|
||||
src_pkg_print_graph_cluster();
|
||||
fputs("}\n", stdout);
|
||||
break;
|
||||
default:
|
||||
if (src_pkg_output_build_order())
|
||||
goto out;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = EXIT_SUCCESS;
|
||||
out:
|
||||
|
@ -209,7 +222,9 @@ static command_t buildstrategy = {
|
|||
" produces this binary. If the `--provides` file\n"
|
||||
" specifies that more than one source pacakge\n"
|
||||
" provides a binary package, this file contains the\n"
|
||||
" prefered one we should use.\n",
|
||||
" prefered one we should use.\n"
|
||||
" --graph, -g Instead of printing out an ordered list, produce\n"
|
||||
" a dot graph of the source packages to be built.\n",
|
||||
.run_cmd = cmd_buildstrategy,
|
||||
};
|
||||
|
||||
|
|
|
@ -17,6 +17,11 @@ enum {
|
|||
FLAG_BUILD_PKG = 0x01,
|
||||
};
|
||||
|
||||
enum {
|
||||
MODE_BUILD_ORDER = 0,
|
||||
MODE_BUILD_GRAPH,
|
||||
};
|
||||
|
||||
typedef struct source_pkg_t {
|
||||
struct source_pkg_t *next;
|
||||
char *name;
|
||||
|
@ -45,4 +50,6 @@ int provider_add_prefered(const char *binpkg, const char *sourcepkg);
|
|||
|
||||
source_pkg_t *provider_get(const char *parent, const char *binpkg);
|
||||
|
||||
void src_pkg_print_graph_cluster(void);
|
||||
|
||||
#endif /* BUILDSTRATEGY_H */
|
||||
|
|
|
@ -122,3 +122,24 @@ int src_pkg_output_build_order(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int print_cluster(void *usr, const char *name, void *p)
|
||||
{
|
||||
source_pkg_t *pkg = p;
|
||||
size_t i;
|
||||
(void)usr;
|
||||
|
||||
if (!(pkg->flags & FLAG_BUILD_PKG))
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < pkg->num_depends; ++i) {
|
||||
printf("\t\"%s\" -> \"%s\"\n",
|
||||
name, pkg->depends[i]->name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void src_pkg_print_graph_cluster(void)
|
||||
{
|
||||
hash_table_foreach(&tbl_sourcepkgs, NULL, print_cluster);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue