summaryrefslogtreecommitdiffstats
path: root/scripts/ptx-modifications/0001-conf-add-an-option-to-output-the-dependency-informat.patch
blob: 56b538d55dd13a352a8ab051ea0856fa3e3a6bc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
From: Michael Olbrich <m.olbrich@pengutronix.de>
Date: Mon, 1 Nov 2010 19:49:21 +0100
Subject: [PATCH] conf: add an option to output the dependency information

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
 scripts/kconfig/conf.c | 47 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index ef3678c24bab..c51086a37d4b 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -33,6 +33,7 @@ enum input_mode {
 	savedefconfig,
 	listnewconfig,
 	olddefconfig,
+	writedepend,
 };
 static enum input_mode input_mode = oldaskconfig;
 
@@ -447,6 +448,42 @@ static void check_conf(struct menu *menu)
 		check_conf(child);
 }
 
+static void create_dep_output()
+{
+	int i;
+	bool hit;
+	const char *filename;
+	struct symbol *sym;
+	struct property *prop;
+
+	for_all_symbols(i, sym) {
+		if ((sym_get_tristate_value(sym) == no) || !sym->name)
+			continue;
+
+		hit = 0;
+		filename = NULL;
+		for (prop = sym->prop; prop; prop = prop->next) {
+			if (prop->type == P_SELECT && expr_calc_value(prop->visible.expr))
+				hit=1;
+			if (prop->type == P_SYMBOL)
+				filename = prop->menu->file->name;
+			if (filename && hit)
+				break;
+		}
+		if (filename)
+			printf("SOURCE:%s:%s\n", sym->name, filename);
+		if (!hit)
+			continue;
+		printf("DEP:%s", sym->name);
+		for (prop = sym->prop; prop; prop = prop->next) {
+			if (prop->type == P_SELECT && expr_calc_value(prop->visible.expr)) {
+				printf(":%s", prop->expr->left.sym->name);
+			}
+		}
+		printf("\n");
+	}
+}
+
 static struct option long_opts[] = {
 	{"oldaskconfig",    no_argument,       NULL, oldaskconfig},
 	{"oldconfig",       no_argument,       NULL, oldconfig},
@@ -460,6 +497,7 @@ static struct option long_opts[] = {
 	{"randconfig",      no_argument,       NULL, randconfig},
 	{"listnewconfig",   no_argument,       NULL, listnewconfig},
 	{"olddefconfig",    no_argument,       NULL, olddefconfig},
+	{"writedepend",     no_argument,       NULL, writedepend},
 	{NULL, 0, NULL, 0}
 };
 
@@ -489,6 +527,7 @@ int main(int ac, char **av)
 	int opt;
 	const char *name, *defconfig_file = NULL /* gcc uninit */;
 	int no_conf_write = 0;
+	int dep_output = 0;
 
 	tty_stdio = isatty(0) && isatty(1);
 
@@ -497,6 +536,10 @@ int main(int ac, char **av)
 			conf_set_message_callback(NULL);
 			continue;
 		}
+		if (opt == writedepend) {
+			dep_output = 1;
+			continue;
+		}
 		input_mode = (enum input_mode)opt;
 		switch (opt) {
 		case syncconfig:
@@ -698,5 +741,9 @@ int main(int ac, char **av)
 			return 1;
 		}
 	}
+
+	if (dep_output)
+		create_dep_output();
+
 	return 0;
 }