[anjuta] am-project: Support included file using m4_include in configure.ac file



commit 405b8d3fbe5bdb147bb4231b29daa7a23c049ac1
Author: SÃbastien Granjoux <seb sfo free fr>
Date:   Sun Oct 2 22:46:43 2011 +0200

    am-project: Support included file using m4_include in configure.ac file

 plugins/am-project/ac-parser.y      |   63 ++++++++++++++----
 plugins/am-project/ac-scanner.h     |   21 +++---
 plugins/am-project/ac-scanner.l     |  122 ++++++++++++++++++++++++-----------
 plugins/am-project/ac-writer.c      |   60 +++++++++---------
 plugins/am-project/am-project.c     |    6 +-
 plugins/am-project/tests/include.at |   31 +++++++++-
 6 files changed, 205 insertions(+), 98 deletions(-)
---
diff --git a/plugins/am-project/ac-parser.y b/plugins/am-project/ac-parser.y
index f8d7abd..b80af0a 100644
--- a/plugins/am-project/ac-parser.y
+++ b/plugins/am-project/ac-parser.y
@@ -2,17 +2,17 @@
 /*
  * ac-parser.y
  * Copyright (C) SÃbastien Granjoux 2009 <seb sfo free fr>
- * 
+ *
  * main.c is free software: you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
- * 
+ *
  * main.c is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  * See the GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License along
  * with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
@@ -33,7 +33,8 @@
 
 %}
 
-%token  EOL '\n'
+%token	END_OF_FILE
+%token	END_OF_LINE	'\n'
 
 %token  SPACE ' '
 
@@ -62,6 +63,7 @@
 /* M4 macros */
 
 %token  DNL
+%token	M4_INCLUDE
 
 
 /* Autoconf macros */
@@ -104,7 +106,7 @@
 %token	LT_INIT
 %token	LT_PREREQ
 %token	PKG_CHECK_MODULES
-%token	PKG_PROG_PKG_CONFIG	
+%token	PKG_PROG_PKG_CONFIG
 
 
 
@@ -183,7 +185,7 @@ file:
     /* empty */
 	| file  statement
 	;
-   
+
 statement:
     line
     | macro
@@ -204,10 +206,11 @@ line:
 
 macro:
     dnl
+    | include
 	| ac_macro_with_arg
 	| ac_macro_without_arg
     | ac_init
-	| pkg_check_modules 
+	| pkg_check_modules
 	| obsolete_ac_output
 	| ac_output
 	| ac_config_files
@@ -259,14 +262,23 @@ name:
  *----------------------------------------------------------------------------*/
 
 dnl:
