[anjuta/newproject] Read target and group properties



commit 044b707a11adb29b86be83c2530b53f9b3a02cb7
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Sat Feb 13 19:54:40 2010 +0100

    Read target and group properties
    
    Map properties are not implemented
    Install directories are often wrong

 libanjuta/anjuta-project.c              |    1 +
 libanjuta/anjuta-project.h              |    3 +-
 plugins/am-project/am-parser.y          |   90 +++++++++--
 plugins/am-project/am-project-private.h |    2 -
 plugins/am-project/am-project.c         |  252 +++++++++++++++++++++++++++----
 plugins/am-project/am-project.h         |   12 ++
 plugins/am-project/am-properties.c      |   96 ++++++++-----
 plugins/am-project/am-properties.h      |    3 +-
 plugins/am-project/am-scanner.h         |   22 +++-
 plugins/am-project/am-scanner.l         |   48 ++++++-
 10 files changed, 442 insertions(+), 87 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index 86fe40a..de6532d 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -144,6 +144,7 @@ anjuta_project_property_remove (AnjutaProjectPropertyList *list, AnjutaProjectPr
 		else if ((info == prop->data) || (info->override == prop))
 		{
 			list = g_list_delete_link (list, link);
+			if (list == NULL) list = info->override;
 			break;
 		}
 	}
diff --git a/libanjuta/anjuta-project.h b/libanjuta/anjuta-project.h
index 943b9d4..f1579b0 100644
--- a/libanjuta/anjuta-project.h
+++ b/libanjuta/anjuta-project.h
@@ -72,7 +72,8 @@ typedef AnjutaProjectTargetInfo* AnjutaProjectTargetType;
 typedef enum
 {
 	ANJUTA_PROJECT_PROPERTY_STRING = 1,
-	ANJUTA_PROJECT_PROPERTY_BOOLEAN
+	ANJUTA_PROJECT_PROPERTY_BOOLEAN,
+	ANJUTA_PROJECT_PROPERTY_MAP
 } AnjutaProjectPropertyType;
 
 typedef struct
diff --git a/plugins/am-project/am-parser.y b/plugins/am-project/am-parser.y
index bb8b37e..63bf489 100644
--- a/plugins/am-project/am-parser.y
+++ b/plugins/am-project/am-parser.y
@@ -62,6 +62,27 @@
 %token  _SCRIPTS
 %token  _SOURCES
 %token  _TEXINFOS
+%token  _DIR
+%token  _LDFLAGS
+%token  _CPPFLAGS
+%token  _CFLAGS
+%token  _CXXFLAGS
+%token  _JAVACFLAGS
+%token  _FCFLAGS
+%token  _OBJCFLAGS
+%token  _LFLAGS
+%token  _YFLAGS
+%token  TARGET_LDFLAGS
+%token  TARGET_CPPFLAGS
+%token  TARGET_CFLAGS
+%token  TARGET_CXXFLAGS
+%token  TARGET_JAVACFLAGS
+%token  TARGET_FCFLAGS
+%token  TARGET_OBJCFLAGS
+%token  TARGET_LFLAGS
+%token  TARGET_YFLAGS
+%token  TARGET_DEPENDENCIES
+
 
 %defines
 
