[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    [PATCH 1/2] makedep: Add support for using parent makefile variables.
From:       Jacek Caban <jacek () codeweavers ! com>
Date:       2020-01-31 19:12:40
Message-ID: 8f64dc50-dfe3-388e-a5b0-1a5ff7e28103 () codeweavers ! com
[Download RAW message or body]

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
---
  tools/makedep.c | 49 +++++++++++++++++++++++++++++++++++++++++++------
  1 file changed, 43 insertions(+), 6 deletions(-)



["0001-makedep-Add-support-for-using-parent-makefile-variable.txt" (text/x-patch)]

diff --git a/tools/makedep.c b/tools/makedep.c
index 4cc0e784c7..0f54e6f29e 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -189,7 +189,6 @@ struct makefile
     const char     *obj_dir;
     const char     *top_src_dir;
     const char     *top_obj_dir;
-    const char     *parent_dir;
     const char     *module;
     const char     *testdll;
     const char     *sharedlib;
@@ -201,6 +200,7 @@ struct makefile
     int             is_cross;
     int             is_win16;
     int             is_exe;
+    struct makefile *parent;
     struct makefile **submakes;
 
     /* values generated at output time */
@@ -1375,10 +1375,10 @@ static struct file *open_local_file( const struct makefile \
*make, const char *pa  struct file *ret = load_file( src_path );
 
     /* if not found, try parent dir */
-    if (!ret && make->parent_dir)
+    if (!ret && make->parent)
     {
         free( src_path );
-        path = strmake( "%s/%s", make->parent_dir, path );
+        path = strmake( "%s/%s", get_relative_path( make->base_dir, \
make->parent->base_dir ), path );  src_path = root_dir_path( base_dir_path( make, \
path ));  ret = load_file( src_path );
         if (ret) ret->flags |= FLAG_PARENTDIR;
@@ -1720,6 +1720,7 @@ static const char *get_make_variable( const struct makefile \
*make, const char *n  
     if ((ret = strarray_get_value( &cmdline_vars, name ))) return ret;
     if ((ret = strarray_get_value( &make->vars, name ))) return ret;
+    if (make->parent && !strncmp( name, "parent_", 7 ) && (ret = strarray_get_value( \
                &make->parent->vars, name + 7 ))) return ret;
     if (top_makefile && (ret = strarray_get_value( &top_makefile->vars, name ))) \
return ret;  return NULL;
 }
@@ -2106,6 +2107,42 @@ static struct makefile *get_parent_makefile( struct makefile \
*make )  }
 
 
+/*******************************************************************
+ *         get_parent_src_makefile
+ */
+static struct makefile *get_parent_src_makefile( struct makefile *make, const char \
*parent_src ) +{
+    const char *base_end, *parent_subdir;
+    char *dir, *p;
+    int i;
+
+    if (!make->base_dir || !parent_src) return NULL;
+
+    base_end = make->base_dir + strlen( make->base_dir );
+    parent_subdir = parent_src;
+
+    while (!strncmp( parent_subdir, "../", 3 ))
+    {
+        parent_subdir += 3;
+        if (base_end == make->base_dir) fatal_error( "invalid parent %s\n", \
parent_src ); +        base_end--;
+        while (base_end > make->base_dir && *base_end != '/') base_end--;
+    }
+    p = dir = xmalloc( base_end - make->base_dir + strlen( parent_subdir ) + 2 );
+    if (base_end > make->base_dir)
+    {
+        memcpy( p, make->base_dir, base_end - make->base_dir );
+        p += base_end - make->base_dir;
+        *p++ = '/';
+    }
+    strcpy( p, parent_subdir );
+    for (i = 0; i < top_makefile->subdirs.count; i++)
+        if (!strcmp( top_makefile->submakes[i]->base_dir, dir )) return \
top_makefile->submakes[i]; +    fatal_error( "could not find parent makefile %s\n", \
parent_src ); +    return NULL;
+}
+
+
 /*******************************************************************
  *         needs_cross_lib
  */
@@ -4201,7 +4238,7 @@ static void load_sources( struct makefile *make )
     strarray_set_value( &make->vars, "top_srcdir", top_src_dir_path( make, "" ));
     strarray_set_value( &make->vars, "srcdir", src_dir_path( make, "" ));
 
-    make->parent_dir    = get_expanded_make_variable( make, "PARENTSRC" );
+    make->parent        = get_parent_src_makefile( make, get_expanded_make_variable( \
make, "PARENTSRC" ) );  make->module        = get_expanded_make_variable( make, \
"MODULE" );  make->testdll       = get_expanded_make_variable( make, "TESTDLL" );
     make->sharedlib     = get_expanded_make_variable( make, "SHAREDLIB" );
@@ -4252,8 +4289,8 @@ static void load_sources( struct makefile *make )
     strarray_add( &make->include_args, strmake( "-I%s", obj_dir_path( make, "" )));
     if (make->src_dir)
         strarray_add( &make->include_args, strmake( "-I%s", make->src_dir ));
-    if (make->parent_dir)
-        strarray_add( &make->include_args, strmake( "-I%s", src_dir_path( make, \
make->parent_dir ))); +    if (make->parent)
+        strarray_add( &make->include_args, strmake( "-I%s", top_src_dir_path( make, \
                make->parent->base_dir )));
     strarray_add( &make->include_args, strmake( "-I%s", top_obj_dir_path( make, \
"include" )));  if (make->top_src_dir)
         strarray_add( &make->include_args, strmake( "-I%s", top_src_dir_path( make, \
"include" )));



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic