Kaydet (Commit) d0bf1510 authored tarafından Michael Meeks's avatar Michael Meeks

detect and collapse internal boost dependencies to a single header

Change-Id: I18281f9cdf4c20ab4f939b2f7d3b0a6c3bf5387b
üst 14028189
...@@ -109,9 +109,9 @@ ...@@ -109,9 +109,9 @@
#define FALSE 0 #define FALSE 0
#endif #endif
static char* base_dir_var = "$(SRCDIR)"; int internal_boost = 0;
#define kBASE_DIR_VAR_LENGTH 9
static char* base_dir; static char* base_dir;
static char* out_dir;
#ifdef __GNUC__ #ifdef __GNUC__
#define clz __builtin_clz #define clz __builtin_clz
...@@ -710,16 +710,24 @@ static inline void eat_space(char ** token) ...@@ -710,16 +710,24 @@ 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 * Prune LibreOffice specific duplicate dependencies to improve
* gnumake startup time, and shrink the disk-space footprint. * 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 #if 0
{ {
int i; int i;
fprintf (stderr, "elide?!: '"); fprintf (stderr, "elide?%d!: '", internal_boost);
for (i = 0; i < key_len; i++) { for (i = 0; i < key_len; i++) {
fprintf (stderr, "%c", key[i]); fprintf (stderr, "%c", key[i]);
} }
...@@ -730,14 +738,48 @@ static inline int elide_dependency(const char* key, int key_len) ...@@ -730,14 +738,48 @@ static inline int elide_dependency(const char* key, int key_len)
/* .hdl files are always matched by .hpp */ /* .hdl files are always matched by .hpp */
if (key_len > 4 && !strncmp(key + key_len - 4, ".hdl", 4)) if (key_len > 4 && !strncmp(key + key_len - 4, ".hdl", 4))
return 1; 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; 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 */ /* prefix paths to absolute */
static inline void print_fullpaths(char* line) static inline void print_fullpaths(char* line)
{ {
char* token; char* token;
char* end; char* end;
int boost_count = 0;
token = line; token = line;
eat_space(&token); eat_space(&token);
...@@ -748,18 +790,30 @@ static inline void print_fullpaths(char* line) ...@@ -748,18 +790,30 @@ static inline void print_fullpaths(char* line)
++end; ++end;
} }
int token_len = end - token; int token_len = end - token;
if(elide_dependency(token, token_len)) if(elide_dependency(token, token_len, &boost_count))
; /* don't output it */ {
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 == '/' || else if(*token == ':' || *token == '\\' || *token == '/' ||
*token == '$' || ':' == token[1]) *token == '$' || ':' == token[1])
{ {
fwrite(token, token_len, 1, stdout); fwrite(token, token_len, 1, stdout);
fputc(' ', stdout);
} }
else else
{ {
fwrite(token, end - token, 1, stdout); fwrite(token, end - token, 1, stdout);
fputc(' ', stdout);
} }
fputc(' ', stdout);
token = end; token = end;
eat_space(&token); eat_space(&token);
} }
...@@ -821,7 +875,7 @@ off_t size; ...@@ -821,7 +875,7 @@ off_t size;
* duplicate out * duplicate out
*/ */
int key_len = cursor_out - base; 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)) hash_store(dep_hash, base, key_len))
{ {
/* DO NOT modify base after it has been added /* DO NOT modify base after it has been added
...@@ -887,6 +941,17 @@ static void _usage(void) ...@@ -887,6 +941,17 @@ static void _usage(void)
#define kDEFAULT_HASH_SIZE 4096 #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 main(int argc, char** argv)
{ {
int rc = 0; int rc = 0;
...@@ -895,18 +960,18 @@ char* in_list; ...@@ -895,18 +960,18 @@ char* in_list;
char* in_list_cursor; char* in_list_cursor;
char* in_list_base; char* in_list_base;
struct hash* dep_hash; struct hash* dep_hash;
const char *env_str;
if(argc < 2) if(argc < 2)
{ {
_usage(); _usage();
return 1; return 1;
} }
base_dir = getenv("SRCDIR"); if(get_var(&base_dir, "SRCDIR") || get_var(&out_dir, "OUTDIR"))
if(!base_dir)
{
fputs("Error: SRCDIR is missing in the environement\n", stderr);
return 1; 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); in_list = file_load(argv[1], &in_list_size, &rc);
if(!rc) if(!rc)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment