r1622 - dev/concept/moongoo

neocool at linuxfromscratch.org neocool at linuxfromscratch.org
Fri Dec 3 09:01:49 PST 2004


Author: neocool
Date: 2004-12-03 10:01:48 -0700 (Fri, 03 Dec 2004)
New Revision: 1622

Added:
   dev/concept/moongoo/build.c
   dev/concept/moongoo/build.h
Modified:
   dev/concept/moongoo/Makefile
   dev/concept/moongoo/alfs.c
   dev/concept/moongoo/alfs.h
   dev/concept/moongoo/book.c
   dev/concept/moongoo/moo.xml
   dev/concept/moongoo/moongoo.c
   dev/concept/moongoo/nalfs.c
   dev/concept/moongoo/repl.c
   dev/concept/moongoo/repl.h
Log:
* Added support for paralell building
* Bugfix in nALFS code
* Some new helper functions


Modified: dev/concept/moongoo/Makefile
===================================================================
--- dev/concept/moongoo/Makefile	2004-12-02 22:15:50 UTC (rev 1621)
+++ dev/concept/moongoo/Makefile	2004-12-03 17:01:48 UTC (rev 1622)
@@ -7,13 +7,15 @@
 CFLAGS+=-Wall -Werror -g3
 
 BIN=moongoo
-OBJS=alfs.o book.o util.o repl.o syn.o nalfs.o ass.o devel.o
+OBJS=alfs.o book.o util.o repl.o syn.o nalfs.o ass.o devel.o build.o
 
-#BOOK=~/projects/alfs/book/index.xml
-BOOK=~/projects/alfs/lfs-profile/LFS.xml
+BOOK=~/projects/alfs/book/index.xml
+#BOOK=~/projects/alfs/lfs-profile/LFS.xml
 #BOOK=~/projects/alfs/ass/index.xml
 #BOOK=~/projects/hive/unstable/profile.xml
 
+OPTS=
+
 .PHONY: all clean compile run memcheck debug todo
 
 all: run
@@ -24,13 +26,13 @@
 compile: $(BIN)
 
 run: compile
-	./$(BIN) -s nalfs -q $(BOOK)
+	./$(BIN) $(OPTS) $(BOOK)
 
 memcheck: compile
-	valgrind -q --tool=memcheck $(BIN) $(BOOK)
+	valgrind -q --tool=memcheck $(BIN) $(OPTS) $(BOOK)
 
 debug: compile
-	@echo "Book: $(BOOK)"
+	@echo "Book: $(OPTS) $(BOOK)"
 	gdb ./$(BIN)
 
 todo:
@@ -44,3 +46,4 @@
 nalfs.o: nalfs.h
 ass.o: ass.h
 devel.o: devel.h
+build.o: build.h

Modified: dev/concept/moongoo/alfs.c
===================================================================
--- dev/concept/moongoo/alfs.c	2004-12-02 22:15:50 UTC (rev 1621)
+++ dev/concept/moongoo/alfs.c	2004-12-03 17:01:48 UTC (rev 1622)
@@ -312,3 +312,20 @@
 	}
 	return false;
 }
+
+package *search_pkg (profile *prof, char *name, char *ch)
+{
+	int i, j;
+
+	for (i=0;i<prof->n;i++)
+	{
+		if (strcmp(ch, prof->ch[i].ref))
+			continue;
+		
+		for (j=0;j<prof->ch[i].n;j++)
+			if (!strcmp(name, prof->ch[i].pkg[j].name))
+				return &prof->ch[i].pkg[j];
+	}
+
+	return NULL;
+}

Modified: dev/concept/moongoo/alfs.h
===================================================================
--- dev/concept/moongoo/alfs.h	2004-12-02 22:15:50 UTC (rev 1621)
+++ dev/concept/moongoo/alfs.h	2004-12-03 17:01:48 UTC (rev 1622)
@@ -90,6 +90,7 @@
 char *find_values (xmlNodePtr node, char *str);
 char *find_values_repl (xmlNodePtr node, char *str, char **orig, char **repl);
 char *entity_val (char *name);
