[anjuta] am-project: Allow to enable a property with another one



commit 4368e62df6e9485c57a0e63cfd31f033e22981c9
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Sun Apr 17 22:57:32 2011 +0200

    am-project: Allow to enable a property with another one

 plugins/am-project/am-project-private.h |    4 +-
 plugins/am-project/am-project.c         |   22 ++++----
 plugins/am-project/am-properties.c      |   15 +++--
 plugins/am-project/am-writer.c          |   14 ++++-
 plugins/am-project/tests/properties.at  |   96 +++++++++++++++++++++++++++++++
 5 files changed, 132 insertions(+), 19 deletions(-)
---
diff --git a/plugins/am-project/am-project-private.h b/plugins/am-project/am-project-private.h
index 7c19e43..38ff395 100644
--- a/plugins/am-project/am-project-private.h
+++ b/plugins/am-project/am-project-private.h
@@ -30,7 +30,8 @@ G_BEGIN_DECLS
 typedef enum {
 	AM_PROPERTY_IN_CONFIGURE = 1 << 0,
 	AM_PROPERTY_IN_MAKEFILE = 1 << 1,
-	AM_PROPERTY_DIRECTORY = 1 << 2,			/* Directory property (having dir suffix) */
+	AM_PROPERTY_DIRECTORY = 1 << 2,						/* Directory property (having dir suffix) */
+	AM_PROPERTY_DISABLE_FOLLOWING = 1 << 3,		/* Disable following property if true */
 } AmpPropertyFlag;
 
 