@@ -86,20 +107,41 @@ amp_am_automake_variable (AnjutaToken *token)
 {
     switch (anjuta_token_get_type (token))
     {
-    case SUBDIRS: return AM_TOKEN_SUBDIRS;
-    case DIST_SUBDIRS: return AM_TOKEN_DIST_SUBDIRS;
-    case _DATA: return AM_TOKEN__DATA;
-    case _HEADERS: return AM_TOKEN__HEADERS;
-    case _LIBRARIES: return AM_TOKEN__LIBRARIES;
-    case _LISP: return AM_TOKEN__LISP;
-    case _LTLIBRARIES: return AM_TOKEN__LTLIBRARIES;
-    case _MANS: return AM_TOKEN__MANS;
-    case _PROGRAMS: return AM_TOKEN__PROGRAMS;
-    case _PYTHON: return AM_TOKEN__PYTHON;
-    case _JAVA: return AM_TOKEN__JAVA;
-    case _SCRIPTS: return AM_TOKEN__SCRIPTS;
-    case _SOURCES: return AM_TOKEN__SOURCES;
-    case _TEXINFOS: return AM_TOKEN__TEXINFOS;
+    case SUBDIRS:               return AM_TOKEN_SUBDIRS;
+    case DIST_SUBDIRS:          return AM_TOKEN_DIST_SUBDIRS;
+    case _DATA:                 return AM_TOKEN__DATA;
+    case _HEADERS:              return AM_TOKEN__HEADERS;
+    case _LIBRARIES:            return AM_TOKEN__LIBRARIES;
+    case _LISP:                 return AM_TOKEN__LISP;
+    case _LTLIBRARIES:          return AM_TOKEN__LTLIBRARIES;
+    case _MANS:                 return AM_TOKEN__MANS;
+    case _PROGRAMS:             return AM_TOKEN__PROGRAMS;
+    case _PYTHON:               return AM_TOKEN__PYTHON;
+    case _JAVA:                 return AM_TOKEN__JAVA;
+    case _SCRIPTS:              return AM_TOKEN__SCRIPTS;
+    case _SOURCES:              return AM_TOKEN__SOURCES;
+    case _TEXINFOS:             return AM_TOKEN__TEXINFOS;
+    case _DIR:                  return AM_TOKEN_DIR;
+    case _LDFLAGS:              return AM_TOKEN__LDFLAGS;
+    case _CPPFLAGS:             return AM_TOKEN__CPPFLAGS;
+    case _CFLAGS:               return AM_TOKEN__CFLAGS;
+    case _CXXFLAGS:             return AM_TOKEN__CXXFLAGS;
+    case _JAVACFLAGS:           return AM_TOKEN__JAVACFLAGS;
+    case _FCFLAGS:              return AM_TOKEN__FCFLAGS;
+    case _OBJCFLAGS:            return AM_TOKEN__OBJCFLAGS;
+    case _LFLAGS:               return AM_TOKEN__LFLAGS;
+    case _YFLAGS:               return AM_TOKEN__YFLAGS;
+    case TARGET_LDFLAGS:        return AM_TOKEN_TARGET_LDFLAGS;
+    case TARGET_CPPFLAGS:       return AM_TOKEN_TARGET_CPPFLAGS;
+    case TARGET_CFLAGS:         return AM_TOKEN_TARGET_CFLAGS;
+    case TARGET_CXXFLAGS:       return AM_TOKEN_TARGET_CXXFLAGS;
+    case TARGET_JAVACFLAGS:     return AM_TOKEN_TARGET_JAVACFLAGS;
+    case TARGET_FCFLAGS:        return AM_TOKEN_TARGET_FCFLAGS;
+    case TARGET_OBJCFLAGS:      return AM_TOKEN_TARGET_OBJCFLAGS;
+    case TARGET_LFLAGS:         return AM_TOKEN_TARGET_LFLAGS;
+    case TARGET_YFLAGS:         return AM_TOKEN_TARGET_YFLAGS;
+    case TARGET_DEPENDENCIES:   return AM_TOKEN_TARGET_DEPENDENCIES;
+
     default: return ANJUTA_TOKEN_NAME;
     }
 }
@@ -258,6 +300,26 @@ automake_token:
     | _SCRIPTS
     | _SOURCES
     | _TEXINFOS
+    |  _DIR
+    |  _LDFLAGS
+    |  _CPPFLAGS
+    |  _CFLAGS
+    |  _CXXFLAGS
+    |  _JAVACFLAGS
+    |  _FCFLAGS
+    |  _OBJCFLAGS
+    |  _LFLAGS
+    |  _YFLAGS
+    |  TARGET_LDFLAGS
+    |  TARGET_CPPFLAGS
+    |  TARGET_CFLAGS
+    |  TARGET_CXXFLAGS
+    |  TARGET_JAVACFLAGS
+    |  TARGET_FCFLAGS
+    |  TARGET_OBJCFLAGS
+    |  TARGET_LFLAGS
+    |  TARGET_YFLAGS
+    |  TARGET_DEPENDENCIES
     ;
     
 		
diff --git a/plugins/am-project/am-project-private.h b/plugins/am-project/am-project-private.h
index 5edacff..d07ec9f 100644
--- a/plugins/am-project/am-project-private.h
+++ b/plugins/am-project/am-project-private.h
@@ -55,8 +55,6 @@ struct _AmpPropertyInfo {
 	AnjutaToken *token;
 };
 
-typedef struct _AmpPropertyInfo   AmpPropertyInfo;
-
 struct _AmpProject {
 	GObject         parent;
 
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index f2e2148..9cb56a8 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -139,6 +139,11 @@ struct _AmpTargetInformation {
 	const gchar *install;
 };
 
+struct _AmpTargetPropertyBuffer {
+	GList *sources;
+	GList *properties;
+};
+
 /* Target types
  *---------------------------------------------------------------------------*/
 
@@ -461,6 +466,62 @@ ac_init_default_tarname (const gchar *name)
 	return tarname;
 }
 
+/* Properties buffer objects
+ *---------------------------------------------------------------------------*/
+
+AmpTargetPropertyBuffer*
+amp_target_property_buffer_new (void)
+{
+	AmpTargetPropertyBuffer* buffer;
+
+	buffer = g_new0 (AmpTargetPropertyBuffer, 1);
+
+	return buffer;
+}
+
+void
+amp_target_property_buffer_free (AmpTargetPropertyBuffer *buffer)
+{
+	g_list_foreach (buffer->sources, (GFunc)amp_source_free, NULL);
+	g_list_free (buffer->sources);
+	g_list_foreach (buffer->properties, (GFunc)amp_property_free, NULL);
+	g_list_free (buffer->properties);
+	g_free (buffer);
+}
+
+void
+amp_target_property_buffer_add_source (AmpTargetPropertyBuffer *buffer, AmpSource *source)
+{
+	buffer->sources = g_list_prepend (buffer->sources, source);
+}
+
+void
+amp_target_property_buffer_add_property (AmpTargetPropertyBuffer *buffer, AnjutaProjectPropertyInfo *prop)
+{
+	buffer->properties = g_list_prepend (buffer->properties, prop);
+}
+
+GList *
+amp_target_property_buffer_steal_sources (AmpTargetPropertyBuffer *buffer)
+{
+	GList *list = buffer->sources;
+
+	buffer->sources = NULL;
+
+	return list;
+}
+
+GList *
+amp_target_property_buffer_steal_properties (AmpTargetPropertyBuffer *buffer)
+{
+	GList *list = buffer->properties;
+
+	buffer->properties = NULL;
+
+	return list;
+}
+
+
 /* Config file objects
  *---------------------------------------------------------------------------*/
 
