[OpenBIOS] [PATCH 2/4] config: add new fcode tag and support for building Fcode into dictionaries
Mark Cave-Ayland
mark.cave-ayland at ilande.co.uk
Mon Jun 24 17:06:21 CEST 2013
Here we introduce a new <fcode> tag which will tokenise the specified source
file into Fcode using the toke utility. Similarly add a new type attribute
to the dictionary <object> tag which when set to "fcode" will add the fcode
binary as a dependency for the specified target dictionary.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
openbios-devel/Makefile.target | 3 ++
openbios-devel/config/xml/dictionary.xsl | 40 +++++++++++++++++++++----
openbios-devel/config/xml/fcode.xsl | 48 ++++++++++++++++++++++++++++++
openbios-devel/config/xml/makefile.xsl | 2 ++
openbios-devel/config/xml/rules.xml | 3 ++
5 files changed, 90 insertions(+), 6 deletions(-)
create mode 100644 openbios-devel/config/xml/fcode.xsl
diff --git a/openbios-devel/Makefile.target b/openbios-devel/Makefile.target
index 913fb13..a7363e6 100644
--- a/openbios-devel/Makefile.target
+++ b/openbios-devel/Makefile.target
@@ -35,6 +35,9 @@ CFLAGS+= -MMD -MP -MT $@ -MF '$(*D)/$(*F).d'
INCLUDES := -I$(SRCDIR)/include -I$(SRCDIR)/kernel/include -I$(ODIR)/target/include
AS_FLAGS+= -g
+# FCode tokeniser
+TOKE := toke
+
quiet-command = $(if $(V),$1,$(if $(2), at echo $2 && $1, @$1))
VPATH_SUFFIXES = %.c %.h %.S %.fs
diff --git a/openbios-devel/config/xml/dictionary.xsl b/openbios-devel/config/xml/dictionary.xsl
index 664df0f..61f62d8 100644
--- a/openbios-devel/config/xml/dictionary.xsl
+++ b/openbios-devel/config/xml/dictionary.xsl
@@ -53,16 +53,23 @@
</xsl:variable>
<xsl:if test="$conditions=0">
- <xsl:value-of select="$dictname"/><xsl:text>-DICTIONARY:=$(</xsl:text>
- <xsl:value-of select="$dictname"/><xsl:text>-DICTIONARY) </xsl:text>
- <xsl:value-of select="$path"/>
- <xsl:value-of select="@source"/>
- <xsl:text>
</xsl:text>
+ <xsl:variable name="source"><xsl:value-of select="@source" /></xsl:variable>
+
+ <!-- Handle just Forth source, not FCode -->
+ <xsl:if test="not(@target = 'fcode')">
+ <xsl:value-of select="$dictname"/><xsl:text>-DICTIONARY:=$(</xsl:text>
+ <xsl:value-of select="$dictname"/><xsl:text>-DICTIONARY) </xsl:text>
+
+ <xsl:value-of select="$path"/>
+ <xsl:value-of select="$source"/>
+ <xsl:text>
</xsl:text>
+ </xsl:if>
+
</xsl:if>
</xsl:for-each>
- <xsl:text>
</xsl:text>
+ <xsl:text>
</xsl:text>
<!-- Create targets for all dictionaries -->
<xsl:for-each select="//dictionary">
@@ -92,6 +99,27 @@
<xsl:if test="$init!=''">
<xsl:text> $(ODIR)/</xsl:text><xsl:value-of select="$init"/><xsl:text>.dict</xsl:text>
</xsl:if>
+
+ <!-- Check for Fcode dependency -->
+ <xsl:for-each select="object[@target = 'fcode']">
+
+ <xsl:variable name="conditions">
+ <xsl:text>0</xsl:text>
+ <xsl:for-each select="(ancestor-or-self::*)[@condition!='']">
+ <xsl:call-template name="resolve-condition">
+ <xsl:with-param select="@condition" name="expression"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <xsl:if test="$conditions = 0">
+
+ <xsl:text> $(ODIR)/</xsl:text>
+ <xsl:value-of select="@source"/>
+
+ </xsl:if>
+ </xsl:for-each>
+
<xsl:text>
</xsl:text>
<!-- rule -->
<xsl:text> $(call quiet-command,$(ODIR)/forthstrap</xsl:text>
diff --git a/openbios-devel/config/xml/fcode.xsl b/openbios-devel/config/xml/fcode.xsl
new file mode 100644
index 0000000..ccc7e6e
--- /dev/null
+++ b/openbios-devel/config/xml/fcode.xsl
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="ISO-8859-15" ?>
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+ <xsl:template match="/" mode="fcode">
+
+ <xsl:text>
#
# fcode rules
#
</xsl:text>
+
+ <!-- Create linker targets for FCode roms -->
+ <xsl:for-each select="//fcode">
+ <xsl:variable name="outer-conditions">
+ <xsl:text>0</xsl:text>
+ <xsl:for-each select="(ancestor-or-self::*)[@condition!='']">
+ <xsl:call-template name="resolve-condition">
+ <xsl:with-param select="@condition" name="expression"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <xsl:if test="$outer-conditions = 0">
+ <xsl:if test="(ancestor-or-self::*)">
+
+ <xsl:variable name="path">
+ <xsl:for-each select="ancestor::build">
+ <xsl:call-template name="get-dirname">
+ <xsl:with-param select="@base" name="path"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- Fcode name -->
+ <xsl:text>$(ODIR)/</xsl:text>
+ <xsl:value-of select="@name"/>
+ <xsl:text>:</xsl:text>
+
+ <xsl:text> $(SRCDIR)/</xsl:text>
+ <xsl:value-of select="$path"/>
+ <xsl:value-of select="@source"/>
+
+ <!-- FIXME this requires strict spaces in rules.xml -->
+ <xsl:value-of select="document('rules.xml',.)//rule[@target='host'][@entity='fcode']"/>
+ <xsl:text>
</xsl:text>
+ </xsl:if>
+ </xsl:if>
+ </xsl:for-each>
+
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/openbios-devel/config/xml/makefile.xsl b/openbios-devel/config/xml/makefile.xsl
index 8589274..56c494c 100644
--- a/openbios-devel/config/xml/makefile.xsl
+++ b/openbios-devel/config/xml/makefile.xsl
@@ -5,10 +5,12 @@
<xsl:include href="util.xsl"/>
<xsl:include href="dictionary.xsl"/>
<xsl:include href="object.xsl"/>
+ <xsl:include href="fcode.xsl"/>
<xsl:template match="/">
<xsl:value-of select="document('rules.xml',.)/rules/pre"/>
<xsl:apply-templates select="." mode="dictionaries"/>
+ <xsl:apply-templates select="." mode="fcode"/>
<xsl:apply-templates select="." mode="objects"/>
</xsl:template>
diff --git a/openbios-devel/config/xml/rules.xml b/openbios-devel/config/xml/rules.xml
index 86a3b6b..29a720a 100644
--- a/openbios-devel/config/xml/rules.xml
+++ b/openbios-devel/config/xml/rules.xml
@@ -13,6 +13,9 @@
<rule target="host" entity="library">
$(call quiet--command,$(AR) cru $@ $^; $(RANLIB) $@," HOSTAR $(TARGET_DIR)$@")
</rule>
+<rule target="host" entity="fcode">
+ $(call quiet-command,$(TOKE) -o $@ $^," TOKE $(TARGET_DIR)$@")
+</rule>
<!-- target/cross compiler build rules -->
<rule target="target" entity="executable">
--
1.7.10.4
More information about the OpenBIOS
mailing list