[anjuta/newproject] Check for vala flags, accept directory in target names, fix a crash with empty group



commit e95f0f2d32d84175e68a13523d714045cf5c0c8a
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Sun Oct 17 10:37:50 2010 +0200

    Check for vala flags, accept directory in target names, fix a crash with empty group

 plugins/am-project/am-node.c       |   23 +++++++++++++++--------
 plugins/am-project/am-parser.y     |    6 ++++++
 plugins/am-project/am-project.c    |    5 ++++-
 plugins/am-project/am-properties.c |    6 ++++--
 plugins/am-project/am-scanner.h    |    2 ++
 plugins/am-project/am-scanner.l    |    4 ++++
 6 files changed, 35 insertions(+), 11 deletions(-)
---
diff --git a/plugins/am-project/am-node.c b/plugins/am-project/am-node.c
index d9d3789..3ddd845 100644
--- a/plugins/am-project/am-node.c
+++ b/plugins/am-project/am-node.c
@@ -734,6 +734,7 @@ AnjutaAmTargetNode*
 amp_target_new (const gchar *name, AnjutaProjectNodeType type, const gchar *install, gint flags, GError **error)
 {
 	AnjutaAmTargetNode *node = NULL;
+	const gchar *basename;
 
 	/* Validate target name */
 	if (!name || strlen (name) <= 0)
@@ -747,29 +748,35 @@ amp_target_new (const gchar *name, AnjutaProjectNodeType type, const gchar *inst
 		const gchar *ptr = name;
 		while (*ptr) {
 			if (!isalnum (*ptr) && *ptr != '.' && *ptr != '-' &&
-			    *ptr != '_')
+			    *ptr != '_' && *ptr != '/')
 				failed = TRUE;
 			ptr++;
 		}
 		if (failed) {
 			error_set (error, IANJUTA_PROJECT_ERROR_VALIDATION_FAILED,
-				   _("Target name can only contain alphanumeric, '_', '-' or '.' characters"));
+				   _("Target name can only contain alphanumeric, '_', '-', '/' or '.' characters"));
 			return NULL;
 		}
 	}
