1<?xml version="1.0" encoding="utf-8"?>
2
3<!-- Copyright (C) 2021-2022 Intel Corporation. -->
4<!-- SPDX-License-Identifier: BSD-3-Clause -->
5
6<xsl:stylesheet
7    version="1.0"
8    xmlns:xi="http://www.w3.org/2003/XInclude"
9    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10    xmlns:math="http://exslt.org/math"
11    xmlns:exslt="http://exslt.org/common"
12    xmlns:acrn="http://projectacrn.org">
13  <xsl:include href="lib.xsl" />
14  <xsl:output method="text" />
15
16  <xsl:variable name="integer-suffix" select="'U'" />
17
18  <xi:include href="config_common.xsl" xpointer="xpointer(id('config_common')/*)" />
19
20  <xsl:template match="/acrn-offline-data">
21    <xsl:text>#ifndef CONFIG_H&#x0a;</xsl:text>
22    <xsl:text>#define CONFIG_H&#x0a;</xsl:text>
23
24    <xsl:apply-templates select="board-data/acrn-config" />
25    <xsl:apply-templates select="config-data/acrn-config" />
26
27    <xsl:text>#endif&#x0a;</xsl:text>
28  </xsl:template>
29
30  <xsl:template name="entry-by-key-value">
31    <xsl:param name="prefix" />
32    <xsl:param name="key" />
33    <xsl:param name="value" />
34    <xsl:param name="default" />
35
36    <xsl:text>#define </xsl:text>
37    <xsl:choose>
38      <xsl:when test="$prefix != ''">
39        <xsl:value-of select="$prefix" />
40      </xsl:when>
41      <xsl:otherwise>
42        <xsl:text>CONFIG_</xsl:text>
43      </xsl:otherwise>
44    </xsl:choose>
45    <xsl:value-of select="$key" />
46    <xsl:choose>
47      <xsl:when test="$value != ''">
48	<xsl:text> </xsl:text>
49	<xsl:value-of select="$value" />
50      </xsl:when>
51      <xsl:when test="$default != ''">
52	<xsl:text> </xsl:text>
53	<xsl:value-of select="$default" />
54      </xsl:when>
55    </xsl:choose>
56    <xsl:value-of select="$newline" />
57  </xsl:template>
58
59  <xsl:template name="boolean-by-key-value">
60    <xsl:param name="key" />
61    <xsl:param name="value" />
62
63    <xsl:if test="($value = 'true') or ($value = 'y')">
64      <xsl:call-template name="entry-by-key-value">
65	<xsl:with-param name="key" select="$key" />
66	<xsl:with-param name="value" select="1" />
67      </xsl:call-template>
68    </xsl:if>
69  </xsl:template>
70
71  <xsl:template name="string-by-key-value">
72    <xsl:param name="key" />
73    <xsl:param name="value" />
74
75    <xsl:call-template name="entry-by-key-value">
76      <xsl:with-param name="key" select="$key" />
77      <xsl:with-param name="value" select="concat('&#x22;', $value, '&#x22;')" />
78    </xsl:call-template>
79  </xsl:template>
80
81</xsl:stylesheet>
82