On Fri, Apr 17, 2009 at 9:28 AM, ron minnich <[email protected]> wrote:
> On Fri, Apr 17, 2009 at 7:53 AM, Carl-Daniel Hailfinger
> <[email protected]> wrote:
>
>> Unfortunately, if I use the "dir" syntax, I have to create a directory
>> for every snippet. I tried to change config.g, but it's too difficult to
>> modify it to have another command which takes a file name instead of a
>> directory for the include operation.
>>
>> Any help is appreciated.
>
> I can add an include command if you want.

Maybe this one will be good enough while he's factoring things out.

I made it so it always includes from /config/shared.  I think it
should be easy to modify this rule for your needs.

Thanks,
Myles
Index: util/newconfig/config.g
===================================================================
--- util/newconfig/config.g	(revision 4127)
+++ util/newconfig/config.g	(working copy)
@@ -1514,6 +1514,17 @@
 	doconfigfile(fullpath, path, file, 'cfgfile')
 	dirstack.pop()
 
+def dofile(path, file):
+	"""dofile is a simple include relative to treetop"""
+	# if the first char is '/', it is relative to treetop, 
+	# else relative to curdir
+	# os.path.join screws up if the name starts with '/', sigh.
+	print "SHAREDINCLUDE %s" % os.path.join(path, file)
+	fullpath = os.path.join(treetop, 'src')
+	path = re.sub('^/*', '', path)
+	debug.info(debug.statement, "DOFILE: path %s, fullpath %s" % (path, fullpath))
+	doconfigfile(fullpath, path, file, 'cfgfile')
+
 def lookup(name):
 	global curimage
 	return getoption(name, curimage)
@@ -1658,6 +1669,7 @@
     token PRINT:		'print'
     token REGISTER:		'register'
     token ROMIMAGE:		'romimage'
+    token SHAREDINCLUDE:	'sharedinclude'
     token SMMOBJECT:		'smmobject'
     token SOUTHBRIDGE:		'southbridge'
     token SUPERIO:		'superio'
@@ -1841,6 +1853,8 @@
 			HEX_NUM			{{ cluster = int(HEX_NUM, 16) }}
 						{{ if (C): partstack.tos().addapic_clusterpath(cluster) }}
 
+    rule sharedinclude<<C>>:	SHAREDINCLUDE STR 	{{ dofile('/config/shared', dequote(STR)) }}
+
     rule cpu<<C>>:	CPU			{{ if (C): devicepart('cpu') }}
     			HEX_NUM			{{ id = int(HEX_NUM, 16) }}
 						{{ if (C): partstack.tos().addcpupath(id) }}
@@ -1896,6 +1910,7 @@
 		|	partdef<<C>>		{{ return partdef }}
 		| 	prtstmt<<C>>		{{ return prtstmt }}
 		|	register<<C>> 		{{ return register }}
+		|	sharedinclude<<C>>	{{ return sharedinclude }}
 		|	device<<C>>		{{ return device }}
 		|	smmobject<<C>>		{{ return smmobject }}
 
-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to