+
+	/* Skip eventual directory name */
+	basename = strrchr (name, '/');
+	basename = basename == NULL ? name : basename + 1;
+		
+	
 	if ((type & ANJUTA_PROJECT_ID_MASK) == ANJUTA_PROJECT_SHAREDLIB) {
-		if (strlen (name) < 7 ||
-		    strncmp (name, "lib", strlen("lib")) != 0 ||
-		    strcmp (&name[strlen(name) - 3], ".la") != 0) {
+		if (strlen (basename) < 7 ||
+		    strncmp (basename, "lib", strlen("lib")) != 0 ||
+		    strcmp (&basename[strlen(basename) - 3], ".la") != 0) {
 			error_set (error, IANJUTA_PROJECT_ERROR_VALIDATION_FAILED,
 				   _("Shared library target name must be of the form 'libxxx.la'"));
 			return NULL;
 		}
 	}
 	else if ((type & ANJUTA_PROJECT_ID_MASK) == ANJUTA_PROJECT_STATICLIB) {
-		if (strlen (name) < 6 ||
-		    strncmp (name, "lib", strlen("lib")) != 0 ||
-		    strcmp (&name[strlen(name) - 2], ".a") != 0) {
+		if (strlen (basename) < 6 ||
+		    strncmp (basename, "lib", strlen("lib")) != 0 ||
+		    strcmp (&basename[strlen(basename) - 2], ".a") != 0) {
 			error_set (error, IANJUTA_PROJECT_ERROR_VALIDATION_FAILED,
 				   _("Static library target name must be of the form 'libxxx.a'"));
 			return NULL;
diff --git a/plugins/am-project/am-parser.y b/plugins/am-project/am-parser.y
index a7332a9..2d0bc0b 100644
--- a/plugins/am-project/am-parser.y
+++ b/plugins/am-project/am-parser.y
@@ -72,6 +72,7 @@
 %token  _CFLAGS
 %token  _CXXFLAGS
 %token  _JAVACFLAGS
+%token  _VALAFLAGS
 %token  _FCFLAGS
 %token  _OBJCFLAGS
 %token  _LFLAGS
@@ -81,6 +82,7 @@
 %token  TARGET_CFLAGS
 %token  TARGET_CXXFLAGS
 %token  TARGET_JAVACFLAGS
+%token  TARGET_VALAFLAGS
 %token  TARGET_FCFLAGS
 %token  TARGET_OBJCFLAGS
 %token  TARGET_LFLAGS
@@ -139,6 +141,7 @@ amp_am_automake_variable (AnjutaToken *token)
     case _CFLAGS:               return AM_TOKEN__CFLAGS;
     case _CXXFLAGS:             return AM_TOKEN__CXXFLAGS;
     case _JAVACFLAGS:           return AM_TOKEN__JAVACFLAGS;
+    case _VALAFLAGS:           return AM_TOKEN__VALAFLAGS;
     case _FCFLAGS:              return AM_TOKEN__FCFLAGS;
     case _OBJCFLAGS:            return AM_TOKEN__OBJCFLAGS;
     case _LFLAGS:               return AM_TOKEN__LFLAGS;
@@ -148,6 +151,7 @@ amp_am_automake_variable (AnjutaToken *token)
     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_VALAFLAGS:     return AM_TOKEN_TARGET_VALAFLAGS;
     case TARGET_FCFLAGS:        return AM_TOKEN_TARGET_FCFLAGS;
     case TARGET_OBJCFLAGS:      return AM_TOKEN_TARGET_OBJCFLAGS;
     case TARGET_LFLAGS:         return AM_TOKEN_TARGET_LFLAGS;
@@ -542,6 +546,7 @@ automake_token:
 	|  _CFLAGS
 	|  _CXXFLAGS
 	|  _JAVACFLAGS
+	|  _VALAFLAGS
 	|  _FCFLAGS
 	|  _OBJCFLAGS
 	|  _LFLAGS
@@ -551,6 +556,7 @@ automake_token:
 	|  TARGET_CFLAGS
 	|  TARGET_CXXFLAGS
 	|  TARGET_JAVACFLAGS
+	|  TARGET_VALAFLAGS
 	|  TARGET_FCFLAGS
 	|  TARGET_OBJCFLAGS
 	|  TARGET_LFLAGS
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index eae4325..79a63bd 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -934,7 +934,7 @@ project_load_target (AmpProject *project, AnjutaToken *name, AnjutaTokenType tok
 
 		/* Create target */
 		target = amp_target_new (value, info->base.type, install, flags, NULL);
-		//fprintf(stderr, "create target %p\n", target);
+		//fprintf(stderr, "create target %s %p\n", value, target);
 		if (target != NULL)
 		{
 			amp_target_add_token (target, ANJUTA_TOKEN_ARGUMENT, arg);
@@ -1289,6 +1289,7 @@ project_load_subdirs (AmpProject *project, AnjutaToken *list, AnjutaAmGroupNode
 		gchar *value;
 		
 		value = anjuta_token_evaluate (arg);
+		if (value == NULL) continue;		/* Empty value, a comment of a quote by example */
 		
 		/* Skip ., it is a special case, used to defined build order */
 		if (strcmp (value, ".") != 0)
@@ -1408,6 +1409,7 @@ amp_project_set_am_variable (AmpProject* project, AnjutaAmGroupNode* group, Anju
 	case AM_TOKEN__CFLAGS:
 	case AM_TOKEN__CXXFLAGS:
 	case AM_TOKEN__JAVACFLAGS:
+	case AM_TOKEN__VALAFLAGS:
 	case AM_TOKEN__FCFLAGS:
 	case AM_TOKEN__OBJCFLAGS:
 	case AM_TOKEN__LFLAGS:
@@ -1419,6 +1421,7 @@ amp_project_set_am_variable (AmpProject* project, AnjutaAmGroupNode* group, Anju
 	case AM_TOKEN_TARGET_CFLAGS:
 	case AM_TOKEN_TARGET_CXXFLAGS:
 	case AM_TOKEN_TARGET_JAVACFLAGS:
+	case AM_TOKEN_TARGET_VALAFLAGS:
 	case AM_TOKEN_TARGET_FCFLAGS:
 	case AM_TOKEN_TARGET_OBJCFLAGS:
 	case AM_TOKEN_TARGET_LFLAGS:
diff --git a/plugins/am-project/am-properties.c b/plugins/am-project/am-properties.c
index 06a5628..30a7022 100644
--- a/plugins/am-project/am-properties.c
+++ b/plugins/am-project/am-properties.c
@@ -57,7 +57,8 @@ static AmpProperty AmpGroupProperties[] = {
 	{{N_("C preprocessor flags:"),			ANJUTA_PROJECT_PROPERTY_LIST,  	ANJUTA_PROJECT_PROPERTY_READ_WRITE,	NULL, 	NULL}, 	AM_TOKEN__CPPFLAGS, 		0, 	AM_PROPERTY_IN_MAKEFILE,	NULL},
 	{{N_("C compiler flags:"), 				ANJUTA_PROJECT_PROPERTY_LIST, 	ANJUTA_PROJECT_PROPERTY_READ_WRITE, 	NULL, 	NULL}, 	AM_TOKEN__CFLAGS, 			0, 	AM_PROPERTY_IN_MAKEFILE, 	NULL},
 	{{N_("C++ compiler flags:"), 			ANJUTA_PROJECT_PROPERTY_LIST, 	ANJUTA_PROJECT_PROPERTY_READ_WRITE,	NULL, 	NULL}, 	AM_TOKEN__CXXFLAGS, 		0, 	AM_PROPERTY_IN_MAKEFILE, 	NULL},
-	{{N_("Java Compiler flags:"), 			ANJUTA_PROJECT_PROPERTY_LIST,  	ANJUTA_PROJECT_PROPERTY_READ_WRITE,	NULL, 	NULL}, 	AM_TOKEN__JAVACFLAGS,		0, 	AM_PROPERTY_IN_MAKEFILE, 	NULL},
+	{{N_("Java compiler flags:"), 			ANJUTA_PROJECT_PROPERTY_LIST,  	ANJUTA_PROJECT_PROPERTY_READ_WRITE,	NULL, 	NULL}, 	AM_TOKEN__JAVACFLAGS,		0, 	AM_PROPERTY_IN_MAKEFILE, 	NULL},
+	{{N_("Vala compiler flags:"), 			ANJUTA_PROJECT_PROPERTY_LIST, 	ANJUTA_PROJECT_PROPERTY_READ_WRITE,	NULL, 	NULL}, 	AM_TOKEN__VALAFLAGS, 		0, 	AM_PROPERTY_IN_MAKEFILE, 	NULL},
 	{{N_("Fortan compiler flags:"), 			ANJUTA_PROJECT_PROPERTY_LIST, 	ANJUTA_PROJECT_PROPERTY_READ_WRITE,	NULL, 	NULL}, 	AM_TOKEN__FCFLAGS, 			0, 	AM_PROPERTY_IN_MAKEFILE, 	NULL},
 	{{N_("Objective C compiler flags:"),	ANJUTA_PROJECT_PROPERTY_LIST, 	ANJUTA_PROJECT_PROPERTY_READ_WRITE, 	NULL, 	NULL}, 	AM_TOKEN__OBJCFLAGS, 		0, 	AM_PROPERTY_IN_MAKEFILE, 	NULL},
 	{{N_("Lex/Flex flags:"), 					ANJUTA_PROJECT_PROPERTY_LIST, 	ANJUTA_PROJECT_PROPERTY_READ_WRITE, 	NULL, 	NULL}, 	AM_TOKEN__LFLAGS, 			0, 	AM_PROPERTY_IN_MAKEFILE, 	NULL},
@@ -77,7 +78,8 @@ static AmpProperty AmpTargetProperties[] = {
 	{{N_("C preprocessor flags:"),			ANJUTA_PROJECT_PROPERTY_LIST, 			ANJUTA_PROJECT_PROPERTY_READ_WRITE,	NULL,	NULL},	AM_TOKEN_TARGET_CPPFLAGS,	0, 	AM_PROPERTY_IN_MAKEFILE,	NULL},
 	{{N_("C compiler flags:"),					ANJUTA_PROJECT_PROPERTY_LIST, 			ANJUTA_PROJECT_PROPERTY_READ_WRITE,	NULL,	NULL},	AM_TOKEN_TARGET_CFLAGS,		0, 	AM_PROPERTY_IN_MAKEFILE,	NULL},
 	{{N_("C++ compiler flags:"),			ANJUTA_PROJECT_PROPERTY_LIST, 			ANJUTA_PROJECT_PROPERTY_READ_WRITE,	NULL,	NULL},	AM_TOKEN_TARGET_CXXFLAGS,	0, 	AM_PROPERTY_IN_MAKEFILE,	NULL},
-	{{N_("Java Compiler flags:"),				ANJUTA_PROJECT_PROPERTY_LIST, 			ANJUTA_PROJECT_PROPERTY_READ_WRITE,	NULL,	NULL},	AM_TOKEN_TARGET_JAVACFLAGS,0, 	AM_PROPERTY_IN_MAKEFILE,	NULL},
+	{{N_("Java compiler flags:"),				ANJUTA_PROJECT_PROPERTY_LIST, 			ANJUTA_PROJECT_PROPERTY_READ_WRITE,	NULL,	NULL},	AM_TOKEN_TARGET_JAVACFLAGS,0, 	AM_PROPERTY_IN_MAKEFILE,	NULL},
+	{{N_("Vala compiler flags:"),				ANJUTA_PROJECT_PROPERTY_LIST, 			ANJUTA_PROJECT_PROPERTY_READ_WRITE,	NULL,	NULL},	AM_TOKEN_TARGET_VALAFLAGS,0, 	AM_PROPERTY_IN_MAKEFILE,	NULL},
 	{{N_("Fortan compiler flags:"),			ANJUTA_PROJECT_PROPERTY_LIST, 			ANJUTA_PROJECT_PROPERTY_READ_WRITE,	NULL,	NULL},	AM_TOKEN_TARGET_FCFLAGS,	0, 	AM_PROPERTY_IN_MAKEFILE,	NULL},
 	{{N_("Objective C compiler flags:"),	ANJUTA_PROJECT_PROPERTY_LIST, 			ANJUTA_PROJECT_PROPERTY_READ_WRITE,	NULL,	NULL},	AM_TOKEN_TARGET_OBJCFLAGS,0, 	AM_PROPERTY_IN_MAKEFILE,	NULL},
 	{{N_("Lex/Flex flags:"),						ANJUTA_PROJECT_PROPERTY_LIST, 			ANJUTA_PROJECT_PROPERTY_READ_WRITE,	NULL,	NULL},	AM_TOKEN_TARGET_LFLAGS,		0, 	AM_PROPERTY_IN_MAKEFILE,	NULL},
diff --git a/plugins/am-project/am-scanner.h b/plugins/am-project/am-scanner.h
index 0fecfe4..5cba7e9 100644
--- a/plugins/am-project/am-scanner.h
+++ b/plugins/am-project/am-scanner.h
@@ -70,6 +70,7 @@ typedef enum
 	AM_TOKEN__CFLAGS,
 	AM_TOKEN__CXXFLAGS,
 	AM_TOKEN__JAVACFLAGS,
+	AM_TOKEN__VALAFLAGS,
 	AM_TOKEN__FCFLAGS,
 	AM_TOKEN__OBJCFLAGS,
 	AM_TOKEN__LFLAGS,
@@ -79,6 +80,7 @@ typedef enum
 	AM_TOKEN_TARGET_CFLAGS,
 	AM_TOKEN_TARGET_CXXFLAGS,
 	AM_TOKEN_TARGET_JAVACFLAGS,
+	AM_TOKEN_TARGET_VALAFLAGS,
 	AM_TOKEN_TARGET_FCFLAGS,
 	AM_TOKEN_TARGET_OBJCFLAGS,
 	AM_TOKEN_TARGET_LFLAGS,
diff --git a/plugins/am-project/am-scanner.l b/plugins/am-project/am-scanner.l
index 6629947..88c767b 100644
--- a/plugins/am-project/am-scanner.l
+++ b/plugins/am-project/am-scanner.l
@@ -166,6 +166,8 @@ NAME          [^ \t\n\r:#=$"'`&@\\]*
 
 <INITIAL>AM_JAVACFLAGS				{ RETURN (_JAVACFLAGS);}
 
+<INITIAL>AM_VALAFLAGS				{ RETURN (_VALAFLAGS);}
+
 <INITIAL>AM_FCFLAGS					{ RETURN (_FCFLAGS);}
 
 <INITIAL>AM_OBJCFLAGS				{ RETURN (_OBJCFLAGS);}
@@ -184,6 +186,8 @@ NAME          [^ \t\n\r:#=$"'`&@\\]*
 
 <INITIAL>{NAME}_JAVACFLAGS			{ RETURN (TARGET_JAVACFLAGS);}
 
+<INITIAL>{NAME}_VALAFLAGS			{ RETURN (TARGET_VALAFLAGS);}
+
 <INITIAL>{NAME}_FCFLAGS				{ RETURN (TARGET_FCFLAGS);}
 
 <INITIAL>{NAME}_OBJCFLAGS			{ RETURN (TARGET_OBJCFLAGS);}



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