+package *search_pkg (profile *prof, char *name, char *ch);
 
 char *role2str (role role);
 char *type2str (xmlElementType type);

Modified: dev/concept/moongoo/book.c
===================================================================
--- dev/concept/moongoo/book.c	2004-12-02 22:15:50 UTC (rev 1621)
+++ dev/concept/moongoo/book.c	2004-12-03 17:01:48 UTC (rev 1622)
@@ -35,6 +35,7 @@
 	j = prof->ch[i].n-1;
 	
 	tmp = strdog(lower_case(title), "version");
+	// TODO: Name and version are not correctly separated
 	prof->ch[i].pkg[j].vers = entity_val(tmp);
 	prof->ch[i].pkg[j].name = strcut(title, 0, strlen(title)-
 		((prof->ch[i].pkg[j].vers) ? 1 : 0));

Added: dev/concept/moongoo/build.c
===================================================================
--- dev/concept/moongoo/build.c	2004-12-02 22:15:50 UTC (rev 1621)
+++ dev/concept/moongoo/build.c	2004-12-03 17:01:48 UTC (rev 1622)
@@ -0,0 +1,52 @@
+#include <string.h>
+
+#include <build.h>
+#include <util.h>
+#include <repl.h>
+
+void build_paralell (profile *prof, char **filter, char **p1, char **p2)
+{
+	int i, j, k;
+	
+	for (i=0;i<prof->n;i++)
+		for (j=0;j<prof->ch[i].n;j++)
+			for (k=0;k<prof->ch[i].pkg[j].n;k++)
+			{
+				int m = 0, o;
+				bool no = false;
+				package *pkg = &prof->ch[i].pkg[j];
+				command *moo = &pkg->build[k];
+
+				if (strcmp(moo->cmd, "make")||(moo->role!=ROLE_NONE))
+					continue;
+
+				while (filter[m])
+				{
+					for (o=0;o<moo->n;o++)
+						if (!strcmp(moo->arg[o], filter[m]))
+							no = true;
+					m++;
+				}
+				
+				if (!no)
+				{
+					char **new = (char **)malloc((moo->n+1)*sizeof(char *)), 
+						**old, *opt;
+					moo->arg = realloc(moo->arg, (++moo->n)*sizeof(char *));
+					for (m=0;m<moo->n-1;m++)
+						new[m+1]=moo->arg[m];
+					o=0;
+					opt = "-j";
+					while (p1[o])
+					{
+						if (!strcmp(pkg->name, p1[o]))
+							opt = p2[o];
+						o++;
+					}
+					new[0] = strdog(opt, get_option("PARALELL"));
+					old = moo->arg;
+					moo->arg = new;
+					free(old);
+				}
+			}
+}

Added: dev/concept/moongoo/build.h
===================================================================
--- dev/concept/moongoo/build.h	2004-12-02 22:15:50 UTC (rev 1621)
+++ dev/concept/moongoo/build.h	2004-12-03 17:01:48 UTC (rev 1622)
@@ -0,0 +1,8 @@
+#ifndef __BUILD_H__
+#define __BUILD_H__
+
+#include <alfs.h>
+
+void build_paralell (profile *prof, char **filter, char **p1, char **p2);
+
+#endif

Modified: dev/concept/moongoo/moo.xml
===================================================================
--- dev/concept/moongoo/moo.xml	2004-12-02 22:15:50 UTC (rev 1621)
+++ dev/concept/moongoo/moo.xml	2004-12-03 17:01:48 UTC (rev 1622)
@@ -22,4 +22,6 @@
 <answer name="[/path/to/your/keymap]"></answer>
 <!-- Paths -->
 <answer name="[unpacked sources dir]">/usr/src</answer>
+<!-- Paralell building -->
+<answer name="PARALELL">666</answer>
 </answers>

Modified: dev/concept/moongoo/moongoo.c
===================================================================
--- dev/concept/moongoo/moongoo.c	2004-12-02 22:15:50 UTC (rev 1621)
+++ dev/concept/moongoo/moongoo.c	2004-12-03 17:01:48 UTC (rev 1622)
@@ -9,13 +9,17 @@
 #include <nalfs.h>
 #include <ass.h>
 #include <util.h>
