[anjuta] am-project: bgo#684770 - Adding a "Miscelaneous Data" objective ignores the given name
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] am-project: bgo#684770 - Adding a "Miscelaneous Data" objective ignores the given name
- Date: Sat, 13 Oct 2012 17:10:42 +0000 (UTC)
commit ab6ba6fd176483be417f58ba853cc32c60be7787
Author: SÃbastien Granjoux <seb sfo free fr>
Date: Sat Oct 13 18:18:16 2012 +0200
am-project: bgo#684770 - Adding a "Miscelaneous Data" objective ignores the given name
plugins/am-project/am-writer.c | 229 ++++++++++++++++++++++-----------------
plugins/am-project/amp-target.c | 14 +++-
plugins/am-project/amp-target.h | 1 +
3 files changed, 141 insertions(+), 103 deletions(-)
---
diff --git a/plugins/am-project/am-writer.c b/plugins/am-project/am-writer.c
index 91bdeda..9c50ff1 100644
--- a/plugins/am-project/am-writer.c
+++ b/plugins/am-project/am-writer.c
@@ -826,7 +826,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 (amp_target_node_get_install_directory (target) != NULL ? amp_target_node_get_install_directory (target) : info->install, "_", info->prefix, NULL);
// Get token corresponding to sibling and check if the target are compatible
args = NULL;
@@ -1393,148 +1393,173 @@ amp_property_rename_target (AmpProject *project, AnjutaProjectNode *node)
info = (AmpNodeInfo *)amp_project_get_type_info (project, anjuta_project_node_get_full_type (node));
g_string_append (new_name, info->prefix);
-
- // Check if the target already exist.
- after = TRUE;
- for (item = amp_group_node_get_token (AMP_GROUP_NODE (group), AM_GROUP_TARGET); item != NULL; item = g_list_next (item))
+ if ((anjuta_project_node_get_full_type (node) & ANJUTA_PROJECT_ID_MASK) == ANJUTA_PROJECT_DATA)
{
- existing_target_list = (AnjutaToken *)item->data;
- gchar *target_name = anjuta_token_evaluate (anjuta_token_first_word (existing_target_list));
- gboolean same;
+ list = amp_target_node_get_token (AMP_TARGET_NODE (node), AM_TOKEN__DATA);
- same = strcmp (target_name, new_name->str) == 0;
- g_free (target_name);
+ if ((list != NULL) && (list->data != NULL))
+ {
+ AnjutaToken *old_token;
+ AnjutaToken *parent;
- if (after)
+ parent = (AnjutaToken *)list->data;
+ old_token = anjuta_token_first_word (parent);
+ if (old_token != NULL)
+ {
+ AnjutaToken *token;
+
+
+ token = anjuta_token_new_string (ANJUTA_TOKEN_ADDED, new_name->str);
+ update = anjuta_token_insert_word_after (parent, old_token, token);
+ anjuta_token_remove_word (old_token);
+ update = parent;
+ }
+ }
+ }
+ else
+ {
+ // Check if the target already exist.
+ after = TRUE;
+ for (item = amp_group_node_get_token (AMP_GROUP_NODE (group), AM_GROUP_TARGET); item != NULL; item = g_list_next (item))
{
- GList *list;
- GList *item;
+ existing_target_list = (AnjutaToken *)item->data;
+ gchar *target_name = anjuta_token_evaluate (anjuta_token_first_word (existing_target_list));
+ gboolean same;
- list = amp_target_node_get_token (AMP_TARGET_NODE (node), ANJUTA_TOKEN_ARGUMENT);
- for (item = g_list_first (list); item != NULL; item = g_list_next (item))
+ same = strcmp (target_name, new_name->str) == 0;
+ g_free (target_name);
+
+ if (after)
{
- AnjutaToken *arg = (AnjutaToken *)item->data;
- AnjutaToken *target_list;
+ GList *list;
+ GList *item;
- if (arg != NULL)
+ list = amp_target_node_get_token (AMP_TARGET_NODE (node), ANJUTA_TOKEN_ARGUMENT);
+ for (item = g_list_first (list); item != NULL; item = g_list_next (item))
{
- target_list = anjuta_token_list (arg);
- if (anjuta_token_list (target_list) == existing_target_list)
+ AnjutaToken *arg = (AnjutaToken *)item->data;
+ AnjutaToken *target_list;
+
+ if (arg != NULL)
{
- /* token in group_node are stored in reverse order */
- after = FALSE;
- break;
+ target_list = anjuta_token_list (arg);
+ if (anjuta_token_list (target_list) == existing_target_list)
+ {
+ /* token in group_node are stored in reverse order */
+ after = FALSE;
+ break;
+ }
}
}
}
- }
- if (same)
- {
- existing_target_list = anjuta_token_last_item (existing_target_list);
- break;
+ if (same)
+ {
+ existing_target_list = anjuta_token_last_item (existing_target_list);
+ break;
+ }
+ existing_target_list = NULL;
}
- existing_target_list = NULL;
- }
- if (existing_target_list != NULL)
- {
- GList *token_list;
+ if (existing_target_list != NULL)
+ {
+ GList *token_list;
- /* Get old tokens */
- token_list = g_list_copy (amp_target_node_get_token (AMP_TARGET_NODE (node), ANJUTA_TOKEN_ARGUMENT));
+ /* Get old tokens */
+ token_list = g_list_copy (amp_target_node_get_token (AMP_TARGET_NODE (node), ANJUTA_TOKEN_ARGUMENT));
- /* Add target in already existing list */
- amp_target_add_in_list (project, existing_target_list, node, after, NULL);
+ /* Add target in already existing list */
+ amp_target_add_in_list (project, existing_target_list, node, after, NULL);
- /* Remove old token */
- amp_target_node_delete_token (project, AMP_TARGET_NODE (node), token_list, NULL);
- g_list_free (token_list);
- }
- else
- {
- list = amp_target_node_get_token (AMP_TARGET_NODE (node), ANJUTA_TOKEN_ARGUMENT);
- for (item = g_list_first (list); item != NULL; item = g_list_next (item))
+ /* Remove old token */
+ amp_target_node_delete_token (project, AMP_TARGET_NODE (node), token_list, NULL);
+ g_list_free (token_list);
+ }
+ else
{
- AnjutaToken *arg = (AnjutaToken *)item->data;
- AnjutaToken *target_list;
+ list = amp_target_node_get_token (AMP_TARGET_NODE (node), ANJUTA_TOKEN_ARGUMENT);
+ for (item = g_list_first (list); item != NULL; item = g_list_next (item))
+ {
+ AnjutaToken *arg = (AnjutaToken *)item->data;
+ AnjutaToken *target_list;
- if (arg == NULL) continue;
+ if (arg == NULL) continue;
- target_list = anjuta_token_list (arg);
+ target_list = anjuta_token_list (arg);
- if (anjuta_token_nth_word (target_list, 1) == NULL)
- {
- /* Only one target in list, just replace list name */
- AnjutaToken *target_variable = anjuta_token_list (target_list);
-
- if (target_variable != NULL)
+ if (anjuta_token_nth_word (target_list, 1) == NULL)
{
- AnjutaToken *old_token;
+ /* Only one target in list, just replace list name */
+ AnjutaToken *target_variable = anjuta_token_list (target_list);
- old_token = anjuta_token_first_word (target_variable);
- if (old_token != NULL)
+ if (target_variable != NULL)
{
- AnjutaToken *token;
-
- token = anjuta_token_new_string (ANJUTA_TOKEN_ADDED, new_name->str);
- update = anjuta_token_insert_word_after (target_variable, old_token, token);
- anjuta_token_remove_word (old_token);
- update = target_variable;
- }
- }
- }
- else
- {
- gchar *old_target;
- AmpNodeInfo *info;
- gboolean after = TRUE;
- AnjutaToken *sibling = NULL;
- AnjutaTokenStyle *style;
- AnjutaToken *token;
+ AnjutaToken *old_token;
- old_target = anjuta_token_evaluate (arg);
+ old_token = anjuta_token_first_word (target_variable);
+ if (old_token != NULL)
+ {
+ AnjutaToken *token;
- /* Find sibling target */
- if (anjuta_token_first_word (target_list) == arg)
- {
- sibling = anjuta_token_next_word (arg);
- after = FALSE;
+ token = anjuta_token_new_string (ANJUTA_TOKEN_ADDED, new_name->str);
+ update = anjuta_token_insert_word_after (target_variable, old_token, token);
+ anjuta_token_remove_word (old_token);
+ update = target_variable;
+ }
+ }
}
else
{
- for (sibling = anjuta_token_first_word (target_list); sibling != NULL; sibling = anjuta_token_next_word (sibling))
+ gchar *old_target;
+ AmpNodeInfo *info;
+ gboolean after = TRUE;
+ AnjutaToken *sibling = NULL;
+ AnjutaTokenStyle *style;
+ AnjutaToken *token;
+
+ old_target = anjuta_token_evaluate (arg);
+
+ /* Find sibling target */
+ if (anjuta_token_first_word (target_list) == arg)
{
- if (anjuta_token_next_word (sibling) == arg) break;
+ sibling = anjuta_token_next_word (arg);
+ after = FALSE;
+ }
+ else
+ {
+ for (sibling = anjuta_token_first_word (target_list); sibling != NULL; sibling = anjuta_token_next_word (sibling))
+ {
+ if (anjuta_token_next_word (sibling) == arg) break;
+ }
+ after = TRUE;
}
- after = TRUE;
- }
- /* More than one target, remove target in list */
- arg = anjuta_token_remove_word (arg);
- if (arg != NULL) amp_group_node_update_makefile (AMP_GROUP_NODE (group), arg);
+ /* More than one target, remove target in list */
+ arg = anjuta_token_remove_word (arg);
+ if (arg != NULL) amp_group_node_update_makefile (AMP_GROUP_NODE (group), arg);
- /* Add target in new list */
- style = anjuta_token_style_new_from_base (project->am_space_list);
- anjuta_token_style_update (style, target_list);
+ /* Add target in new list */
+ style = anjuta_token_style_new_from_base (project->am_space_list);
+ anjuta_token_style_update (style, target_list);
- info = (AmpNodeInfo *)amp_project_get_type_info (project, anjuta_project_node_get_full_type (node));
- target_list = amp_project_write_target (AMP_GROUP_NODE (group), info->token, new_name->str, after, sibling);
+ info = (AmpNodeInfo *)amp_project_get_type_info (project, anjuta_project_node_get_full_type (node));
+ target_list = amp_project_write_target (AMP_GROUP_NODE (group), info->token, new_name->str, after, sibling);
- token = anjuta_token_new_string (ANJUTA_TOKEN_ARGUMENT | ANJUTA_TOKEN_ADDED, old_target);
- anjuta_token_insert_word_after (target_list, NULL, token);
+ token = anjuta_token_new_string (ANJUTA_TOKEN_ARGUMENT | ANJUTA_TOKEN_ADDED, old_target);
+ anjuta_token_insert_word_after (target_list, NULL, token);
- /* Try to use the same style than the current target list */
- anjuta_token_style_format (style, target_list);
- anjuta_token_style_free (style);
+ /* Try to use the same style than the current target list */
+ anjuta_token_style_format (style, target_list);
+ anjuta_token_style_free (style);
- amp_group_node_update_makefile (AMP_GROUP_NODE (group), token);
- amp_target_node_add_token (AMP_TARGET_NODE (node), ANJUTA_TOKEN_ARGUMENT, token);
+ amp_group_node_update_makefile (AMP_GROUP_NODE (group), token);
+ amp_target_node_add_token (AMP_TARGET_NODE (node), ANJUTA_TOKEN_ARGUMENT, token);
- g_free (old_target);
+ g_free (old_target);
- update = anjuta_token_list (target_list);
+ update = anjuta_token_list (target_list);
+ }
}
}
}
diff --git a/plugins/am-project/amp-target.c b/plugins/am-project/amp-target.c
index 71bfbfc..189d6f0 100644
--- a/plugins/am-project/amp-target.c
+++ b/plugins/am-project/amp-target.c
@@ -243,6 +243,13 @@ amp_target_node_update_node (AmpTargetNode *node, AmpTargetNode *new_node)
new_node->tokens = NULL;
}
+/* Get install directory */
+const gchar *
+amp_target_node_get_install_directory (AmpTargetNode *node)
+{
+ return node->install;
+}
+
/* The target has changed which could change its children */
void
amp_target_changed (AmpTargetNode *node)
@@ -319,7 +326,12 @@ amp_target_node_new (const gchar *name, AnjutaProjectNodeType type, const gchar
node = g_object_new (AMP_TYPE_TARGET_NODE, NULL);
amp_target_node_set_type (node, type);
node->base.name = g_strdup (name);
- node->install = g_strdup (install);
+ if ((install == NULL) && ((type & ANJUTA_PROJECT_ID_MASK) == ANJUTA_PROJECT_DATA)) {
+ node->install = g_strdup (name);
+ }
+ else {
+ node->install = g_strdup (install);
+ }
node->flags = flags;
amp_node_property_add_mandatory (ANJUTA_PROJECT_NODE (node));
diff --git a/plugins/am-project/amp-target.h b/plugins/am-project/amp-target.h
index 9d674f8..c1eb01d 100644
--- a/plugins/am-project/amp-target.h
+++ b/plugins/am-project/amp-target.h
@@ -72,6 +72,7 @@ AmpTargetNode* amp_target_node_new (const gchar *name, AnjutaProjectNodeType typ
AmpTargetNode* amp_target_node_new_valid (const gchar *name, AnjutaProjectNodeType type, const gchar *install, gint flags, AnjutaProjectNode *parent, GError **error);
void amp_target_node_free (AmpTargetNode *node);
void amp_target_node_update_node (AmpTargetNode *node, AmpTargetNode *new_node);
+const gchar *amp_target_node_get_install_directory (AmpTargetNode *node);
void amp_target_changed (AmpTargetNode *node);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]