summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2012-10-11 19:14:39 +0100
committerMichael Meeks <michael.meeks@suse.com>2012-10-12 17:47:37 +0100
commitd0bf1510632801e15f1f498320c90efb6d773d6e (patch)
tree1fb895ff34024fba7aec7df91f0a9c0009988b4f
parent140281898f21f707582f395918e5234bdb67e435 (diff)
detect and collapse internal boost dependencies to a single header
Change-Id: I18281f9cdf4c20ab4f939b2f7d3b0a6c3bf5387b
-rw-r--r--solenv/bin/concat-deps.c91
1 files changed, 78 insertions, 13 deletions
diff --git a/solenv/bin/concat-deps.c b/solenv/bin/concat-deps.c
index 11571ee5c756..81a47929a266 100644
--- a/solenv/bin/concat-deps.c
+++ b/solenv/bin/concat-deps.c
@@ -109,9 +109,9 @@
#define FALSE 0
#endif
-static char* base_dir_var = "$(SRCDIR)";
-#define kBASE_DIR_VAR_LENGTH 9
+int internal_boost = 0;
static char* base_dir;
+static char* out_dir;
#ifdef __GNUC__
#define clz __builtin_clz
@@ -711,15 +711,23 @@ static inline void eat_space(char ** token)
}
/*
+ * Find substring in bounded length string
+ */
+static inline const char *find_substr(const char *key, int key_len,
+ const char *substr, int substr_len)
+{
+}
+
+/*
* Prune LibreOffice specific duplicate dependencies to improve
* gnumake startup time, and shrink the disk-space footprint.
*/
-static inline int elide_dependency(const char* key, int key_len)
+static inline int elide_dependency(const char* key, int key_len, int *boost_count)
{
#if 0
{
int i;
- fprintf (stderr, "elide?!: '");
+ fprintf (stderr, "elide?%d!: '", internal_boost);
for (i = 0; i < key_len; i++) {
fprintf (stderr, "%c", key[i]);
}
@@ -730,14 +738,48 @@ static inline int elide_dependency(const char* key, int key_len)
/* .hdl files are always matched by .hpp */
if (key_len > 4 && !strncmp(key + key_len - 4, ".hdl", 4))
return 1;
+
+ /* boost brings a plague of header files */
+ if (internal_boost)
+ {
+ int i;
+ int hit = 0;
+ /* walk down path elements */
+ for (i = 0; i < key_len - 1; i++)
+ {
+ if (key[i] == '/')
+ {
+ if (!strncmp(key + i + 1, "solver/", 7))
+ hit++;
+ if (hit > 0 && !strncmp(key + i + 1, "inc/external/boost/", 19))
+ {
+ if (boost_count)
+ (*boost_count)++;
+ return 1;
+ }
+ }
+ }
+ }
+
return 0;
}
+/*
+ * We collapse tens of internal boost headers to a single one, such
+ * that you can re-compile / install boost and all is well.
+ */
+static void emit_single_boost_header(void)
+{
+#define BOOST_HEADER "/inc/external/boost/bind.hpp"
+ fprintf(stdout, "%s" BOOST_HEADER " ", out_dir);
+}
+
/* prefix paths to absolute */
static inline void print_fullpaths(char* line)
{
char* token;
char* end;
+ int boost_count = 0;
token = line;
eat_space(&token);
@@ -748,18 +790,30 @@ static inline void print_fullpaths(char* line)
++end;
}
int token_len = end - token;
- if(elide_dependency(token, token_len))
- ; /* don't output it */
+ if(elide_dependency(token, token_len, &boost_count))
+ {
+ if (boost_count == 1)
+ emit_single_boost_header();
+ else
+ {
+ /* don't output, and swallow trailing \\\n if any */
+ token = end;
+ eat_space(&token);
+ if (token[0] == '\\' && token[1] == '\n')
+ end = token + 2;
+ }
+ }
else if(*token == ':' || *token == '\\' || *token == '/' ||
*token == '$' || ':' == token[1])
{
fwrite(token, token_len, 1, stdout);
+ fputc(' ', stdout);
}
else
{
fwrite(token, end - token, 1, stdout);
+ fputc(' ', stdout);
}
- fputc(' ', stdout);
token = end;
eat_space(&token);
}
@@ -821,7 +875,7 @@ off_t size;
* duplicate out
*/
int key_len = cursor_out - base;
- if(!elide_dependency(base,key_len - 1) &&
+ if(!elide_dependency(base,key_len - 1, NULL) &&
hash_store(dep_hash, base, key_len))
{
/* DO NOT modify base after it has been added
@@ -887,6 +941,17 @@ static void _usage(void)
#define kDEFAULT_HASH_SIZE 4096
+static int get_var(char **var, const char *name)
+{
+ *var = (char *)getenv(name);
+ if(!*var)
+ {
+ fprintf(stderr,"Error: %s is missing in the environement\n", name);
+ return 1;
+ }
+ return 0;
+}
+
int main(int argc, char** argv)
{
int rc = 0;
@@ -895,18 +960,18 @@ char* in_list;
char* in_list_cursor;
char* in_list_base;
struct hash* dep_hash;
+const char *env_str;
if(argc < 2)
{
_usage();
return 1;
}
- base_dir = getenv("SRCDIR");
- if(!base_dir)
- {
- fputs("Error: SRCDIR is missing in the environement\n", stderr);
+ if(get_var(&base_dir, "SRCDIR") || get_var(&out_dir, "OUTDIR"))
return 1;
- }
+
+ env_str = getenv("SYSTEM_BOOST");
+ internal_boost = !env_str || strcmp(env_str,"TRUE");
in_list = file_load(argv[1], &in_list_size, &rc);
if(!rc)