static gboolean amp_module_node_update (AmpNode *node, AmpNode *new_node) { AMP_MODULE_NODE(node)->module = AMP_MODULE_NODE(new_node)->module; return TRUE; }
gboolean amp_module_node_create_token (AmpProject *project, AmpModuleNode *module, GError **error) { gboolean after; AnjutaToken *token; AnjutaToken *prev; AnjutaToken *next; AnjutaProjectNode *sibling; /* Add in configure.ac */ /* Find a sibling if possible */ prev = NULL; after = TRUE; for (sibling = anjuta_project_node_prev_sibling (ANJUTA_PROJECT_NODE (module)); sibling != NULL; sibling = anjuta_project_node_prev_sibling (sibling)) { if (anjuta_project_node_get_node_type (sibling) == ANJUTA_PROJECT_MODULE) { prev = amp_module_node_get_token (AMP_MODULE_NODE (sibling)); if (prev != NULL) { prev = anjuta_token_list (prev); break; } } } if (prev == NULL) { after = FALSE; for (sibling = anjuta_project_node_next_sibling (ANJUTA_PROJECT_NODE (module)); sibling != NULL; sibling = anjuta_project_node_next_sibling (sibling)) { if (anjuta_project_node_get_node_type (sibling) == ANJUTA_PROJECT_MODULE) { prev = amp_module_node_get_token (AMP_MODULE_NODE (sibling)); if (prev != NULL) { prev = anjuta_token_list (prev); break; } } } } token = amp_project_write_module_list (project, anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (module)), after, prev); next = anjuta_token_next (token); next = anjuta_token_next (next); next = anjuta_token_next (next); amp_module_node_add_token (module, next); amp_project_update_configure (project, token); return TRUE; }
static gboolean amp_module_node_write (AmpNode *node, AmpNode *amp_parent, AmpProject *project, GError **error) { AnjutaProjectNode *parent = ANJUTA_PROJECT_NODE (amp_parent); if ((parent != NULL) && (anjuta_project_node_get_node_type (parent) == ANJUTA_PROJECT_TARGET)) { AnjutaProjectNode *group = anjuta_project_node_parent (parent); AnjutaProjectPropertyInfo *group_cpp; AnjutaProjectPropertyInfo *target_cpp; AnjutaProjectPropertyInfo *target_lib; gchar *lib_flags; gchar *cpp_flags; gint type; group_cpp = amp_node_get_property_info_from_token (group, AM_TOKEN__CPPFLAGS, 0); type = anjuta_project_node_get_full_type (parent) & (ANJUTA_PROJECT_ID_MASK | ANJUTA_PROJECT_TYPE_MASK); switch (type) { case ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_PROGRAM: target_lib = amp_node_get_property_info_from_token (parent, AM_TOKEN_TARGET_LDADD, 0); break; case ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_STATICLIB: case ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_SHAREDLIB: case ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_LT_MODULE: target_lib = amp_node_get_property_info_from_token (parent, AM_TOKEN_TARGET_LIBADD, 0); break; default: break; } target_cpp = amp_node_get_property_info_from_token (parent, AM_TOKEN_TARGET_CPPFLAGS, 0); lib_flags = g_strconcat ("$(", anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (node)), "_LIBS)", NULL); cpp_flags = g_strconcat ("$(", anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (node)), "_CFLAGS)", NULL); if (!amp_node_property_has_flags (group, group_cpp->id, cpp_flags) && !amp_node_property_has_flags (ANJUTA_PROJECT_NODE (parent), target_cpp->id, cpp_flags)) { AnjutaProjectProperty *prop; prop = amp_node_property_add_flags (group, group_cpp->id, cpp_flags); amp_project_update_am_property (project, group, prop); } if (!amp_node_property_has_flags (parent, target_lib->id, lib_flags)) { AnjutaProjectProperty *prop; prop = amp_node_property_add_flags (parent, target_lib->id, lib_flags); amp_project_update_am_property (project, parent, prop); } g_free (lib_flags); g_free (cpp_flags); return TRUE; } else { return amp_module_node_create_token (project, AMP_MODULE_NODE (node), error); } }
static void amp_module_node_finalize (GObject *object) { AmpModuleNode *module = AMP_MODULE_NODE (object); g_list_foreach (module->base.properties, (GFunc)amp_property_free, NULL); G_OBJECT_CLASS (amp_module_node_parent_class)->finalize (object); }
static gboolean amp_module_node_erase (AmpNode *node, AmpNode *amp_parent, AmpProject *project, GError **error) { AnjutaProjectNode *parent = ANJUTA_PROJECT_NODE (amp_parent); if ((parent != NULL) && (anjuta_project_node_get_node_type (parent) == ANJUTA_PROJECT_TARGET)) { AnjutaProjectNode *group = anjuta_project_node_parent (parent); AnjutaProjectProperty *prop; AnjutaProjectPropertyInfo *group_cpp; AnjutaProjectPropertyInfo *target_cpp; AnjutaProjectPropertyInfo *target_lib; gchar *lib_flags; gchar *cpp_flags; gint type; lib_flags = g_strconcat ("$(", anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (node)), "_LIBS)", NULL); cpp_flags = g_strconcat ("$(", anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (node)), "_CFLAGS)", NULL); group_cpp = amp_node_get_property_info_from_token (group, AM_TOKEN__CPPFLAGS, 0); if (amp_node_property_has_flags (group, group_cpp->id, cpp_flags)) { /* Remove flags in group variable if not more target has this module */ gboolean used = FALSE; AnjutaProjectNode *target; for (target = anjuta_project_node_first_child (ANJUTA_PROJECT_NODE (group)); target != NULL; target = anjuta_project_node_next_sibling (target)) { if (anjuta_project_node_get_node_type (target) == ANJUTA_PROJECT_TARGET) { AnjutaProjectNode *module; for (module = anjuta_project_node_first_child (target); module != NULL; module = anjuta_project_node_next_sibling (module)) { if ((anjuta_project_node_get_node_type (module) == ANJUTA_PROJECT_MODULE) && (module != ANJUTA_PROJECT_NODE (node)) && (strcmp (anjuta_project_node_get_name (module), anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (node))) == 0)) { used = TRUE; break; } } } if (used) break; } if (!used) { AnjutaProjectProperty *prop; prop = amp_node_property_remove_flags (group, group_cpp->id, cpp_flags); if (prop != NULL) amp_project_update_am_property (project, group, prop); } } type = anjuta_project_node_get_full_type (ANJUTA_PROJECT_NODE (parent)) & (ANJUTA_PROJECT_ID_MASK | ANJUTA_PROJECT_TYPE_MASK); switch (type) { case ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_PROGRAM: target_lib = amp_node_get_property_info_from_token (parent, AM_TOKEN_TARGET_LDADD, 0); break; case ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_STATICLIB: case ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_SHAREDLIB: case ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_LT_MODULE: target_lib = amp_node_get_property_info_from_token (parent, AM_TOKEN_TARGET_LIBADD, 0); break; default: target_lib = NULL; break; } target_cpp = amp_node_get_property_info_from_token (parent, AM_TOKEN_TARGET_CPPFLAGS, 0); prop = amp_node_property_remove_flags (parent, target_cpp->id, cpp_flags); if (prop != NULL) amp_project_update_am_property (project, parent, prop); prop = amp_node_property_remove_flags (parent, target_lib->id, lib_flags); if (prop != NULL) amp_project_update_am_property (project, parent, prop); g_free (lib_flags); g_free (cpp_flags); return TRUE; } else { return amp_module_node_delete_token (project, AMP_MODULE_NODE (node), error); } }
gboolean amp_package_node_create_token (AmpProject *project, AmpPackageNode *package, GError **error) { AmpModuleNode *module; AnjutaProjectNode *sibling; gboolean after; AnjutaToken *token; AnjutaToken *prev; AnjutaToken *args; /* Get parent module */ module = AMP_MODULE_NODE (anjuta_project_node_parent_type (ANJUTA_PROJECT_NODE (package), ANJUTA_PROJECT_MODULE)); if (module == NULL) return FALSE; /* Add in configure.ac */ /* Find a sibling if possible */ if ((sibling = anjuta_project_node_prev_sibling (ANJUTA_PROJECT_NODE (package))) != NULL) { prev = amp_package_node_get_token (AMP_PACKAGE_NODE (sibling)); after = TRUE; args = anjuta_token_list (prev); } else if ((sibling = anjuta_project_node_next_sibling (ANJUTA_PROJECT_NODE (package))) != NULL) { prev = amp_package_node_get_token (AMP_PACKAGE_NODE (sibling)); after = FALSE; args = anjuta_token_list (prev); } else { prev = NULL; args = NULL; } /* Check if a valid source variable is already defined */ if (args == NULL) { args = amp_module_node_get_token (module); } if (args != NULL) { AnjutaTokenStyle *style; const gchar *name; name = anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (package)); style = anjuta_token_style_new_from_base (project->ac_space_list); //anjuta_token_style_update (style, args); token = anjuta_token_new_string (ANJUTA_TOKEN_NAME | ANJUTA_TOKEN_ADDED, name); if (after) { anjuta_token_insert_word_after (args, prev, token); } else { anjuta_token_insert_word_before (args, prev, token); } /* Try to use the same style than the current target list */ anjuta_token_style_format (style, args); anjuta_token_style_free (style); amp_project_update_configure (project, token); amp_package_node_add_token (package, token); } return TRUE; }