@@ -41,6 +42,7 @@ struct _AmpProperty {
 	const gchar *suffix;
 	AmpPropertyFlag flags;
 	AnjutaToken *token;
+	AmpProperty *link;			/* Link to a boolean property disabling this one */
 };
 
 struct _AmpProject {
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 2086ce4..b3e93d1 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -112,77 +112,77 @@ static AmpNodeInfo AmpNodeInformations[] = {
 	N_("Shared Library"),
 	"application/x-sharedlib"},
 	AM_TOKEN__LTLIBRARIES,
-	"_LTLIBRARIES",
+	"LTLIBRARIES",
 	"lib"},
 	
 	{{ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_PRIMARY |  ANJUTA_PROJECT_STATICLIB,
 	N_("Static Library"),
 	"application/x-archive"},
 	AM_TOKEN__LIBRARIES,
-	"_LIBRARIES",
+	"LIBRARIES",
 	"lib"},
 
 	{{ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_PRIMARY | ANJUTA_PROJECT_PROGRAM | ANJUTA_PROJECT_EXECUTABLE,
 	N_("Program"),
 	"application/x-executable"},
 	AM_TOKEN__PROGRAMS,
-	"_PROGRAMS",
+	"PROGRAMS",
 	"bin"},
 
 	{{ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_PYTHON,
 	N_("Python Module"),
 	"application/x-python"},
 	AM_TOKEN__PYTHON,
-	"_PYTHON",
+	"PYTHON",
 	"python"},
 	
 	{{ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_JAVA,
 	N_("Java Module"),
 	"application/x-java"},
 	AM_TOKEN__JAVA,
-	"_JAVA",
+	"JAVA",
 	"java"},
 	
 	{{ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_LISP,
 	N_("Lisp Module"),
 	"text/plain"},
 	AM_TOKEN__LISP,
-	"_LISP",
+	"LISP",
 	"lisp"},
 	
 	{{ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_HEADER,
 	N_("Header Files"),
 	"text/x-chdr"},
 	AM_TOKEN__HEADERS,
-	"_HEADERS",
+	"HEADERS",
 	"include"},
 	
 	{{ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_MAN,
 	N_("Man Documentation"),
 	"text/x-troff-man"},
 	AM_TOKEN__MANS,
-	"_MANS",
+	"MANS",
 	"man"},
 
 	{{ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_INFO,
 	N_("Info Documentation"),
 	"application/x-tex-info"},
 	AM_TOKEN__TEXINFOS,
-	"_TEXINFOS",
+	"TEXINFOS",
 	"info"},
 	
 	{{ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_DATA,
 	N_("Miscellaneous Data"),
 	"application/octet-stream"},
 	AM_TOKEN__DATA,
-	"_DATA",
+	"DATA",
 	"data"},
 	
 	{{ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_SCRIPT,
 	N_("Script"),
 	"text/x-shellscript"},
 	AM_TOKEN__SCRIPTS,
-	"_SCRIPTS",
+	"SCRIPTS",
 	"bin"},
 
 	{{ANJUTA_PROJECT_MODULE,
diff --git a/plugins/am-project/am-properties.c b/plugins/am-project/am-properties.c
index db616f9..93d30f1 100644
--- a/plugins/am-project/am-properties.c
+++ b/plugins/am-project/am-properties.c
@@ -195,7 +195,7 @@ static AmpProperty AmpTargetNodeProperties[] = {
 			N_("Build but do not install the target."),
 			"0"},
 		AM_TOKEN__PROGRAMS,	 3, NULL,
-		AM_PROPERTY_IN_MAKEFILE
+		AM_PROPERTY_IN_MAKEFILE | AM_PROPERTY_DISABLE_FOLLOWING
 	},
 	{
 		{N_("Installation directory:"),
@@ -360,14 +360,14 @@ static AmpProperty AmpProgramTargetProperties[] = {
 			N_("Build but do not install the target."),
 			"0"},
 		AM_TOKEN__PROGRAMS,	 3, "noinst_",
-		AM_PROPERTY_IN_MAKEFILE
+		AM_PROPERTY_IN_MAKEFILE | AM_PROPERTY_DISABLE_FOLLOWING
 	},
 	{
 		{N_("Installation directory:"),
 			ANJUTA_PROJECT_PROPERTY_STRING,
 			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("It has to be a standard directory or a custom one defined in group properties.")},
-		AM_TOKEN__PROGRAMS, 	6, "bin_",
+		AM_TOKEN__PROGRAMS, 	6, "bin",
 		AM_PROPERTY_IN_MAKEFILE | AM_PROPERTY_DIRECTORY
 	},
 	{
@@ -517,7 +517,7 @@ static AmpProperty AmpLibraryTargetProperties[] = {
 			N_("Build but do not install the target."),
 			"0"},
 		AM_TOKEN__PROGRAMS,	 3, "noinst_",
-		AM_PROPERTY_IN_MAKEFILE
+		AM_PROPERTY_IN_MAKEFILE | AM_PROPERTY_DISABLE_FOLLOWING
 	},
 	{
 		{N_("Installation directory:"),
@@ -706,7 +706,7 @@ static AmpProperty AmpDataTargetProperties[] = {
 			N_("Build but do not install the target."),
 			"0"},
 		AM_TOKEN__PROGRAMS,	 3, "noinst_",
-		AM_PROPERTY_IN_MAKEFILE
+		AM_PROPERTY_IN_MAKEFILE | AM_PROPERTY_DISABLE_FOLLOWING
 	},
 	{
 		{N_("Installation directory:"),
@@ -774,7 +774,7 @@ static AmpProperty AmpScriptTargetProperties[] = {
 			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
 			N_("Build but do not install the target.")},
 		AM_TOKEN__PROGRAMS,	 3, "noinst_",
-		AM_PROPERTY_IN_MAKEFILE
+		AM_PROPERTY_IN_MAKEFILE | AM_PROPERTY_DISABLE_FOLLOWING
 	},
 	{
 		{N_("Installation directory:"),
@@ -843,10 +843,13 @@ amp_create_property_list (GList **list, AmpProperty *properties)
 	if (*list == NULL)
 	{
 		AmpProperty *prop;
+		AmpProperty *link = NULL;
 
 		for (prop = properties; prop->base.name != NULL; prop++)
 		{
+			prop->link = link;
 			*list = g_list_prepend (*list, prop);
+			link = prop->flags & AM_PROPERTY_DISABLE_FOLLOWING ? prop : NULL; 
 		}
 		*list = g_list_reverse (*list);
 	}
diff --git a/plugins/am-project/am-writer.c b/plugins/am-project/am-writer.c
index ba62a9c..49b8a7b 100644
--- a/plugins/am-project/am-writer.c
+++ b/plugins/am-project/am-writer.c
@@ -815,7 +815,7 @@ amp_target_node_create_token (AmpProject  *project, AmpTargetNode *target, GErro
 	if (sibling == NULL) after = TRUE;
 	
 	/* Add in Makefile.am */
-	targetname = g_strconcat (info->install, info->prefix, NULL);
+	targetname = g_strconcat (info->install, "_", info->prefix, NULL);
 
 	// Get token corresponding to sibling and check if the target are compatible
 	args = NULL;
@@ -1325,6 +1325,16 @@ amp_property_rename_target (AmpProject *project, AnjutaProjectNode *node)
 		AmpProperty *nat_prop = (AmpProperty *)item->data;
 		AmpProperty *cust_prop;
 
+		/* Check if property is enabled by another property */
+		if (nat_prop->link != NULL)
+		{
+			AnjutaProjectProperty *en_prop;
+
+			en_prop = anjuta_project_node_get_property (node, (AnjutaProjectProperty *)nat_prop->link);
+
+			if ((en_prop->value != NULL) && (*en_prop->value == '1')) continue;
+		}
+		
 		cust_prop = (AmpProperty *)anjuta_project_node_get_property (node, (AnjutaProjectProperty *)nat_prop);
 		if ((cust_prop == nat_prop) || (g_strcmp0 (cust_prop->base.value, nat_prop->base.value) == 0))
 		{
@@ -1332,6 +1342,7 @@ amp_property_rename_target (AmpProject *project, AnjutaProjectNode *node)
 			if (nat_prop->base.type == ANJUTA_PROJECT_PROPERTY_STRING)
 			{
 				g_string_append (new_name, nat_prop->suffix);
+				g_string_append_c (new_name, '_');
 			}
 		}
 		else
@@ -1350,6 +1361,7 @@ amp_property_rename_target (AmpProject *project, AnjutaProjectNode *node)
 				{
 					g_string_append (new_name, cust_prop->base.value);
 				}
+				g_string_append_c (new_name, '_');
 				break;
 			case ANJUTA_PROJECT_PROPERTY_BOOLEAN:
 				if ((cust_prop->base.value != NULL) && (g_strcmp0 (cust_prop->base.value, nat_prop->base.value) != 0))
diff --git a/plugins/am-project/tests/properties.at b/plugins/am-project/tests/properties.at
index c2be8af..8320808 100644
--- a/plugins/am-project/tests/properties.at
+++ b/plugins/am-project/tests/properties.at
@@ -570,4 +570,100 @@ AT_CHECK([diff -b output expect])
 
 
 
+AT_DATA([expect],
+[[    GROUP (): empty16
+        PROPERTY (Installation directories): plugindir = 
+        TARGET (): target1
+            PROPERTY (Installation directory): bindir
+            PROPERTY (Libraries): $(GDL_LIBS)
+            SOURCE (): source2
+        TARGET (): target2
+            PROPERTY (Installation directory): bindir
+            PROPERTY (Libraries): $(GDL_LIBS)
+            SOURCE (): source1
+        TARGET (): library1.la
+            PROPERTY (Do not install): true
+            PROPERTY (Libraries): $(GDL_LIBS)
+]])
+AT_DATA([reference.am],
+[[
+bin_PROGRAMS = target1 \
+        target2
+
+target1_SOURCES =  \
+	source2
+
+target1_LDADD = $(GDL_LIBS)
+
+target2_SOURCES =  \
+	source1
+
+target2_LDADD = $(GDL_LIBS)
+
+plugindir = 
+noinst_LTLIBRARIES =  \
+	library1.la
+
+library1_la_LIBADD = $(GDL_LIBS)
+]])
+AT_PARSER_CHECK([load empty15 \
+		move empty16 \
+		set 0:2 noinst 1 \
+		list \
+		save])
+AT_CHECK([diff -b empty16/Makefile.am reference.am])
+AT_PARSER_CHECK([load empty16 \
+		 list])
+AT_CHECK([diff -b output expect])
+
+
+
+AT_DATA([expect],
+[[    GROUP (): empty17
+        PROPERTY (Installation directories): plugindir = 
+        TARGET (): target1
+            PROPERTY (Installation directory): bindir
+            PROPERTY (Libraries): $(GDL_LIBS)
+            SOURCE (): source2
+        TARGET (): target2
+            PROPERTY (Installation directory): bindir
+            PROPERTY (Libraries): $(GDL_LIBS)
+            SOURCE (): source1
+        TARGET (): library1.la
+            PROPERTY (Installation directory): libdir
+            PROPERTY (Libraries): $(GDL_LIBS)
+]])
+AT_DATA([reference.am],
+[[
+bin_PROGRAMS = target1 \
+        target2
+
+target1_SOURCES =  \
+	source2
+
+target1_LDADD = $(GDL_LIBS)
+
+target2_SOURCES =  \
+	source1
+
+target2_LDADD = $(GDL_LIBS)
+
+plugindir = 
+lib_LTLIBRARIES =  \
+	library1.la
+
+library1_la_LIBADD = $(GDL_LIBS)
+]])
+AT_PARSER_CHECK([load empty16 \
+		move empty17 \
+		set 0:2 noinst 0 \
+		list \
+		save])
+AT_CHECK([diff -b empty17/Makefile.am reference.am])
+AT_PARSER_CHECK([load empty17 \
+		 list])
+AT_CHECK([diff -b output expect])
+
+
+
 AT_CLEANUP



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