r3511 - in jhalfs/branches/experimental: . LFS XSL common/libs
manuel at linuxfromscratch.org
manuel at linuxfromscratch.org
Sun Sep 30 07:02:43 MDT 2007
Author: manuel
Date: 2007-09-30 07:02:43 -0600 (Sun, 30 Sep 2007)
New Revision: 3511
Added:
jhalfs/branches/experimental/XSL/optimize.xsl
Removed:
jhalfs/branches/experimental/optimize/
Modified:
jhalfs/branches/experimental/LFS/lfs.xsl
jhalfs/branches/experimental/common/libs/func_book_parser
jhalfs/branches/experimental/jhalfs
Log:
Migrated optimizations support to XSL-based code.
Modified: jhalfs/branches/experimental/LFS/lfs.xsl
===================================================================
--- jhalfs/branches/experimental/LFS/lfs.xsl 2007-09-29 18:57:23 UTC (rev 3510)
+++ jhalfs/branches/experimental/LFS/lfs.xsl 2007-09-30 13:02:43 UTC (rev 3511)
@@ -10,9 +10,10 @@
<!-- XSLT stylesheet to create shell scripts from LFS books. -->
<!-- Including common extensions templates -->
+ <xsl:include href="../XSL/blfs-tool.xsl"/>
+ <xsl:include href="../XSL/custom-tools.xsl"/>
+ <xsl:include href="../XSL/optimize.xsl"/>
<xsl:include href="../XSL/user.xsl"/>
- <xsl:include href="../XSL/custom-tools.xsl"/>
- <xsl:include href="../XSL/blfs-tool.xsl"/>
<!-- ####################### PARAMETERS ################################### -->
@@ -48,7 +49,14 @@
<!-- blfs-tool support -->
<xsl:param name="blfs-tool">n</xsl:param>
+ <!-- optimize support level
+ 0 = none
+ 1 = not for temporary tools
+ 2 = all packages
+ -->
+ <xsl:param name="optimize">0</xsl:param>
+
<!-- ####################################################################### -->
<!-- ############################# MATCH TEMPLATES ########################## -->
@@ -176,7 +184,7 @@
<!-- Used to set and initialize the testuite log file -->
<xsl:param name="testlogfile" select="foo"/>
<xsl:param name="run_this_test" select="foo"/>
- <!-- Build phase (base file name) to be used for PM -->
+ <!-- Build phase (base file name) to be used for PM and optimize -->
<xsl:param name="phase" select="foo"/>
<xsl:text>
PKG_PHASE=</xsl:text>
<xsl:value-of select="$phase"/>
@@ -186,6 +194,17 @@
<xsl:apply-templates select="productnumber"/>
<!-- Tarball name -->
<xsl:apply-templates select="address"/>
+ <!-- Add optimization envars -->
+ <xsl:choose>
+ <xsl:when test="$optimize = '0'"/>
+ <xsl:when test="$optimize = '1' and ancestor::chapter[@id='chapter-temporary-tools']"/>
+ <xsl:otherwise>
+ <xsl:call-template name="optimize">
+ <xsl:with-param name="package" select="$phase"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ <!-- Set and initialize testsuite log file -->
<xsl:if test="$run_this_test = '1'">
<xsl:text>
TEST_LOG=</xsl:text>
<xsl:if test="ancestor::chapter[@id='chapter-temporary-tools']">
Added: jhalfs/branches/experimental/XSL/optimize.xsl
===================================================================
--- jhalfs/branches/experimental/XSL/optimize.xsl (rev 0)
+++ jhalfs/branches/experimental/XSL/optimize.xsl 2007-09-30 13:02:43 UTC (rev 3511)
@@ -0,0 +1,485 @@
+<?xml version="1.0"?>
+
+<!-- $Id$ -->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+<!-- ####################### PARAMETERS ################################### -->
+
+ <!-- ###### MAKEFLAGS ###### -->
+
+ <!-- Should MAKEFLAGS be set? y = yes, n = no -->
+ <xsl:param name="set_makeflags">y</xsl:param>
+
+
+ <!-- Jobs control level. Left it empty for no jobs control -->
+ <xsl:param name="jobs">-j3</xsl:param>
+
+
+ <!-- Jobs control black-listed packages. One in each line.
+ NOTE: This and other similar parameters uses the PKG_PHASE value -->
+ <xsl:param name="no_jobs">
+ keep_this_line
+ autoconf
+ dejagnu
+ gettext
+ groff
+ man-db
+ keep_this_line
+ </xsl:param>
+
+
+ <!-- Additional make flags. -->
+ <xsl:param name="makeflags"></xsl:param>
+
+
+ <!-- Additional make flags black-listed packages. One in each line. -->
+ <xsl:param name="no_mkflags">
+ keep_this_line
+ keep_this_line
+ </xsl:param>
+
+
+ <!-- ############################ -->
+
+ <!-- ###### COMPILER FLAGS ###### -->
+
+ <!-- Should compiler envars be set? y = yes, n = no -->
+ <xsl:param name="set_buildflags">y</xsl:param>
+
+
+ <!-- Compiler optimizations black-listed packages. One in each line. -->
+ <xsl:param name="no_buildflags">
+ keep_this_line
+ binutils
+ binutils-pass1
+ binutils-pass2
+ gcc
+ gcc-pass1
+ gcc-pass2
+ glibc
+ grub
+ keep_this_line
+ </xsl:param>
+
+
+ <!-- Default envars setting. Left empty to not set a variable. -->
+
+ <!-- Default CFLAGS -->
+ <xsl:param name="cflags">-O3 -pipe</xsl:param>
+
+
+ <!-- Default CXXFLAGS -->
+ <xsl:param name="cxxflags">$CFLAGS</xsl:param>
+
+
+ <!-- Default OTHER_CFLAGS -->
+ <xsl:param name="other_cflags">$CFLAGS</xsl:param>
+
+
+ <!-- Default OTHER_CXXFLAGS -->
+ <xsl:param name="other_cxxflags">$CXXFLAGS</xsl:param>
+
+
+ <!-- Default LDFLAGS -->
+ <xsl:param name="ldflags"></xsl:param>
+
+
+ <!-- Default OTHER_LDFLAGS -->
+ <xsl:param name="other_ldflags"></xsl:param>
+
+ <!-- -->
+
+ <!-- By-package additional settings. A pair "package value" on each line.
+ The values set here will be added to the ones set above -->
+
+ <!-- Extra CFLAGS -->
+ <xsl:param name="extra_cflags">
+ zlib -fPIC
+ </xsl:param>
+
+
+ <!-- Extra CXXFLAGS -->
+ <xsl:param name="extra_cxxflags">
+ </xsl:param>
+
+
+ <!-- Extra OTHER_CFLAGS -->
+ <xsl:param name="extra_other_cflags">
+ </xsl:param>
+
+
+ <!-- Extra OTHER_CXXFLAGS -->
+ <xsl:param name="extra_other_cxxflags">
+ </xsl:param>
+
+
+ <!-- Extra LDFLAGS -->
+ <xsl:param name="extra_ldflags">
+ </xsl:param>
+
+
+ <!-- Extra OTHER_LDFLAGS -->
+ <xsl:param name="extra_other_ldflags">
+ </xsl:param>
+
+ <!-- -->
+
+ <!-- By-package settings. A pair "package value" on each line.
+ The values set here will override the ones set above -->
+
+ <!-- Extra CFLAGS -->
+ <xsl:param name="override_cflags">
+ </xsl:param>
+
+
+ <!-- Extra CXXFLAGS -->
+ <xsl:param name="override_cxxflags">
+ </xsl:param>
+
+
+ <!-- Extra OTHER_CFLAGS -->
+ <xsl:param name="override_other_cflags">
+ </xsl:param>
+
+
+ <!-- Extra OTHER_CXXFLAGS -->
+ <xsl:param name="override_other_cxxflags">
+ </xsl:param>
+
+
+ <!-- Extra LDFLAGS -->
+ <xsl:param name="override_ldflags">
+ </xsl:param>
+
+
+ <!-- Extra OTHER_LDFLAGS -->
+ <xsl:param name="override_other_ldflags">
+ </xsl:param>
+
+
+<!-- ######################################################################## -->
+
+<!-- ########################### NAMED TEMPLATES ########################### -->
+
+ <!-- Master optimizations template -->
+ <xsl:template name="optimize">
+ <xsl:param name="package" select="foo"/>
+ <xsl:text>