-    DNL  not_eol_list  EOL {
+    DNL  not_eol_list  end_of_line {
 		$$ = anjuta_token_new_static (ANJUTA_TOKEN_COMMENT, NULL);
 		anjuta_token_merge ($$, $1);
 		anjuta_token_merge ($$, $2);
 		anjuta_token_merge ($$, $3);
 	}
     ;
-    
+
+include:
+    M4_INCLUDE arg_list {
+		$$ = anjuta_token_new_static (ANJUTA_TOKEN_LIST, NULL);
+		anjuta_token_merge ($$, $1);
+		anjuta_token_merge ($$, $2);
+		amp_ac_scanner_include (scanner, $$);
+	}
+	;
+
 
 pkg_check_modules:
     PKG_CHECK_MODULES arg_list {
@@ -289,7 +301,7 @@ ac_macro_with_arg:
 		anjuta_token_merge ($$, $2);
 	}
 	;
-	
+
 ac_macro_without_arg:
 	ac_macro_without_arg_token {
 		anjuta_token_set_type ($1, amp_ac_autoconf_macro ($1));
@@ -317,7 +329,7 @@ obsolete_ac_output:
         amp_ac_scanner_load_config (scanner, $2);
     }
 	;
-	
+
 ac_config_files:
     AC_CONFIG_FILES  arg_list {
 		$$ = anjuta_token_new_static (AC_TOKEN_AC_CONFIG_FILES, NULL);
@@ -370,7 +382,7 @@ arg_list_body:
     ;
 
 comment:
-    HASH not_eol_list EOL {
+    HASH not_eol_list end_of_line {
 		$$ = anjuta_token_new_static (ANJUTA_TOKEN_COMMENT, NULL);
 		anjuta_token_merge ($$, $1);
 		anjuta_token_merge ($$, $2);
@@ -497,7 +509,7 @@ arg:
         anjuta_token_merge_children ($1, $2);
         //fprintf(stdout, "arg merge\n");
         //anjuta_token_dump ($1);
-    }        
+    }
     ;
 
 arg_body:
@@ -612,12 +624,25 @@ spaces:
 	}
 	;
 
+
 /* Tokens
  *----------------------------------------------------------------------------*/
 
 not_eol_token:
     SPACE
-    | word_token    
+    | args_token
+    | HASH
+    | OPERATOR
+    | EQUAL
+    | LOWER
+    | GREATER
+    | NAME
+    | VARIABLE
+    | WORD
+    | any_macro
+    | M4_INCLUDE
+    | LEFT_BRACE
+    | RIGHT_BRACE
     ;
 
 not_brace_token:
@@ -632,11 +657,12 @@ not_brace_token:
     | VARIABLE
     | WORD
     | any_macro
+	| M4_INCLUDE
     ;
 
 space_token:
     SPACE
-    | EOL {
+    | END_OF_LINE {
 		anjuta_token_set_type ($1, ANJUTA_TOKEN_EOL);
 	}
     ;
@@ -658,6 +684,7 @@ not_operator_token:
     | VARIABLE
     | WORD
     | any_macro
+    | include
     ;
 
 word_token:
@@ -675,6 +702,7 @@ word_token:
     | VARIABLE
     | WORD
     | any_macro
+    | include
     ;
 
 any_macro:
@@ -727,4 +755,9 @@ ac_macro_with_arg_token:
 	| PKG_PROG_PKG_CONFIG
 	;
 
+end_of_line:
+	END_OF_LINE
+	| END_OF_FILE
+	;
+
 %%
diff --git a/plugins/am-project/ac-scanner.h b/plugins/am-project/ac-scanner.h
index f81d40c..9ca4ca1 100644
--- a/plugins/am-project/ac-scanner.h
+++ b/plugins/am-project/ac-scanner.h
@@ -2,17 +2,17 @@
 /*
  * ac-scanner.h
  * Copyright (C) SÃbastien Granjoux 2009 <seb sfo free fr>
- * 
+ *
  * main.c is free software: you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
- * 
+ *
  * main.c is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  * See the GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License along
  * with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
@@ -27,7 +27,7 @@
 
 G_BEGIN_DECLS
 
-/* Token location is found directly from token value. We don't maintain a 
+/* Token location is found directly from token value. We don't maintain a
  * independent position. */
 #define YYLTYPE AnjutaToken*
 #define YYSTYPE AnjutaToken*
@@ -38,15 +38,16 @@ AmpAcScanner *amp_ac_scanner_new (AmpProject *project);
 void amp_ac_scanner_free (AmpAcScanner *scanner);
 
 gboolean amp_ac_scanner_parse (AmpAcScanner *scanner, AnjutaTokenFile *file, GError **error);
-AnjutaToken* amp_ac_scanner_parse_token (AmpAcScanner *scanner, AnjutaToken *token, gint start, GError **error);
+AnjutaToken* amp_ac_scanner_parse_token (AmpAcScanner *scanner, AnjutaToken *root, AnjutaToken *content, gint start, GFile *filename, GError **error);
 
 void amp_ac_scanner_load_module (AmpAcScanner *scanner, AnjutaToken *module);
 void amp_ac_scanner_load_config (AmpAcScanner *scanner, AnjutaToken *list);
 void amp_ac_scanner_load_properties (AmpAcScanner *scanner, AnjutaToken *macro, AnjutaToken *args);
+void amp_ac_scanner_include (AmpAcScanner *scanner, AnjutaToken *list);
 
 void amp_ac_yyerror (YYLTYPE *loc, AmpAcScanner *scanner, char const *s);
 
-enum 
+enum
 {
 	/* Order is important as the backend will try to follow it */
 	AC_TOKEN_FIRST_ORDERED_MACRO = ANJUTA_TOKEN_USER,
@@ -61,7 +62,7 @@ enum
 	/* Options */
 	AC_TOKEN_AM_MAINTAINER_MODE,
 	AC_TOKEN_AC_ARG_ENABLE,
-	
+
 	/* Check for programs */
 	AC_TOKEN_AC_PROG_CC,
 	AC_TOKEN_AC_PROG_CPP,
@@ -76,7 +77,7 @@ enum
 	AC_TOKEN_PKG_PROG_PKG_CONFIG,
 	AC_TOKEN_AC_CHECK_PROG,
 	AC_TOKEN_AM_GLIB_GNU_GETTEXT,
-	
+
 	/* Check for libraries */
 	AC_TOKEN_PKG_CHECK_MODULES,
 	AC_TOKEN_AC_CHECK_LIB,
@@ -85,7 +86,7 @@ enum
 	AC_TOKEN_AC_HEADER_STDC,
 	AC_TOKEN_AC_CHECK_HEADERS,
 	AC_TOKEN_AC_EGREP_HEADER,
-	
+
 	/* Check for types & structures */
 	AC_TOKEN_AC_C_CONST,
 	AC_TOKEN_AC_OBJEXT,
@@ -101,7 +102,7 @@ enum
 	AC_TOKEN_OBSOLETE_AC_OUTPUT,
 	AC_TOKEN_AC_OUTPUT,
 	AC_TOKEN_LAST_ORDERED_MACRO,
-		
+
 	AC_TOKEN_SPACE_LIST,
 	AC_TOKEN_OPEN_STRING,
 	AC_TOKEN_CLOSE_STRING
diff --git a/plugins/am-project/ac-scanner.l b/plugins/am-project/ac-scanner.l
index a88e8fd..28d27a9 100644
--- a/plugins/am-project/ac-scanner.l
+++ b/plugins/am-project/ac-scanner.l
@@ -2,21 +2,21 @@
 /*
  * ac-scanner.l
  * Copyright (C) SÃbastien Granjoux 2009 <seb sfo free fr>
- * 
+ *
  * main.c is free software: you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
- * 
+ *
  * main.c is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  * See the GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License along
  * with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
- 
+
 %{
 
 #include "ac-scanner.h"
@@ -35,7 +35,7 @@
 #define YY_DECL static int ac_yylex (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner)
 
 //#define YY_USER_INIT {yy_flex_debug = 1;}
- 
+
 static gint amp_ac_scanner_parse_end (AmpAcScanner *scanner);
 
 #define RETURN(tok) *yylval = anjuta_token_stream_tokenize (yyextra->stream, tok, yyleng); \
@@ -50,9 +50,11 @@ struct _AmpAcScanner
     AmpProject *project;
 
     AnjutaToken *parsed;
+
+	gboolean eof;		/* TRUE to emit EOF at the end */
 };
 
-             
+
 %}
 
 %option reentrant stack noyywrap yylineno
@@ -64,7 +66,7 @@ struct _AmpAcScanner
 
 /* Necessary because autotools wrapper always looks for a file named "lex.yy.c",
  * not "lex.amp_ac_yy.c"
-%option outfile="lex.yy.c"*/			
+%option outfile="lex.yy.c"*/
 
 %option bison-bridge bison-locations
 
@@ -98,7 +100,7 @@ OTHER       [^ \t\r\v\n#\[\]\\(),=><$_A-Za-z_]+
 
 \\\n                    { RETURN (SPACE); }
 
-{NL}                    { RETURN (EOL); }
+{NL}                    { RETURN (END_OF_LINE); }
 
 {COMMENT}               { RETURN (HASH); }
 
@@ -120,6 +122,8 @@ OTHER       [^ \t\r\v\n#\[\]\\(),=><$_A-Za-z_]+
 
 dnl                     { RETURN (DNL); }
 
+m4_include\(			{ RETURN (M4_INCLUDE); }
+
 AC_ARG_ENABLE\(			{ RETURN (AC_ARG_ENABLE);}
 
 AC_C_CONST				{ RETURN (AC_C_CONST);}
@@ -147,11 +151,11 @@ AC_EXEEXT				{ RETURN (AC_EXEEXT); }
 AC_HEADER_STDC			{ RETURN (AC_HEADER_STDC); }
 
 AC_INIT\(               { RETURN (AC_INIT); }
- 
+
 AC_OBJEXT				{ RETURN (AC_OBJEXT); }
 
 AC_OUTPUT\(             { RETURN (OBSOLETE_AC_OUTPUT); }
- 
+
 AC_OUTPUT               { RETURN (AC_OUTPUT); }
 
 AC_PREREQ\(				{ RETURN (AC_PREREQ); }
@@ -163,34 +167,34 @@ AC_PROG_CPP				{ RETURN (AC_PROG_CPP);}
 AC_PROG_CXX				{ RETURN (AC_PROG_CXX);}
 
 IT_PROG_INTLTOOL\(		{ RETURN (IT_PROG_INTLTOOL);}
-                  
+
 AC_PROG_LEX				{ RETURN (AC_PROG_LEX);}
-                  
+
 AC_PROG_RANLIB			{ RETURN (AC_PROG_RANLIB);}
-                  
-AC_PROG_YACC			{ RETURN (AC_PROG_YACC);}	
-                  
+
+AC_PROG_YACC			{ RETURN (AC_PROG_YACC);}
+
 AC_SUBST\(				{ RETURN (AC_SUBST);}
-          
+
 AC_TYPE_SIZE_T			{ RETURN (AC_TYPE_SIZE_T);}
-          
+
 AC_TYPE_OFF_T			{ RETURN (AC_TYPE_OFF_T);}
-          
+
 AM_INIT_AUTOMAKE\(		{ RETURN (AM_INIT_AUTOMAKE);}
-                  
+
 AM_GLIB_GNU_GETTEXT\(   { RETURN (AM_GLIB_GNU_GETTEXT);}
-                     
+
 AM_MAINTAINER_MODE		{ RETURN (AM_MAINTAINER_MODE);}
-                     
+
 AM_PROG_LIBTOOL			{ RETURN (AM_PROG_LIBTOOL);}
-                     
-LT_INIT\(				{ RETURN (LT_INIT);}	
-         
+
+LT_INIT\(				{ RETURN (LT_INIT);}
+
 LT_PREREQ\(				{ RETURN (LT_PREREQ);}
 
 PKG_CHECK_MODULES\(     { RETURN (PKG_CHECK_MODULES); }
 
-PKG_PROG_PKG_CONFIG\(	{ RETURN (PKG_PROG_PKG_CONFIG);}	   
+PKG_PROG_PKG_CONFIG\(	{ RETURN (PKG_PROG_PKG_CONFIG);}
 
 {NAME}                  { RETURN (NAME); }
 
@@ -222,18 +226,34 @@ PKG_PROG_PKG_CONFIG\(	{ RETURN (PKG_PROG_PKG_CONFIG);}
 static gint
 amp_ac_scanner_parse_end (AmpAcScanner *scanner)
 {
-    scanner->parsed = anjuta_token_stream_get_root (scanner->stream);
-    yypop_buffer_state(scanner->scanner);
-    scanner->stream = anjuta_token_stream_pop (scanner->stream);
 
-    if (scanner->stream == NULL)
-    {
-        yyterminate();
-    }
-    else
-    {
-        return 1;
-    }
+   	if (scanner->stream == NULL)
+   	{
+		yyterminate();
+	}
+   	else
+   	{
+		if (scanner->eof)
+		{
+			scanner->eof = FALSE;
+			return END_OF_FILE;
+		}
+
+		yypop_buffer_state(scanner->scanner);
+    	scanner->stream = anjuta_token_stream_pop (scanner->stream);
+
+		if (scanner->stream == NULL)
+		{
+			yyterminate();
+		}
+		else
+		{
+			scanner->eof = anjuta_token_stream_get_current_file (scanner->stream) != NULL;
+
+			/* Continue parsing the parent file */
+			return 1;
+		}
+	}
 }
 
 /* Parser functions
@@ -273,19 +293,43 @@ amp_ac_scanner_load_properties (AmpAcScanner *scanner, AnjutaToken *macro, Anjut
     amp_project_load_properties (scanner->project, macro, list);
 }
 
+void
+amp_ac_scanner_include (AmpAcScanner *scanner, AnjutaToken *list)
+{
+	GFile *file;
+	AnjutaTokenFile *include;
+	AnjutaToken *token;
+	AnjutaToken *name;
+	gchar *filename;
+
+	name = anjuta_token_first_item (list);  	/* m4_include macro */
+	name = anjuta_token_next_item (name);		/* arguments list */
+	name = anjuta_token_first_item (name);		/* filename */
+	filename = g_strstrip (anjuta_token_evaluate (name));
+	//g_message ("read include =%s=", filename);
+	file = g_file_resolve_relative_path (anjuta_token_stream_get_current_directory (scanner->stream), filename);
+	g_message ("file %p current dir %p filename %s", file, anjuta_token_stream_get_current_directory (scanner->stream), filename);
+	g_free (filename);
+	include = anjuta_token_file_new (file);
+	token = anjuta_token_file_load (include, NULL);
+	amp_ac_scanner_parse_token (scanner, list, token, 0, file, NULL);
+	g_object_unref (file);
+}
 
 /* Public functions
  *---------------------------------------------------------------------------*/
 
 AnjutaToken *
-amp_ac_scanner_parse_token (AmpAcScanner *scanner, AnjutaToken *token, gint start, GError **error)
+amp_ac_scanner_parse_token (AmpAcScanner *scanner, AnjutaToken *root, AnjutaToken *content, gint start, GFile *filename, GError **error)
 {
     AnjutaToken *first;
     AnjutaTokenStream *stream;
 
-    stream = anjuta_token_stream_push (scanner->stream, NULL, token, NULL);
+    stream = anjuta_token_stream_push (scanner->stream, root, content, filename);
     first = anjuta_token_stream_get_root (stream);
 
+	scanner->eof = filename != NULL;
+
     if (scanner->stream != NULL)
     {
         /* Parse an included file or a expanded variable */
@@ -318,7 +362,7 @@ amp_ac_scanner_parse_token (AmpAcScanner *scanner, AnjutaToken *token, gint star
         do
         {
             gint yychar = ac_yylex (&yylval_param, &yylloc_param, scanner->scanner);
-        
+
             yylloc_param = yylval_param;
             status = amp_ac_yypush_parse (ps, yychar, &yylval_param, &yylloc_param, scanner);
 
diff --git a/plugins/am-project/ac-writer.c b/plugins/am-project/ac-writer.c
index 2105ae1..fd65bdf 100644
--- a/plugins/am-project/ac-writer.c
+++ b/plugins/am-project/ac-writer.c
@@ -57,7 +57,7 @@ anjuta_token_find_position (AnjutaToken *list, gboolean after, AnjutaTokenType t
 	{
 		AnjutaToken *last = NULL;
 		gboolean found = FALSE;
-		
+
 		for (tok = list; tok != NULL; tok = anjuta_token_next (tok))
 		{
 			AnjutaTokenType current = anjuta_token_get_type (tok);
@@ -70,7 +70,7 @@ anjuta_token_find_position (AnjutaToken *list, gboolean after, AnjutaTokenType t
 					/*  1. After the last similar macro
 					 *  2. After the last macro with a higher priority
 					 *  3. At the end of the file
-					 */ 
+					 */
 					if (current == type)
 					{
 						pos = tok;
@@ -116,7 +116,7 @@ anjuta_token_find_position (AnjutaToken *list, gboolean after, AnjutaTokenType t
 		}
 	}
 
-	
+
 	return pos;
 }
 
@@ -124,7 +124,7 @@ static AnjutaToken*
 find_tokens (AnjutaToken *list, AnjutaTokenType* types)
 {
 	AnjutaToken *tok;
-	
+
 	for (tok = list; tok != NULL; tok = anjuta_token_next (tok))
 	{
 		AnjutaTokenType *type;
@@ -144,7 +144,7 @@ static AnjutaToken *
 skip_comment (AnjutaToken *token)
 {
 	if (token == NULL) return NULL;
-	
+
 	for (;;)
 	{
 		for (;;)
@@ -152,7 +152,7 @@ skip_comment (AnjutaToken *token)
 			AnjutaToken *next = anjuta_token_next (token);
 
 			if (next == NULL) return token;
-			
+
 			switch (anjuta_token_get_type (token))
 			{
 			case ANJUTA_TOKEN_FILE:
@@ -167,14 +167,14 @@ skip_comment (AnjutaToken *token)
 			}
 			break;
 		}
-		
+
 		for (;;)
 		{
 			AnjutaToken *next = anjuta_token_next (token);
 
 			if (next == NULL) return token;
 			token = next;
-			if (anjuta_token_get_type (token) == EOL) break;
+			if (anjuta_token_get_type (token) == END_OF_LINE) break;
 		}
 	}
 }
@@ -192,7 +192,7 @@ amp_project_update_ac_property (AmpProject *project, AnjutaProjectProperty *prop
 
 	pos = ((AmpProperty *)property)->position;
 	value = ((AmpProperty *)property)->base.value;
-	
+
 	if (project->ac_init == NULL)
 	{
 		gint types[] = {AC_TOKEN_AC_PREREQ, 0};
@@ -208,18 +208,18 @@ amp_project_update_ac_property (AmpProject *project, AnjutaProjectProperty *prop
 			{
 				token = anjuta_token_append_child (configure, anjuta_token_new_string (COMMENT | ANJUTA_TOKEN_ADDED, "#"));
 				token = anjuta_token_insert_after (token, anjuta_token_new_string (SPACE | ANJUTA_TOKEN_ADDED, " Created by Anjuta project manager"));
-				token = anjuta_token_insert_after (token, anjuta_token_new_string (EOL | ANJUTA_TOKEN_ADDED, "\n"));
-				token = anjuta_token_insert_after (token, anjuta_token_new_string (EOL | ANJUTA_TOKEN_ADDED, "\n"));
+				token = anjuta_token_insert_after (token, anjuta_token_new_string (END_OF_LINE | ANJUTA_TOKEN_ADDED, "\n"));
+				token = anjuta_token_insert_after (token, anjuta_token_new_string (END_OF_LINE | ANJUTA_TOKEN_ADDED, "\n"));
 			}
 		}
-		
+
 		token = anjuta_token_insert_before (token, anjuta_token_new_string (AC_TOKEN_AC_INIT | ANJUTA_TOKEN_ADDED, "AC_INIT("));
 		project->ac_init = token;
 		group = anjuta_token_insert_after (token, anjuta_token_new_static (ANJUTA_TOKEN_LIST | ANJUTA_TOKEN_ADDED, NULL));
 		project->args = group;
 		token = anjuta_token_insert_after (group, anjuta_token_new_static (ANJUTA_TOKEN_LAST | ANJUTA_TOKEN_ADDED, NULL));
 		anjuta_token_merge (group, token);
-		anjuta_token_insert_after (token, anjuta_token_new_string (EOL | ANJUTA_TOKEN_ADDED, "\n"));
+		anjuta_token_insert_after (token, anjuta_token_new_string (END_OF_LINE | ANJUTA_TOKEN_ADDED, "\n"));
 		//fprintf(stdout, "whole file\n");
 		//anjuta_token_dump (project->configure_token);
 	}
@@ -237,7 +237,7 @@ amp_project_update_ac_property (AmpProject *project, AnjutaProjectProperty *prop
 	//fprintf(stdout, "ac_init after update link\n");
 	//anjuta_token_dump (project->args);
 	amp_project_update_configure (project, token);
-	
+
 	return TRUE;
 }
 
@@ -258,7 +258,7 @@ amp_project_write_module_list (AmpProject *project, const gchar *name, gboolean
 	pos = anjuta_token_insert_token_list (after, pos,
 		    ANJUTA_TOKEN_EOL, "\n",
 		    NULL);
-	
+
 	pos = anjuta_token_insert_token_list (after, pos,
 		    ANJUTA_TOKEN_EOL, "\n",
 		    NULL);
@@ -277,7 +277,7 @@ amp_project_write_module_list (AmpProject *project, const gchar *name, gboolean
 }
 
 
-gboolean 
+gboolean
 amp_module_node_create_token (AmpProject  *project, AmpModuleNode *module, GError **error)
 {
 	gboolean after;
@@ -285,7 +285,7 @@ amp_module_node_create_token (AmpProject  *project, AmpModuleNode *module, GErro
 	AnjutaToken *prev;
 	AnjutaToken *next;
 	AnjutaProjectNode *sibling;
-	
+
 	/* Add in configure.ac */
 	/* Find a sibling if possible */
 	prev = NULL;
@@ -318,19 +318,19 @@ amp_module_node_create_token (AmpProject  *project, AmpModuleNode *module, GErro
 			}
 		}
 	}
-	
+
 	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;
 }
 
-gboolean 
+gboolean
 amp_module_node_delete_token (AmpProject  *project, AmpModuleNode *module, GError **error)
 {
 	AnjutaToken *token;
@@ -339,7 +339,7 @@ amp_module_node_delete_token (AmpProject  *project, AmpModuleNode *module, GErro
 	if (token != NULL)
 	{
 		AnjutaToken *eol;
-		
+
 		token = anjuta_token_list (token);
 		anjuta_token_set_flags (token, ANJUTA_TOKEN_REMOVED);
 		eol = anjuta_token_next_item (token);
@@ -362,7 +362,7 @@ amp_module_node_delete_token (AmpProject  *project, AmpModuleNode *module, GErro
 /* Package objects
  *---------------------------------------------------------------------------*/
 
-gboolean 
+gboolean
 amp_package_node_create_token (AmpProject  *project, AmpPackageNode *package, GError **error)
 {
 	AmpModuleNode *module;
@@ -403,7 +403,7 @@ amp_package_node_create_token (AmpProject  *project, AmpPackageNode *package, GE
 	{
 		args = amp_module_node_get_token (module);
 	}
-	
+
 	if (args != NULL)
 	{
 		AnjutaTokenStyle *style;
@@ -414,7 +414,7 @@ amp_package_node_create_token (AmpProject  *project, AmpPackageNode *package, GE
 		//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);
@@ -427,16 +427,16 @@ amp_package_node_create_token (AmpProject  *project, AmpPackageNode *package, GE
 		/* 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;
 }
 
-gboolean 
+gboolean
 amp_package_node_delete_token (AmpProject  *project, AmpPackageNode *package, GError **error)
 {
 	AnjutaProjectNode *module;
@@ -448,7 +448,7 @@ amp_package_node_delete_token (AmpProject  *project, AmpPackageNode *package, GE
 	{
 		return FALSE;
 	}
-		
+
 	token = amp_package_node_get_token (package);
 	if (token != NULL)
 	{
@@ -460,9 +460,9 @@ amp_package_node_delete_token (AmpProject  *project, AmpPackageNode *package, GE
 		/* Try to use the same style than the current target list */
 		style = anjuta_token_style_new_from_base (project->ac_space_list);
 		anjuta_token_style_update (style, args);
-		
+
 		anjuta_token_remove_word (token);
-		
+
 		anjuta_token_style_format (style, args);
 		anjuta_token_style_free (style);
 
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 05c6d8f..a504767 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -729,7 +729,7 @@ amp_project_load_module (AmpProject *project, AnjutaToken *module_token)
 		if (arg != NULL)
 		{
 			scanner = amp_ac_scanner_new (project);
-			list = amp_ac_scanner_parse_token (scanner, arg, AC_SPACE_LIST_STATE, NULL);
+			list = amp_ac_scanner_parse_token (scanner, NULL, arg, AC_SPACE_LIST_STATE, NULL, NULL);
 			anjuta_token_free_children (arg);
 			list = anjuta_token_delete_parent (list);
 			anjuta_token_prepend_items (arg, list);
@@ -788,7 +788,7 @@ amp_project_load_config (AmpProject *project, AnjutaToken *arg_list)
 		scanner = amp_ac_scanner_new (project);
 
 		arg = anjuta_token_first_word (arg_list);
-		list = amp_ac_scanner_parse_token (scanner, arg, AC_SPACE_LIST_STATE, NULL);
+		list = amp_ac_scanner_parse_token (scanner, NULL, arg, AC_SPACE_LIST_STATE, NULL, NULL);
 		anjuta_token_free_children (arg);
 		list = anjuta_token_delete_parent (list);
 		amp_ac_scanner_free (scanner);
@@ -1646,7 +1646,7 @@ amp_project_load_root (AmpProject *project, GError **error)
 	amp_project_add_file (project, configure_file, configure_token_file);
 	arg = anjuta_token_file_load (configure_token_file, NULL);
 	scanner = amp_ac_scanner_new (project);
-	project->configure_token = amp_ac_scanner_parse_token (scanner, arg, 0, &err);
+	project->configure_token = amp_ac_scanner_parse_token (scanner, NULL, arg, 0, configure_file, &err);
 	amp_ac_scanner_free (scanner);
 
 	if (project->configure_token == NULL)
diff --git a/plugins/am-project/tests/include.at b/plugins/am-project/tests/include.at
index 179313d..881d52a 100644
--- a/plugins/am-project/tests/include.at
+++ b/plugins/am-project/tests/include.at
@@ -1,4 +1,30 @@
-AT_SETUP([Include in GNUMakefile.am])
+AT_SETUP([Include in Makefile.am and configure.ac])
+
+
+m4_pattern_allow([m4_include])
+
+AS_MKDIR_P([include_ac])
+AT_DATA([include_ac/configure.ac],
+[[AC_CONFIG_FILES(m4_include([include.m4]))
+]])
+AT_DATA([include_ac/include.m4],
+[[Makefile
+]])
+AT_DATA([include_ac/Makefile.am],
+[[
+bin_PROGRAMS = target1
+]])
+AT_DATA([expect],
+[[    GROUP (): include_ac
+        TARGET (): target1
+            PROPERTY (Installation directory): bindir
+]])
+AT_PARSER_CHECK([load include_ac \
+		 list])
+AT_CHECK([diff -b output expect])
+
+
+
 AS_MKDIR_P([include])
 AT_DATA([include/configure.ac],
 [[AC_CONFIG_FILES(GNUmakefile)
@@ -20,4 +46,7 @@ AT_DATA([expect],
 AT_PARSER_CHECK([load include \
 		 list])
 AT_CHECK([diff -b output expect])
+
+
+
 AT_CLEANUP



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