@@ -953,7 +1014,7 @@ amp_project_load_properties (AmpProject *project, AnjutaToken *macro, AnjutaToke
 			prop = anjuta_project_property_lookup (project->properties, list);
 			if (prop == NULL)
 			{
-				prop = (AnjutaProjectPropertyInfo *)amp_property_new (macro);
+				prop = (AnjutaProjectPropertyInfo *)amp_property_new (info->token_type, info->position, NULL, macro);
 				
 				project->properties = anjuta_project_property_insert (project->properties, list, prop);
 			}
@@ -1114,7 +1175,7 @@ find_canonical_target (AnjutaProjectTarget *node, gpointer data)
 }
 
 static AnjutaToken*
-project_load_target (AmpProject *project, AnjutaToken *name, AnjutaToken *list, AnjutaProjectGroup *parent, GHashTable *orphan_sources)
+project_load_target (AmpProject *project, AnjutaToken *name, AnjutaToken *list, AnjutaProjectGroup *parent, GHashTable *orphan_properties)
 {
 	AnjutaToken *arg;
 	AnjutaProjectTargetType type = NULL;
@@ -1145,7 +1206,7 @@ project_load_target (AmpProject *project, AnjutaToken *name, AnjutaToken *list,
 		gchar *value;
 		gchar *canon_id;
 		AmpTarget *target;
-		GList *sources;
+		AmpTargetPropertyBuffer *buffer;
 		gchar *orig_key;
 		gpointer find;
 
@@ -1169,11 +1230,14 @@ project_load_target (AmpProject *project, AnjutaToken *name, AnjutaToken *list,
 		anjuta_project_node_append (parent, target);
 		DEBUG_PRINT ("create target %p name %s", target, value);
 
-		/* Check if there are source availables */
-		if (g_hash_table_lookup_extended (orphan_sources, canon_id, (gpointer *)&orig_key, (gpointer *)&sources))
+		/* Check if there are sources or properties availables */
+		if (g_hash_table_lookup_extended (orphan_properties, canon_id, (gpointer *)&orig_key, (gpointer *)&buffer))
 		{
+			GList *sources;
 			GList *src;
-			g_hash_table_steal (orphan_sources, canon_id);
+
+			g_hash_table_steal (orphan_properties, canon_id);
+			sources = amp_target_property_buffer_steal_sources (buffer);
 			for (src = sources; src != NULL; src = g_list_next (src))
 			{
 				AmpSource *source = src->data;
@@ -1182,6 +1246,8 @@ project_load_target (AmpProject *project, AnjutaToken *name, AnjutaToken *list,
 			}
 			g_free (orig_key);
 			g_list_free (sources);
+
+			amp_target_property_buffer_free (buffer);
 		}
 
 		/* Set target properties */
@@ -1194,7 +1260,16 @@ project_load_target (AmpProject *project, AnjutaToken *name, AnjutaToken *list,
 		if (flags & AM_TARGET_NODIST) 
 			amp_node_property_set (target, AM_TOKEN__PROGRAMS, 2, "0", arg);
 		if (flags & AM_TARGET_NOINST) 
+		{
 			amp_node_property_set (target, AM_TOKEN__PROGRAMS, 3, "1", arg);
+		}
+		else
+		{
+			gchar *instdir = g_strconcat ("$(", install, "dir)", NULL);
+			amp_node_property_set (target, AM_TOKEN__PROGRAMS, 6, instdir, arg);
+			g_free (instdir);
+		}
+		
 		if (flags & AM_TARGET_CHECK) 
 			amp_node_property_set (target, AM_TOKEN__PROGRAMS, 4, "1", arg);
 		if (flags & AM_TARGET_MAN)
@@ -1213,13 +1288,13 @@ project_load_target (AmpProject *project, AnjutaToken *name, AnjutaToken *list,
 }
 
 static AnjutaToken*
-project_load_sources (AmpProject *project, AnjutaToken *name, AnjutaToken *list, AnjutaProjectGroup *parent, GHashTable *orphan_sources)
+project_load_sources (AmpProject *project, AnjutaToken *name, AnjutaToken *list, AnjutaProjectGroup *parent, GHashTable *orphan_properties)
 {
 	AnjutaToken *arg;
 	AmpGroupData *group = AMP_GROUP_DATA (parent);
 	GFile *parent_file = g_object_ref (group->base.directory);
 	gchar *target_id = NULL;
-	GList *orphan = NULL;
+	AmpTargetPropertyBuffer *orphan = NULL;
 
 	target_id = anjuta_token_evaluate (name);
 	if (target_id)
@@ -1240,6 +1315,21 @@ project_load_sources (AmpProject *project, AnjutaToken *name, AnjutaToken *list,
 		anjuta_project_node_children_foreach (parent, find_canonical_target, &find);
 		parent = (gchar *)find != target_id ? (AnjutaProjectTarget *)find : NULL;
 
+		/* Get orphan buffer if there is no target */
+		if (parent == NULL)
+		{
+			gchar *orig_key;
+			if (g_hash_table_lookup_extended (orphan_properties, target_id, (gpointer *)&orig_key, (gpointer *)&orphan))
+			{
+				g_hash_table_steal (orphan_properties, target_id);
+				g_free (orig_key);
+			}
+			else
+			{
+				orphan = amp_target_property_buffer_new ();
+			}
+		}
+
 		for (arg = anjuta_token_first_word (list); arg != NULL; arg = anjuta_token_next_word (arg))
 		{
 			gchar *value;
@@ -1254,10 +1344,9 @@ project_load_sources (AmpProject *project, AnjutaToken *name, AnjutaToken *list,
 			g_object_unref (src_file);
 			AMP_SOURCE_DATA(source)->token = arg;
 
-			if (parent == NULL)
+			if (orphan != NULL)
 			{
-				/* Add in orphan list */
-				orphan = g_list_prepend (orphan, source);
+				amp_target_property_buffer_add_source (orphan, source);
 			}
 			else
 			{
@@ -1268,19 +1357,10 @@ project_load_sources (AmpProject *project, AnjutaToken *name, AnjutaToken *list,
 
 			g_free (value);
 		}
-		
-		if (parent == NULL)
-		{
-			gchar *orig_key;
-			GList *orig_sources;
 
-			if (g_hash_table_lookup_extended (orphan_sources, target_id, (gpointer *)&orig_key, (gpointer *)&orig_sources))
-			{
-				g_hash_table_steal (orphan_sources, target_id);
-				orphan = g_list_concat (orphan, orig_sources);	
-				g_free (orig_key);
-			}
-			g_hash_table_insert (orphan_sources, target_id, orphan);
+		if (orphan != NULL)
+		{
+			g_hash_table_insert (orphan_properties, target_id, orphan);
 		}
 		else
 		{
@@ -1294,7 +1374,7 @@ project_load_sources (AmpProject *project, AnjutaToken *name, AnjutaToken *list,
 }
 
 static AnjutaToken*
-project_load_data (AmpProject *project, AnjutaToken *name, AnjutaToken *list, AnjutaProjectGroup *parent, GHashTable *orphan_sources)
+project_load_data (AmpProject *project, AnjutaToken *name, AnjutaToken *list, AnjutaProjectGroup *parent, GHashTable *orphan_properties)
 {
 	AnjutaProjectTargetType type = NULL;
 	gchar *install;
@@ -1376,6 +1456,98 @@ project_load_data (AmpProject *project, AnjutaToken *name, AnjutaToken *list, An
 	return NULL;
 }
 
+static AnjutaToken*
+project_load_target_properties (AmpProject *project, AnjutaToken *name, AnjutaTokenType type, AnjutaToken *list, AnjutaProjectGroup *parent, GHashTable *orphan_properties)
+{
+	AmpGroupData *group = AMP_GROUP_DATA (parent);
+	gchar *target_id = NULL;
+	
+	target_id = anjuta_token_evaluate (name);
+	if (target_id)
+	{
+		gchar *end = strrchr (target_id, '_');
+		if (end)
+		{
+			*end = '\0';
+		}
+	}
+
+	if (target_id)
+	{
+		gpointer find;
+		gchar *value;
+		AnjutaProjectPropertyInfo *prop;
+		AmpTargetPropertyBuffer *orphan = NULL;
+		
+		find = target_id;
+		DEBUG_PRINT ("search for canonical %s", target_id);
+		anjuta_project_node_children_foreach (parent, find_canonical_target, &find);
+		parent = (gchar *)find != target_id ? (AnjutaProjectTarget *)find : NULL;
+
+		/* Get orphan buffer if there is no target */
+		if (parent == NULL)
+		{
+			gchar *orig_key;
+			if (g_hash_table_lookup_extended (orphan_properties, target_id, (gpointer *)&orig_key, (gpointer *)&orphan))
+			{
+				g_hash_table_steal (orphan_properties, target_id);
+				g_free (orig_key);
+			}
+			else
+			{
+				orphan = amp_target_property_buffer_new ();
+			}
+		}
+
+		/* Create property */
+		value = anjuta_token_evaluate (list);
+		prop = amp_property_new (type, 0, value, list);
+
+		if (parent == NULL)
+		{
+			gchar *orig_key;
+			AmpTargetPropertyBuffer *orphan = NULL;
+			
+			if (g_hash_table_lookup_extended (orphan_properties, target_id, (gpointer *)&orig_key, (gpointer *)&orphan))
+			{
+				g_hash_table_steal (orphan_properties, target_id);
+				g_free (orig_key);
+			}
+			else
+			{
+				orphan = amp_target_property_buffer_new ();
+			}
+			amp_target_property_buffer_add_property (orphan, prop);
+			g_hash_table_insert (orphan_properties, target_id, orphan);
+		}
+		else
+		{
+			amp_node_property_add (parent, prop);
+			g_free (target_id);
+		}
+		g_free (value);
+	}
+
+	return NULL;
+}
+
+static AnjutaToken*
+project_load_group_properties (AmpProject *project, AnjutaTokenType type, AnjutaToken *list, AnjutaProjectGroup *parent)
+{
+	AmpGroupData *group = AMP_GROUP_DATA (parent);
+	gchar *value;
+	AnjutaProjectPropertyInfo *prop;
+		
+	/* Create property */
+	value = anjuta_token_evaluate (list);
+	prop = amp_property_new (type, 0, value, list);
+
+	amp_node_property_add (parent, prop);
+	g_free (value);
+
+	return NULL;
+}
+
 static AmpGroup* project_load_makefile (AmpProject *project, GFile *file, AmpGroup *parent, gboolean dist_only);
 
 static void
@@ -1495,7 +1667,7 @@ project_load_makefile (AmpProject *project, GFile *file, AnjutaProjectGroup *par
 }
 
 void
-amp_project_set_am_variable (AmpProject* project, AmpGroup* group, AnjutaTokenType variable, AnjutaToken *name, AnjutaToken *list, GHashTable *orphan_sources)
+amp_project_set_am_variable (AmpProject* project, AmpGroup* group, AnjutaTokenType variable, AnjutaToken *name, AnjutaToken *list, GHashTable *orphan_properties)
 {
 	
 	switch (variable)
@@ -1507,7 +1679,7 @@ amp_project_set_am_variable (AmpProject* project, AmpGroup* group, AnjutaTokenTy
 		project_load_subdirs (project, list, group, TRUE);
 		break;
 	case AM_TOKEN__DATA:
-		project_load_data (project, name, list, group, orphan_sources);
+		project_load_data (project, name, list, group, orphan_properties);
 		break;
 	case AM_TOKEN__HEADERS:
 	case AM_TOKEN__LIBRARIES:
@@ -1519,10 +1691,34 @@ amp_project_set_am_variable (AmpProject* project, AmpGroup* group, AnjutaTokenTy
 	case AM_TOKEN__JAVA:
 	case AM_TOKEN__SCRIPTS:
 	case AM_TOKEN__TEXINFOS:
-		project_load_target (project, name, list, group, orphan_sources);
+		project_load_target (project, name, list, group, orphan_properties);
 		break;
 	case AM_TOKEN__SOURCES:
-		project_load_sources (project, name, list, group, orphan_sources);
+		project_load_sources (project, name, list, group, orphan_properties);
+		break;
+	case AM_TOKEN_DIR:
+	case AM_TOKEN__LDFLAGS:
+	case AM_TOKEN__CPPFLAGS:
+	case AM_TOKEN__CFLAGS:
+	case AM_TOKEN__CXXFLAGS:
+	case AM_TOKEN__JAVACFLAGS:
+	case AM_TOKEN__FCFLAGS:
+	case AM_TOKEN__OBJCFLAGS:
+	case AM_TOKEN__LFLAGS:
+	case AM_TOKEN__YFLAGS:
+		project_load_group_properties (project, variable, list, group);
+		break;
+	case AM_TOKEN_TARGET_LDFLAGS:
+	case AM_TOKEN_TARGET_CPPFLAGS:
+	case AM_TOKEN_TARGET_CFLAGS:
+	case AM_TOKEN_TARGET_CXXFLAGS:
+	case AM_TOKEN_TARGET_JAVACFLAGS:
+	case AM_TOKEN_TARGET_FCFLAGS:
+	case AM_TOKEN_TARGET_OBJCFLAGS:
+	case AM_TOKEN_TARGET_LFLAGS:
+	case AM_TOKEN_TARGET_YFLAGS:
+	case AM_TOKEN_TARGET_DEPENDENCIES:
+		project_load_target_properties (project, name, variable, list, group, orphan_properties);
 		break;
 	default:
 		break;
diff --git a/plugins/am-project/am-project.h b/plugins/am-project/am-project.h
index d91b65a..606ef19 100644
--- a/plugins/am-project/am-project.h
+++ b/plugins/am-project/am-project.h
@@ -62,10 +62,22 @@ typedef enum {
 	AMP_PROPERTY_URL
 } AmpPropertyType;
 
+typedef struct _AmpPropertyInfo   AmpPropertyInfo;
+
+typedef struct _AmpTargetPropertyBuffer AmpTargetPropertyBuffer;
 
 GType         amp_project_get_type (void);
 AmpProject   *amp_project_new      (void);
 
+
+AmpTargetPropertyBuffer* amp_target_property_buffer_new (void);
+void amp_target_property_buffer_free (AmpTargetPropertyBuffer *buffer);
+
+void amp_target_property_buffer_add_source (AmpTargetPropertyBuffer *buffer, AmpSource *source);
+void amp_target_property_buffer_add_property (AmpTargetPropertyBuffer *buffer, AnjutaProjectPropertyInfo *prop);
+GList *amp_target_property_buffer_steal_sources (AmpTargetPropertyBuffer *buffer);
+GList *amp_target_property_buffer_steal_properties (AmpTargetPropertyBuffer *buffer);
+
 gint amp_project_probe (GFile *directory, GError     **error);
 gboolean amp_project_load (AmpProject *project, GFile *directory, GError **error);
 gboolean amp_project_reload (AmpProject *project, GError **error);
diff --git a/plugins/am-project/am-properties.c b/plugins/am-project/am-properties.c
index 56140a6..7219e65 100644
--- a/plugins/am-project/am-properties.c
+++ b/plugins/am-project/am-properties.c
@@ -52,16 +52,16 @@ static GList* AmpProjectPropertyList = NULL;
 
 
 static AmpPropertyInfo AmpGroupProperties[] = {
-	{{N_("Linker flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("C preprocessor flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("C compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("C++ compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Java Compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Fortan compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Objective C compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Lex/Flex flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Yacc/Bison flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Ratfor compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
+	{{N_("Linker flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN__LDFLAGS, 0, NULL},
+	{{N_("C preprocessor flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN__CPPFLAGS, 0, NULL},
+	{{N_("C compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN__CFLAGS, 0, NULL},
+	{{N_("C++ compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN__CXXFLAGS, 0, NULL},
+	{{N_("Java Compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN__JAVACFLAGS, 0, NULL},
+	{{N_("Fortan compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN__FCFLAGS, 0, NULL},
+	{{N_("Objective C compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN__OBJCFLAGS, 0, NULL},
+	{{N_("Lex/Flex flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN__LFLAGS, 0, NULL},
+	{{N_("Yacc/Bison flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL},AM_TOKEN__YFLAGS, 0, NULL},
+	{{N_("Install directories:"), ANJUTA_PROJECT_PROPERTY_MAP, NULL, NULL}, AM_TOKEN_DIR, 0, NULL},
 	{{NULL, ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL}};
 
 static GList* AmpGroupPropertyList = NULL;
@@ -69,18 +69,17 @@ static GList* AmpGroupPropertyList = NULL;
 
 static AmpPropertyInfo AmpTargetProperties[] = {
 	{{N_("Do not install:"), ANJUTA_PROJECT_PROPERTY_BOOLEAN, NULL, NULL}, AM_TOKEN__PROGRAMS, 3, NULL},
-	{{N_("Installation directory:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Linker flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("C preprocessor flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("C compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("C++ compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Java Compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Fortan compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Objective C compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Lex/Flex flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Yacc/Bison flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Ratfor compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Additional dependencies:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
+	{{N_("Installation directory:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN__PROGRAMS, 6, NULL},
+	{{N_("Linker flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN_TARGET_LDFLAGS, 0, NULL},
+	{{N_("C preprocessor flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN_TARGET_CPPFLAGS, 0, NULL},
+	{{N_("C compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN_TARGET_CFLAGS, 0, NULL},
+	{{N_("C++ compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN_TARGET_CXXFLAGS, 0, NULL},
+	{{N_("Java Compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN_TARGET_JAVACFLAGS, 0, NULL},
+	{{N_("Fortan compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN_TARGET_FCFLAGS, 0, NULL},
+	{{N_("Objective C compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN_TARGET_OBJCFLAGS, 0, NULL},
+	{{N_("Lex/Flex flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN_TARGET_LFLAGS, 0, NULL},
+	{{N_("Yacc/Bison flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN_TARGET_YFLAGS, 0, NULL},
+	{{N_("Additional dependencies:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN_TARGET_DEPENDENCIES, 0, NULL},
 	{{N_("Include in distribution:"), ANJUTA_PROJECT_PROPERTY_BOOLEAN, NULL, NULL}, AM_TOKEN__PROGRAMS, 2, NULL},
 	{{N_("Build for check only:"), ANJUTA_PROJECT_PROPERTY_BOOLEAN, NULL, NULL}, AM_TOKEN__PROGRAMS, 4, NULL},
 	{{N_("Do not use prefix:"), ANJUTA_PROJECT_PROPERTY_BOOLEAN, NULL, NULL}, AM_TOKEN__PROGRAMS, 1, NULL},
@@ -90,17 +89,6 @@ static AmpPropertyInfo AmpTargetProperties[] = {
 static GList* AmpTargetPropertyList = NULL;
 
 static AmpPropertyInfo AmpManTargetProperties[] = {
-	{{N_("Installation directory:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Linker flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("C preprocessor flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("C compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("C++ compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Java Compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Fortan compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Objective C compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Lex/Flex flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Yacc/Bison flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
-	{{N_("Ratfor compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
 	{{N_("Additional dependencies:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, 0, 0, NULL},
 	{{N_("Do not use prefix:"), ANJUTA_PROJECT_PROPERTY_BOOLEAN, NULL, NULL}, AM_TOKEN__PROGRAMS, 1, NULL},
 	{{N_("Manual section:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, AM_TOKEN__PROGRAMS, 5, NULL},
@@ -139,12 +127,15 @@ amp_create_property_list (GList **list, AmpPropertyInfo *info)
  *---------------------------------------------------------------------------*/
 
 AnjutaProjectPropertyInfo *
-amp_property_new (AnjutaToken *ac_init)
+amp_property_new (AnjutaTokenType type, gint position, const gchar *value, AnjutaToken *token)
 {
 	AmpPropertyInfo *prop;
 
 	prop = g_slice_new0(AmpPropertyInfo);
-	prop->token = ac_init;
+	prop->base.value = g_strdup (value);
+	prop->token = token;
+	prop->token_type = type;
+	prop->position = position;
 
 	return (AnjutaProjectPropertyInfo *)prop;
 }
@@ -183,7 +174,7 @@ amp_node_property_set (AnjutaProjectNode *node, gint token_type, gint position,
 			prop = anjuta_project_property_lookup (*properties, list);
 			if (prop == NULL)
 			{
-				prop = (AnjutaProjectPropertyInfo *)amp_property_new (token);
+				prop = (AnjutaProjectPropertyInfo *)amp_property_new (token_type, position, NULL, token);
 				
 				*properties = anjuta_project_property_insert (*properties, list, prop);
 			}
@@ -197,6 +188,39 @@ amp_node_property_set (AnjutaProjectNode *node, gint token_type, gint position,
 	return set;
 }
 
+gboolean
+amp_node_property_add (AnjutaProjectNode *node, AmpPropertyInfo *prop)
+{
+	AnjutaProjectPropertyList **properties = &(ANJUTA_PROJECT_NODE_DATA(node)->properties);
+	AnjutaProjectPropertyItem *list;
+	gboolean set = FALSE;
+
+	g_message ("properties %p", *properties);
+	for (list = anjuta_project_property_first (*properties); list != NULL; list = anjuta_project_property_next (list))
+	{
+		AmpPropertyInfo *info = (AmpPropertyInfo *)anjuta_project_property_get_info (list);
+
+		if ((info->token_type == prop->token_type) && (info->position == prop->position))
+		{
+			AnjutaProjectPropertyInfo *old_prop;
+
+			old_prop = anjuta_project_property_lookup (*properties, list);
+			if (old_prop != NULL)
+			{
+				*properties = anjuta_project_property_remove (*properties, list);
+				g_message ("remove properties %p", *properties);
+				amp_property_free (old_prop);
+			}
+			*properties = anjuta_project_property_insert (*properties, list, (AnjutaProjectPropertyInfo *)prop);
+			set = TRUE;
+			break;
+		}
+	}
+
+	if (!set) amp_property_free ((AnjutaProjectPropertyInfo *)prop);
+	
+	return set;
+}
 
 /* Get property list
  *---------------------------------------------------------------------------*/
diff --git a/plugins/am-project/am-properties.h b/plugins/am-project/am-properties.h
index 5032351..d017e49 100644
--- a/plugins/am-project/am-properties.h
+++ b/plugins/am-project/am-properties.h
@@ -28,10 +28,11 @@
 
 G_BEGIN_DECLS
 
-AnjutaProjectPropertyInfo *amp_property_new (AnjutaToken *token);
+AnjutaProjectPropertyInfo *amp_property_new (AnjutaTokenType type, gint position, const gchar *value, AnjutaToken *token);
 void amp_property_free (AnjutaProjectPropertyInfo *prop);
 
 gboolean amp_node_property_set (AnjutaProjectNode *target, gint token_type, gint position, const gchar *value, AnjutaToken *token);
+gboolean amp_node_property_add (AnjutaProjectNode *node, AmpPropertyInfo *info);
 
 GList* amp_get_project_property_list (void);
 GList* amp_get_group_property_list (void);
diff --git a/plugins/am-project/am-scanner.h b/plugins/am-project/am-scanner.h
index 55640a5..d2882b2 100644
--- a/plugins/am-project/am-scanner.h
+++ b/plugins/am-project/am-scanner.h
@@ -60,7 +60,27 @@ typedef enum
 	AM_TOKEN__SCRIPTS,
 	AM_TOKEN__SOURCES,
 	AM_TOKEN__TEXINFOS,
-	AM_TOKEN__JAVA
+	AM_TOKEN__JAVA,
+	AM_TOKEN_DIR,
+	AM_TOKEN__LDFLAGS,
+	AM_TOKEN__CPPFLAGS,
+	AM_TOKEN__CFLAGS,
+	AM_TOKEN__CXXFLAGS,
+	AM_TOKEN__JAVACFLAGS,
+	AM_TOKEN__FCFLAGS,
+	AM_TOKEN__OBJCFLAGS,
+	AM_TOKEN__LFLAGS,
+	AM_TOKEN__YFLAGS,
+	AM_TOKEN_TARGET_LDFLAGS,
+	AM_TOKEN_TARGET_CPPFLAGS,
+	AM_TOKEN_TARGET_CFLAGS,
+	AM_TOKEN_TARGET_CXXFLAGS,
+	AM_TOKEN_TARGET_JAVACFLAGS,
+	AM_TOKEN_TARGET_FCFLAGS,
+	AM_TOKEN_TARGET_OBJCFLAGS,
+	AM_TOKEN_TARGET_LFLAGS,
+	AM_TOKEN_TARGET_YFLAGS,
+	AM_TOKEN_TARGET_DEPENDENCIES,
 } AmTokenType;
 
 G_END_DECLS
diff --git a/plugins/am-project/am-scanner.l b/plugins/am-project/am-scanner.l
index 4f18edd..df9ffc8 100644
--- a/plugins/am-project/am-scanner.l
+++ b/plugins/am-project/am-scanner.l
@@ -50,7 +50,7 @@ struct _AmpAmScanner
 
     AmpProject *project;
     AmpGroup *group;
-	GHashTable *orphan_sources;
+	GHashTable *orphan_properties;
 };
 
 %}
@@ -142,6 +142,46 @@ NAME          [^ \t\n\r:#=$"'`&@\\]*
 
 <INITIAL>{NAME}_TEXINFOS 			{ RETURN (_TEXINFOS); }
 
+<INITIAL>{NAME}dir					{ RETURN (_DIR); }
+
+<INITIAL>AM_LDFLAGS					{ RETURN (_LDFLAGS);}
+
+<INITIAL>AM_CPPFLAGS				{ RETURN (_CPPFLAGS);}
+
+<INITIAL>AM_CFLAGS					{ RETURN (_CFLAGS);}
+
+<INITIAL>AM_CXXFLAGS				{ RETURN (_CXXFLAGS);}
+
+<INITIAL>AM_JAVACFLAGS				{ RETURN (_JAVACFLAGS);}
+
+<INITIAL>AM_FCFLAGS					{ RETURN (_FCFLAGS);}
+
+<INITIAL>AM_OBJCFLAGS				{ RETURN (_OBJCFLAGS);}
+
+<INITIAL>AM_LFLAGS					{ RETURN (_LFLAGS);}
+
+<INITIAL>AM_YFLAGS					{ RETURN (_YFLAGS);}
+
+<INITIAL>{NAME}_LDFLAGS				{ RETURN (TARGET_LDFLAGS);}
+
+<INITIAL>{NAME}_CPPFLAGS			{ RETURN (TARGET_CPPFLAGS);}
+
+<INITIAL>{NAME}_CFLAGS				{ RETURN (TARGET_CFLAGS);}
+
+<INITIAL>{NAME}_CXXFLAGS			{ RETURN (TARGET_CXXFLAGS);}
+
+<INITIAL>{NAME}_JAVACFLAGS			{ RETURN (TARGET_JAVACFLAGS);}
+
+<INITIAL>{NAME}_FCFLAGS				{ RETURN (TARGET_FCFLAGS);}
+
+<INITIAL>{NAME}_OBJCFLAGS			{ RETURN (TARGET_OBJCFLAGS);}
+
+<INITIAL>{NAME}_LFLAGS				{ RETURN (TARGET_LFLAGS);}
+
+<INITIAL>{NAME}_YFLAGS				{ RETURN (TARGET_YFLAGS);}
+
+<INITIAL>{NAME}_DEPENDENCIES		{ RETURN (TARGET_DEPENDENCIES);}
+
 <INITIAL>{NAME} 					{ RETURN (NAME); }
 
 <INITIAL>. 							{ RETURN (CHARACTER); }
@@ -212,7 +252,7 @@ amp_am_yyerror (YYLTYPE *loc, AmpAmScanner *scanner, char const *s)
 void
 amp_am_scanner_set_am_variable (AmpAmScanner *scanner, AnjutaTokenType variable, AnjutaToken *name, AnjutaToken *list)
 {
-    amp_project_set_am_variable (scanner->project, scanner->group, variable, name, list, scanner->orphan_sources);
+    amp_project_set_am_variable (scanner->project, scanner->group, variable, name, list, scanner->orphan_properties);
 }
 
 /* Public functions
@@ -279,7 +319,7 @@ amp_am_scanner_new (AmpProject *project, AmpGroup *group)
     scanner->group = group;
 
 	/* Create hash table for sources list */
-	scanner->orphan_sources = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify)free_source_list);
+	scanner->orphan_properties = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify)amp_target_property_buffer_free);
 
     yylex_init(&scanner->scanner);
     yyset_extra (scanner, scanner->scanner);
@@ -295,7 +335,7 @@ amp_am_scanner_free (AmpAmScanner *scanner)
     yylex_destroy(scanner->scanner);
 
 	/* Free unused sources files */
-	g_hash_table_destroy (scanner->orphan_sources);
+	g_hash_table_destroy (scanner->orphan_properties);
 
 	g_free (scanner);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]