</xsl:text>
+ <xsl:if test="$set_makeflags = 'y'">
+ <xsl:call-template name="makeflags">
+ <xsl:with-param name="package" select="$package"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="$set_buildflags = 'y' and
+ not(contains(normalize-space($no_buildflags),concat(' ',$package,' ')))">
+ <xsl:call-template name="buildflags">
+ <xsl:with-param name="package" select="$package"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:template>
+
+
+ <!-- MAKEFLAGS template -->
+ <xsl:template name="makeflags">
+ <xsl:param name="package" select="foo"/>
+ <!-- Test if jobs control must be set -->
+ <xsl:variable name="set_jobs">
+ <xsl:if test="$jobs != '' and
+ not(contains(normalize-space($no_jobs),concat(' ',$package,' ')))">1</xsl:if>
+ </xsl:variable>
+ <!-- Test if additional make flags must be set -->
+ <xsl:variable name="add_mkflags">
+ <xsl:if test="$makeflags != '' and
+ not(contains(normalize-space($no_mkflags),concat(' ',$package,' ')))">1</xsl:if>
+ </xsl:variable>
+ <!-- Write the envar -->
+ <xsl:if test="$set_jobs = '1' or $add_mkflags = '1'">
+ <xsl:text>MAKEFLAGS="</xsl:text>
+ <!-- Write jobs control value -->
+ <xsl:if test="$set_jobs = '1'">
+ <xsl:value-of select="$jobs"/>
+ </xsl:if>
+ <!-- If both values will be written, be sure that are space separated -->
+ <xsl:if test="$set_jobs = '1' and $add_mkflags = '1'">
+ <xsl:text> </xsl:text>
+ </xsl:if>
+ <!-- Write additional make flags value -->
+ <xsl:if test="$add_mkflags = '1'">
+ <xsl:value-of select="$makeflags"/>
+ </xsl:if>
+ <xsl:text>"
</xsl:text>
+ </xsl:if>
+ </xsl:template>
+
+
+ <!-- Master compiler flags template -->
+ <xsl:template name="buildflags">
+ <xsl:param name="package" select="foo"/>
+ <xsl:if test="$cflags != ''">
+ <xsl:call-template name="cflags">
+ <xsl:with-param name="package" select="$package"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="$cxxflags != ''">
+ <xsl:call-template name="cxxflags">
+ <xsl:with-param name="package" select="$package"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="$other_cflags != ''">
+ <xsl:call-template name="other_cflags">
+ <xsl:with-param name="package" select="$package"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="$other_cxxflags != ''">
+ <xsl:call-template name="other_cxxflags">
+ <xsl:with-param name="package" select="$package"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="$ldflags != ''">
+ <xsl:call-template name="ldflags">
+ <xsl:with-param name="package" select="$package"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="$other_ldflags != ''">
+ <xsl:call-template name="other_ldflags">
+ <xsl:with-param name="package" select="$package"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:template>
+
+
+ <!-- CFLAGS template -->
+ <xsl:template name="cflags">
+ <xsl:param name="package" select="foo"/>
+ <!-- Find the override value, if any -->
+ <xsl:variable name="override">
+ <xsl:call-template name="lookup.key">
+ <xsl:with-param name="key" select="$package"/>
+ <xsl:with-param name="table" select="normalize-space($override_cflags)"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <!-- Find the extra settings, if any -->
+ <xsl:variable name="extra">
+ <xsl:call-template name="lookup.key">
+ <xsl:with-param name="key" select="$package"/>
+ <xsl:with-param name="table" select="normalize-space($extra_cflags)"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <!-- Writte the envar -->
+ <xsl:text>CFLAGS="</xsl:text>
+ <xsl:choose>
+ <xsl:when test="$override != ''">
+ <xsl:value-of select="$override"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$cflags"/>
+ <xsl:if test="$extra != ''">
+ <xsl:value-of select="concat(' ',$extra)"/>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>"
</xsl:text>
+ </xsl:template>
+
+
+ <!-- CXXFLAGS template -->
+ <xsl:template name="cxxflags">
+ <xsl:param name="package" select="foo"/>
+ <!-- Find the override value, if any -->
+ <xsl:variable name="override">
+ <xsl:call-template name="lookup.key">
+ <xsl:with-param name="key" select="$package"/>
+ <xsl:with-param name="table" select="normalize-space($override_cxxflags)"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <!-- Find the extra settings, if any -->
+ <xsl:variable name="extra">
+ <xsl:call-template name="lookup.key">
+ <xsl:with-param name="key" select="$package"/>
+ <xsl:with-param name="table" select="normalize-space($extra_cxxflags)"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <!-- Writte the envar -->
+ <xsl:text>CXXFLAGS="</xsl:text>
+ <xsl:choose>
+ <xsl:when test="$override != ''">
+ <xsl:value-of select="$override"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$cxxflags"/>
+ <xsl:if test="$extra != ''">
+ <xsl:value-of select="concat(' ',$extra)"/>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>"
</xsl:text>
+ </xsl:template>
+
+
+ <!-- OTHER_CFLAGS template -->
+ <xsl:template name="other_cflags">
+ <xsl:param name="package" select="foo"/>
+ <!-- Find the override value, if any -->
+ <xsl:variable name="override">
+ <xsl:call-template name="lookup.key">
+ <xsl:with-param name="key" select="$package"/>
+ <xsl:with-param name="table" select="normalize-space($override_other_cflags)"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <!-- Find the extra settings, if any -->
+ <xsl:variable name="extra">
+ <xsl:call-template name="lookup.key">
+ <xsl:with-param name="key" select="$package"/>
+ <xsl:with-param name="table" select="normalize-space($extra_other_cflags)"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <!-- Writte the envar -->
+ <xsl:text>OTHER_CFLAGS="</xsl:text>
+ <xsl:choose>
+ <xsl:when test="$override != ''">
+ <xsl:value-of select="$override"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$other_cflags"/>
+ <xsl:if test="$extra != ''">
+ <xsl:value-of select="concat(' ',$extra)"/>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>"
</xsl:text>
+ </xsl:template>
+
+
+ <!-- OTHER_CXXFLAGS template -->
+ <xsl:template name="other_cxxflags">
+ <xsl:param name="package" select="foo"/>
+ <!-- Find the override value, if any -->
+ <xsl:variable name="override">
+ <xsl:call-template name="lookup.key">
+ <xsl:with-param name="key" select="$package"/>
+ <xsl:with-param name="table" select="normalize-space($override_other_cxxflags)"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <!-- Find the extra settings, if any -->
+ <xsl:variable name="extra">
+ <xsl:call-template name="lookup.key">
+ <xsl:with-param name="key" select="$package"/>
+ <xsl:with-param name="table" select="normalize-space($extra_other_cxxflags)"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <!-- Writte the envar -->
+ <xsl:text>OTHER_CXXFLAGS="</xsl:text>
+ <xsl:choose>
+ <xsl:when test="$override != ''">
+ <xsl:value-of select="$override"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$other_cxxflags"/>
+ <xsl:if test="$extra != ''">
+ <xsl:value-of select="concat(' ',$extra)"/>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>"
</xsl:text>
+ </xsl:template>
+
+
+ <!-- LDFLAGS template -->
+ <xsl:template name="ldflags">
+ <xsl:param name="package" select="foo"/>
+ <!-- Find the override value, if any -->
+ <xsl:variable name="override">
+ <xsl:call-template name="lookup.key">
+ <xsl:with-param name="key" select="$package"/>
+ <xsl:with-param name="table" select="normalize-space($override_ldflags)"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <!-- Find the extra settings, if any -->
+ <xsl:variable name="extra">
+ <xsl:call-template name="lookup.key">
+ <xsl:with-param name="key" select="$package"/>
+ <xsl:with-param name="table" select="normalize-space($extra_ldflags)"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <!-- Writte the envar -->
+ <xsl:text>LDFLAGS="</xsl:text>
+ <xsl:choose>
+ <xsl:when test="$override != ''">
+ <xsl:value-of select="$override"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$ldflags"/>
+ <xsl:if test="$extra != ''">
+ <xsl:value-of select="concat(' ',$extra)"/>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>"
</xsl:text>
+ </xsl:template>
+
+
+ <!-- OTHER_LDFLAGS template -->
+ <xsl:template name="other_ldflags">
+ <xsl:param name="package" select="foo"/>
+ <!-- Find the override value, if any -->
+ <xsl:variable name="override">
+ <xsl:call-template name="lookup.key">
+ <xsl:with-param name="key" select="$package"/>
+ <xsl:with-param name="table" select="normalize-space($override_other_ldflags)"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <!-- Find the extra settings, if any -->
+ <xsl:variable name="extra">
+ <xsl:call-template name="lookup.key">
+ <xsl:with-param name="key" select="$package"/>
+ <xsl:with-param name="table" select="normalize-space($extra_other_ldflags)"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <!-- Writte the envar -->
+ <xsl:text>OTHER_LDFLAGS="</xsl:text>
+ <xsl:choose>
+ <xsl:when test="$override != ''">
+ <xsl:value-of select="$override"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$other_ldflags"/>
+ <xsl:if test="$extra != ''">
+ <xsl:value-of select="concat(' ',$extra)"/>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>"
</xsl:text>
+ </xsl:template>
+
+
+ <!-- Parses a table-like param finding a pair key-value.
+ Copied from DocBook-XSL -->
+ <xsl:template name="lookup.key">
+ <xsl:param name="key" select="''"/>
+ <xsl:param name="table" select="''"/>
+ <xsl:if test="contains($table, ' ')">
+ <xsl:choose>
+ <xsl:when test="substring-before($table, ' ') = $key">
+ <xsl:variable name="rest" select="substring-after($table, ' ')"/>
+ <xsl:choose>
+ <xsl:when test="contains($rest, ' ')">
+ <xsl:value-of select="substring-before($rest, ' ')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$rest"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="lookup.key">
+ <xsl:with-param name="key" select="$key"/>
+ <xsl:with-param name="table" select="substring-after(substring-after($table,' '), ' ')"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ </xsl:template>
+
+</xsl:stylesheet>
Property changes on: jhalfs/branches/experimental/XSL/optimize.xsl
___________________________________________________________________
Name: svn:keywords
+ Author Date Revision Id
Modified: jhalfs/branches/experimental/common/libs/func_book_parser
===================================================================
--- jhalfs/branches/experimental/common/libs/func_book_parser 2007-09-29 18:57:23 UTC (rev 3510)
+++ jhalfs/branches/experimental/common/libs/func_book_parser 2007-09-30 13:02:43 UTC (rev 3511)
@@ -146,6 +146,7 @@
--stringparam lang $LANG \
--stringparam custom-tools $CUSTOM_TOOLS \
--stringparam blfs-tool $BLFS_TOOL \
+ --stringparam optimize $OPTIMIZE \
-o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
;;
*) echo -n " ${L_arrow}${BOLD}${PROGNAME}${R_arrow} book invalid, terminate build... "
Modified: jhalfs/branches/experimental/jhalfs
===================================================================
--- jhalfs/branches/experimental/jhalfs 2007-09-29 18:57:23 UTC (rev 3510)
+++ jhalfs/branches/experimental/jhalfs 2007-09-30 13:02:43 UTC (rev 3511)
@@ -266,22 +266,6 @@
[[ $VERBOSITY > 0 ]] && echo "OK"
fi
#
-# optimize module
-if [[ "$OPTIMIZE" != "0" ]]; then
- [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization module..."
- source optimize/optimize_functions
- [[ $? > 0 ]] && echo " optimize/optimize_functions did not load.." && exit
- [[ $VERBOSITY > 0 ]] && echo "OK"
- #
- # optimize configurations
- [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization config..."
- source optimize/opt_config
- [[ $? > 0 ]] && echo " optimize/opt_config did not load.." && exit
- [[ $VERBOSITY > 0 ]] && echo "OK"
- # Validate optimize settings, if required
- validate_opt_settings
-fi
-#
if [[ "$REBUILD_MAKEFILE" = "n" ]] ; then
@@ -327,9 +311,6 @@
validate_config > $JHALFSDIR/jhalfs.config
fi
#
- # Copy optimize files, if needed
- [[ "$OPTIMIZE" != "0" ]] && cp optimize/opt_override $JHALFSDIR/
- #
# Copy compare files, if needed
if [[ "$COMPARE" = "y" ]]; then
mkdir -p $JHALFSDIR/extras
More information about the alfs-log
mailing list