<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.E-MailFormatvorlage17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.E-MailFormatvorlage18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#002060;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=DE link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='color:#002060'>Hello<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:#002060'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#002060'>I think I&#8217;ve found
a solution for my name clash problem. There is a way to check what the
dictionary of command line parameters returns. Classes and some other types
have the builtin attribute &#8216;__name__&#8217; to return the object&#8217;s
name as a string:<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#002060'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span lang=EN-US style='color:black'>self.build_dir =
handle_arg(&quot;BUILD_DIR&quot;, &quot;#build&quot;)<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if hasattr(self.build_dir, &quot;__name__&quot;):<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
self.build_dir = self.build_dir.__name__<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#002060'>This works for all 3
cases: naming the directory after the machine, using another name, or not using
the BUILD_DIR parameter.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#002060'>Maybe there are other
ways to fix the problem: proposal are welcome.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#002060'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#002060'>Regards<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#002060'>Frank<o:p></o:p></span></p>

<div style='border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
developer-bounces@okl4.org [mailto:developer-bounces@okl4.org] <b>On Behalf Of </b>Frank
Kaiser<br>
<b>Sent:</b> Monday, July 14, 2008 2:39 PM<br>
<b>To:</b> developer@okl4.org<br>
<b>Subject:</b> [okl4-developer] OKL4 2.1: naming the build directory after
themachine<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Hello<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><span lang=EN-US>When I compile my new platform I tried to
give the build directory the same nam as the machine by invoking the build
script this way:<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>tools/build.py
MACHINE=sam9263 PROJECT=iguana BUILD_DIR=sam9263<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>However, that does not work. This is the
response:<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>scons: Reading
SConscript files ...<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>/home/fka/Projects/COQOS/L4/OKL4/okl4_2.1/tools/build.py:287
Error: type object 'sam9263' has no attribute 'startswith'<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Here the relevant lines of the script:<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
def handle_arg(name, default):<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ret = kargs.get(name,
default)<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if name in kargs: del kargs[name]<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return ret<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
self.build_dir = handle_arg(&quot;BUILD_DIR&quot;, &quot;#build&quot;)<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if not self.build_dir.startswith('#'):<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
self.build_dir = '#' + self.build_dir<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>The only explanation for this odd error
message is that &#8216;sam9263&#8217; is not treated as a string but as an
object reference to the class &#8216;sam9263&#8217; defined in my platform
script &#8216;machines.py&#8217;. An attempt to quote the BUILD_DIR parameter
has no effect:<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>tools/build.py
MACHINE=sam9263 PROJECT=iguana BUILD_DIR=&#8221;sam9263&#8221;<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>The result is the same error.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Trying to convert the symbol
&#8216;sam9263&#8217; to a string by this assignment<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
self.build_dir = str(handle_arg(&quot;BUILD_DIR&quot;, &quot;#build&quot;))<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>starts compilation into the directory <i>&lt;class
'machines.sam9263'&gt;</i>, which is not what I want. Finally the build stops
with an error message:<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>[IDL ] &lt;class
'machines.sam9263'&gt;/iguana_server/object/libs_iguana/include/interfaces/iguana_serverloop.c<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>sh: class: No
such file or directory<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>scons: ***
[&lt;class
'machines.sam9263'&gt;/iguana_server/object/libs_iguana/include/interfaces/iguana_serverloop.c]
Error 1<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>scons: building
terminated because of errors.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>I think this is a specialty of Python. The
keyword/value paring in a dictionary apparently allows almost anything as a
value, and if the given value is the identifier of a class, then Python assumes
that the class is meant. That mechanism is quite effective when choosing the
hardware platform. First the script reads all available
&#8216;machines.py&#8217;, and then simply by using the class name with the
MACHINE parameter the platform to be compiled is selected.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>So the question remains: has anyone an idea
to enforce the string treatment of the BUILD_DIR value?<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Regards<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Frank<o:p></o:p></span></p>

</div>

</div>

</body>

</html>