summaryrefslogtreecommitdiff
path: root/menuselect
diff options
context:
space:
mode:
authorGeorge Joseph <george.joseph@fairview5.com>2016-03-12 15:02:20 -0700
committerGeorge Joseph <george.joseph@fairview5.com>2016-03-13 15:11:39 -0600
commit0af6b5de620a89645372e4ac7e00bcd27221ad96 (patch)
treec500ecd1d58aebdd56b57df15687a07e07883359 /menuselect
parentb12980011abed533eea13d1d3b80faed331a1f1e (diff)
build_system: Split COMPILE_DOUBLE from DONT_OPTIMIZE
I can't ever recall actually needing the intermediate files or the checking that a double compile produces. What I CAN remember is every DONT_OPTIMIZE build needing 3 invocations of gcc instead of 1 just to do the checks and produce those intermediate files. Having said that, Richard pointed out that the reason for the double compile was that there were cases in the past where a submitted patch failed to compile because the submitter never tried it with the optimizations turned on. To get the best of both worlds, COMPILE_DOUBLE has been split into its own option. If DONT_OPTIMIZE is turned on, COMPILE_DOUBLE will also be selected BUT you can then turn it off if all you need are the debugging symbols. This way you have to make an informed decision about disabling COMPILE_DOUBLE. To allow COMPILE_DOUBLE to be both auto-selected and turned off, a new feature was added to menuselect. The <use> element can now contain an "autoselect" attribute which will turn the used member on but not create a hard dependency. The cflags.xml implementation for COMPILE_DOUBLE looks like this... <member name="DONT_OPTIMIZE" displayname="Disable Optimizations ..."> <use autoselect="yes">COMPILE_DOUBLE</use> <support_level>core</support_level> </member> <member name="COMPILE_DOUBLE" displayname="Pre-compile with ...> <depend>DONT_OPTIMIZE</depend> <support_level>core</support_level> </member> When DONT_OPTIMIZE is turned on, COMPILE_DOUBLE is turned on because of the use. When DONT_OPTIMIZE is turned off, COMPILE_DOUBLE is turned off because of the depend. When COMPILE_DOUBLE is turned on, DONT_OPTIMIZE is turned on because of the depend. When COMPILE_DOUBLE is turned off, DONT_OPTIMIZE is left as is because it only uses COMPILE_DOUBLE, it doesn't depend on it. I also made a few tweaks to the ncurses implementation to move things left a bit to allow longer descriptions. Change-Id: Id49ca930ac4b5ec4fc2d8141979ad888da7b1611
Diffstat (limited to 'menuselect')
-rw-r--r--menuselect/menuselect.c12
-rw-r--r--menuselect/menuselect.h2
-rw-r--r--menuselect/menuselect_curses.c73
3 files changed, 66 insertions, 21 deletions
diff --git a/menuselect/menuselect.c b/menuselect/menuselect.c
index f4a826b84..6136135aa 100644
--- a/menuselect/menuselect.c
+++ b/menuselect/menuselect.c
@@ -357,6 +357,10 @@ static int process_xml_ref_node(xmlNode *node, struct member *mem, struct refere
}
}
+ if ((tmp = (const char *) xmlGetProp(node, BAD_CAST "autoselect"))) {
+ ref->autoselect = !strcasecmp(tmp, "yes");
+ }
+
tmp = (const char *) xmlNodeGetContent(node);
if (tmp && !strlen_zero(tmp)) {
@@ -1154,8 +1158,16 @@ unsigned int enable_member(struct member *mem)
}
if ((mem->enabled = can_enable)) {
+ struct reference *use;
+
print_debug("Just set %s enabled to %d\n", mem->name, mem->enabled);
while (calc_dep_failures(1, 0) || calc_conflict_failures(1, 0));
+
+ AST_LIST_TRAVERSE(&mem->uses, use, list) {
+ if (use->member && use->autoselect && !use->member->enabled) {
+ enable_member(use->member);
+ }
+ }
}
return can_enable;
diff --git a/menuselect/menuselect.h b/menuselect/menuselect.h
index b1d22dd75..112f1c88c 100644
--- a/menuselect/menuselect.h
+++ b/menuselect/menuselect.h
@@ -43,6 +43,8 @@ struct reference {
struct member *member;
/*! if this package was found */
unsigned char met:1;
+ /*! if this package should be autoselected */
+ unsigned char autoselect:1;
/*! for linking */
AST_LIST_ENTRY(reference) list;
};
diff --git a/menuselect/menuselect_curses.c b/menuselect/menuselect_curses.c
index 5afa99661..00645927a 100644
--- a/menuselect/menuselect_curses.c
+++ b/menuselect/menuselect_curses.c
@@ -158,6 +158,12 @@ static int really_quit(WINDOW *win)
return c;
}
+#define MENU_HELP_LEFT_ADJ 16
+#define MAIN_MENU_LEFT_ADJ 20
+#define CAT_MENU_LEFT_ADJ 20
+#define SCROLL_DOWN_LEFT_ADJ 15
+#define MEMBER_INFO_LEFT_ADJ 25
+
static void draw_main_menu(WINDOW *menu, int curopt)
{
struct category *cat;
@@ -167,42 +173,67 @@ static void draw_main_menu(WINDOW *menu, int curopt)
wclear(menu);
AST_LIST_TRAVERSE(&categories, cat, list) {
- wmove(menu, i++, max_x / 2 - 10);
- snprintf(buf, sizeof(buf), " %s", strlen_zero(cat->displayname) ? cat->name : cat->displayname);
+ wmove(menu, i++, max_x / 2 - MAIN_MENU_LEFT_ADJ);
+ snprintf(buf, sizeof(buf), "%s", strlen_zero(cat->displayname) ? cat->name : cat->displayname);
waddstr(menu, buf);
}
- wmove(menu, curopt, (max_x / 2) - 15);
+ wmove(menu, curopt, (max_x / 2) - MAIN_MENU_LEFT_ADJ - 5);
waddstr(menu, "--->");
- wmove(menu, 0, 0);
+ wmove(menu, curopt, (max_x / 2) - MAIN_MENU_LEFT_ADJ);
wrefresh(menu);
}
-static void display_mem_info(WINDOW *menu, struct member *mem, int start, int end)
+static void display_mem_info(WINDOW *menu, struct member *mem, int start_y, int end)
{
char buf[64];
struct reference *dep;
struct reference *con;
struct reference *use;
+ int start_x = (max_x / 2 - MEMBER_INFO_LEFT_ADJ);
+ int maxlen = (max_x - start_x);
- wmove(menu, end - start + 2, max_x / 2 - 16);
+ wmove(menu, end - start_y + 1, start_x);
+ wclrtoeol(menu);
+ wmove(menu, end - start_y + 2, start_x);
wclrtoeol(menu);
- wmove(menu, end - start + 3, max_x / 2 - 16);
+ wmove(menu, end - start_y + 3, start_x);
wclrtoeol(menu);
- wmove(menu, end - start + 4, max_x / 2 - 16);
+ wmove(menu, end - start_y + 4, start_x);
wclrtoeol(menu);
- wmove(menu, end - start + 5, max_x / 2 - 16);
+ wmove(menu, end - start_y + 5, start_x);
wclrtoeol(menu);
- wmove(menu, end - start + 6, max_x / 2 - 16);
+ wmove(menu, end - start_y + 6, start_x);
wclrtoeol(menu);
if (mem->displayname) {
- wmove(menu, end - start + 2, max_x / 2 - 16);
- waddstr(menu, (char *) mem->displayname);
+ int name_len = strlen(mem->displayname);
+
+ wmove(menu, end - start_y + 1, start_x);
+ if (name_len > maxlen) {
+ char *last_space;
+ char *line_1 = strdup(mem->displayname);
+
+ if (line_1) {
+ line_1[maxlen] = '\0';
+ last_space = strrchr(line_1, ' ');
+ if (last_space) {
+ *last_space = '\0';
+ }
+ waddstr(menu, line_1);
+ wmove(menu, end - start_y + 2, start_x);
+ waddstr(menu, &mem->displayname[last_space - line_1]);
+ free(line_1);
+ } else {
+ waddstr(menu, (char *) mem->displayname);
+ }
+ } else {
+ waddstr(menu, (char *) mem->displayname);
+ }
}
if (!AST_LIST_EMPTY(&mem->deps)) {
- wmove(menu, end - start + 3, max_x / 2 - 16);
+ wmove(menu, end - start_y + 3, start_x);
strcpy(buf, "Depends on: ");
AST_LIST_TRAVERSE(&mem->deps, dep, list) {
strncat(buf, dep->displayname, sizeof(buf) - strlen(buf) - 1);
@@ -213,7 +244,7 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start, int en
waddstr(menu, buf);
}
if (!AST_LIST_EMPTY(&mem->uses)) {
- wmove(menu, end - start + 4, max_x / 2 - 16);
+ wmove(menu, end - start_y + 4, start_x);
strcpy(buf, "Can use: ");
AST_LIST_TRAVERSE(&mem->uses, use, list) {
strncat(buf, use->displayname, sizeof(buf) - strlen(buf) - 1);
@@ -224,7 +255,7 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start, int en
waddstr(menu, buf);
}
if (!AST_LIST_EMPTY(&mem->conflicts)) {
- wmove(menu, end - start + 5, max_x / 2 - 16);
+ wmove(menu, end - start_y + 5, start_x);
strcpy(buf, "Conflicts with: ");
AST_LIST_TRAVERSE(&mem->conflicts, con, list) {
strncat(buf, con->displayname, sizeof(buf) - strlen(buf) - 1);
@@ -237,7 +268,7 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start, int en
if (!mem->is_separator) { /* Separators lack support levels */
{ /* support level */
- wmove(menu, end - start + 6, max_x / 2 - 16);
+ wmove(menu, end - start_y + 6, start_x);
snprintf(buf, sizeof(buf), "Support Level: %s", mem->support_level);
if (mem->replacement && *mem->replacement) {
char buf2[64];
@@ -266,7 +297,7 @@ static void draw_category_menu(WINDOW *menu, struct category *cat, int start, in
break;
}
}
- wmove(menu, curopt - start, max_x / 2 - 9);
+ wmove(menu, curopt - start, (max_x / 2) - (CAT_MENU_LEFT_ADJ - 1));
wrefresh(menu);
return;
}
@@ -279,7 +310,7 @@ static void draw_category_menu(WINDOW *menu, struct category *cat, int start, in
i++;
continue;
}
- wmove(menu, j++, max_x / 2 - 10);
+ wmove(menu, j++, max_x / 2 - CAT_MENU_LEFT_ADJ);
i++;
if ((mem->depsfailed == HARD_FAILURE) || (mem->conflictsfailed == HARD_FAILURE)) {
snprintf(buf, sizeof(buf), "XXX %s", mem->name);
@@ -302,11 +333,11 @@ static void draw_category_menu(WINDOW *menu, struct category *cat, int start, in
}
if (flags & SCROLL_DOWN) {
- wmove(menu, j, max_x / 2 - sizeof(SCROLL_DOWN_INDICATOR) / 2);
+ wmove(menu, j, max_x / 2 - SCROLL_DOWN_LEFT_ADJ);
waddstr(menu, SCROLL_DOWN_INDICATOR);
}
- wmove(menu, curopt - start, max_x / 2 - 9);
+ wmove(menu, curopt - start, (max_x / 2) - (CAT_MENU_LEFT_ADJ - 1));
wrefresh(menu);
}
@@ -465,7 +496,7 @@ static void draw_title_window(WINDOW *title)
waddstr(title, (char *) menu_name);
wmove(title, 3, (max_x / 2) - (strlen(titlebar) / 2));
waddstr(title, titlebar);
- wmove(title, 5, (max_x / 2) - (strlen(MENU_HELP) / 2));
+ wmove(title, 5, (max_x / 2) - MENU_HELP_LEFT_ADJ);
waddstr(title, MENU_HELP);
wrefresh(title);
}