+#include <build.h>
 
 role default_filter[4] = { NOEXECUTE, INTERACTIVE, TESTSUITE, 0 };
+char *paralell_filter[4] = { "configure-host", "clean", "mrproper", NULL };
+char *popt_pkg[2] = { "Glibc-20041115", NULL };
+char *popt_cmd[2] = { "PARALLELMFLAGS=-j", NULL };
 
 int main (int argc, char **argv)
 {
 	char c, *syn = NULL;
-	bool quiet;
+	bool quiet = false;
 	xmlNodePtr cur;
 	profile *prof;
 	
@@ -72,11 +76,14 @@
 		fprintf(stderr, "Syntax '%s' is not valid.\n", syn);
 		return 1;
 	}
-	
-	if ((prof)||(!quiet))
+
+	if ((prof) && (!quiet))
 	{
+		build_paralell (prof, paralell_filter, popt_pkg, popt_cmd);
 		set_filter(default_filter);
-		print_profile(*prof);
+		print_pkg(*search_pkg(prof, "Glibc-20041115", 
+			"chapter-building-system"));
+		//print_profile(*prof);
 	}
 	
 	xmlFreeDoc(doc);

Modified: dev/concept/moongoo/nalfs.c
===================================================================
--- dev/concept/moongoo/nalfs.c	2004-12-02 22:15:50 UTC (rev 1621)
+++ dev/concept/moongoo/nalfs.c	2004-12-03 17:01:48 UTC (rev 1622)
@@ -247,7 +247,6 @@
 					if (!strncmp(temp, "cat >", 5))
 					{
 						char *t;
-						fprintf(stderr, "%s\n", temp);
 						t = strnstr(temp, "EOF", 2);
 						process_cmd4(strcut(temp, 0, t-temp+3));
 						t+=2;

Modified: dev/concept/moongoo/repl.c
===================================================================
--- dev/concept/moongoo/repl.c	2004-12-02 22:15:50 UTC (rev 1621)
+++ dev/concept/moongoo/repl.c	2004-12-03 17:01:48 UTC (rev 1622)
@@ -3,32 +3,42 @@
 #include <repl.h>
 #include <alfs.h>
 
+replaceable *r = NULL;
+
 void t_repl (xmlNodePtr node, void *data)
 {
 	xmlNodePtr text = find_node(node->children, "text");
-	int i=0;
 	char *repl = xmlNodeGetContent(text);
-	replaceable *r = (replaceable *)data;
+	char *opt = get_option(repl);
 	
-	if (!r)
+	if (!strcmp(opt, ""))
+	{
+		fprintf(stderr, "Unconfigured replaceable: %s\n", repl);
 		return;
+	}
 	
+	xmlNodeSetContent(node, opt);
+}
+
+char *get_option (char *key)
+{
+	int i=0;
+	
+	if (!r)
+		return NULL;
+	
 	while (r[i].orig)
 	{
-		if (!strcmp(repl, r[i].orig))
-		{
-			xmlNodeSetContent(node, r[i].repl);
-			return;
-		}
+		if (!strcmp(key, r[i].orig))
+			return r[i].repl;
 		i++;
 	}
-	
-	fprintf(stderr, "Unknown replaceable: %s\n", repl);
+
+	return "";
 }
 
 replaceable *init_repl (char *fname)
 {
-	replaceable *r = NULL;
 	xmlDocPtr doc;
 	xmlNodePtr node;
 	int count=0;

Modified: dev/concept/moongoo/repl.h
===================================================================
--- dev/concept/moongoo/repl.h	2004-12-02 22:15:50 UTC (rev 1621)
+++ dev/concept/moongoo/repl.h	2004-12-03 17:01:48 UTC (rev 1622)
@@ -8,5 +8,6 @@
 
 void t_repl (xmlNodePtr node, void *data);
 replaceable *init_repl (char *fname);
+char *get_option (char *key);
 
 #endif




More information about the alfs-log mailing list