[Asterisk-code-review] build system: Split COMPILE DOUBLE from DONT OPTIMIZE (asterisk[master])
Joshua Colp
asteriskteam at digium.com
Tue Mar 15 15:55:27 CDT 2016
Joshua Colp has submitted this change and it was merged.
Change subject: build_system: Split COMPILE_DOUBLE from DONT_OPTIMIZE
......................................................................
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
---
M Makefile.rules
M build_tools/cflags.xml
M menuselect/menuselect.c
M menuselect/menuselect.h
M menuselect/menuselect_curses.c
5 files changed, 77 insertions(+), 25 deletions(-)
Approvals:
Mark Michelson: Looks good to me, approved
Joshua Colp: Looks good to me, but someone else must approve; Verified
diff --git a/Makefile.rules b/Makefile.rules
index 1031f2d..a22f19c 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -103,13 +103,15 @@
CXX_LIBS=$(PTHREAD_LIBS) $(LIBS)
# determine whether to double-compile so that the optimizer can report code path problems
-# this is only done when developer mode and DONT_OPTIMIZE are both enabled
-# in that case, we run the preprocessor to produce a .i or .ii file from the source
+# In this case, we run the preprocessor to produce a .i or .ii file from the source
# code, then compile once with optimizer enabled (and the output to /dev/null),
# and if that doesn't fail then compile again with optimizer disabled
-ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS))$(AST_DEVMODE),DONT_OPTIMIZEyes)
+
+ifeq ($(findstring COMPILE_DOUBLE,$(MENUSELECT_CFLAGS)),COMPILE_DOUBLE)
COMPILE_DOUBLE=yes
-else
+endif
+
+ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS))$(AST_DEVMODE),)
_ASTCFLAGS+=$(AST_FORTIFY_SOURCE)
endif
diff --git a/build_tools/cflags.xml b/build_tools/cflags.xml
index 566c3b0..a06d515 100644
--- a/build_tools/cflags.xml
+++ b/build_tools/cflags.xml
@@ -1,5 +1,10 @@
<category name="MENUSELECT_CFLAGS" displayname="Compiler Flags" positive_output="yes" remove_on_change=".lastclean">
<member name="DONT_OPTIMIZE" displayname="Disable Optimizations by the Compiler">
+ <use autoselect="yes">COMPILE_DOUBLE</use>
+ <support_level>core</support_level>
+ </member>
+ <member name="COMPILE_DOUBLE" displayname="Pre-compile with optimizations to detect errors, then discard and recompile with DONT_OPTIMIZE. Creates intermediate .i files">
+ <depend>DONT_OPTIMIZE</depend>
<support_level>core</support_level>
</member>
<member name="DEBUG_THREADS" displayname="Enable Thread Debugging">
diff --git a/menuselect/menuselect.c b/menuselect/menuselect.c
index f4a826b..6136135 100644
--- a/menuselect/menuselect.c
+++ b/menuselect/menuselect.c
@@ -357,6 +357,10 @@
}
}
+ 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 @@
}
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 b1d22dd..112f1c8 100644
--- a/menuselect/menuselect.h
+++ b/menuselect/menuselect.h
@@ -43,6 +43,8 @@
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 5afa996..0064592 100644
--- a/menuselect/menuselect_curses.c
+++ b/menuselect/menuselect_curses.c
@@ -158,6 +158,12 @@
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 @@
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 + 3, max_x / 2 - 16);
+ wmove(menu, end - start_y + 2, start_x);
wclrtoeol(menu);
- wmove(menu, end - start + 4, max_x / 2 - 16);
+ wmove(menu, end - start_y + 3, start_x);
wclrtoeol(menu);
- wmove(menu, end - start + 5, max_x / 2 - 16);
+ wmove(menu, end - start_y + 4, start_x);
wclrtoeol(menu);
- wmove(menu, end - start + 6, max_x / 2 - 16);
+ wmove(menu, end - start_y + 5, start_x);
+ wclrtoeol(menu);
+ 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
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 @@
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);
}
--
To view, visit https://gerrit.asterisk.org/2381
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id49ca930ac4b5ec4fc2d8141979ad888da7b1611
Gerrit-PatchSet: 3
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
More information about the asterisk-code-review
mailing list