--- a/bake/Module.py Fri Jul 20 17:56:05 2012 +0200
+++ b/bake/Module.py Mon Jul 23 16:26:26 2012 +0200
@@ -26,6 +26,7 @@
self._built_once = built_once
self._installed = installed
+
@property
def installed(self):
return self._installed
@@ -54,6 +55,12 @@
self._do_download(env, child, os.path.join(name, child_name))
def download(self, env):
+ if self._build.attribute('supported_os').value :
+ if not self._build.check_os(self._build.attribute('supported_os').value) :
+ import platform
+ osName = platform.system().lower()
+ print(' Downloading but this module works only on %s platoform(s), %s not supported for %s' % (self._build.attribute('supported_os').value, osName, env._module_name))
+
try:
print(" >> Downloading " + self._name )
self._do_download(env, self._source, self._name)
@@ -148,17 +155,24 @@
if self._build.supports_objdir and not os.path.isdir(env.objdir):
os.mkdir(env.objdir)
+
+ if self._build.attribute('supported_os').value :
+ if not self._build.check_os(self._build.attribute('supported_os').value) :
+ import platform
+ osName = platform.system().lower()
+ raise TaskError('This installation model works only on %s platoform(s), %s not supported for %s' % (self._build.attribute('supported_os').value, osName, env._module_name))
+
try:
print(" >> Building " + self._name )
- if self.attribute('pre_installation').value != '':
- self.perform_pre_installation(env)
+ if self._build.attribute('pre_installation').value != '':
+ self._build.perform_pre_installation(env)
self._build.threatParamVariables(env)
self._build.build(env, jobs)
self._installed = monitor.end()
env.end_build()
self._built_once = True
- if self.attribute('post_installation').value != '':
- self.perform_post_installation(env)
+ if self._build.attribute('post_installation').value != '':
+ self._build.perform_post_installation(env)
print(" >> Built " + self._name + " - OK ")
return True
except TaskError as e:
@@ -195,6 +209,9 @@
def is_downloaded(self, env):
srcDirTmp = self._name
+ if self._source.name() is 'system_dependency' :
+ return True
+
if self._source.attribute('module_directory').value :
srcDirTmp = self._source.attribute('module_directory').value
--- a/bake/ModuleBuild.py Fri Jul 20 17:56:05 2012 +0200
+++ b/bake/ModuleBuild.py Mon Jul 23 16:26:26 2012 +0200
@@ -1,5 +1,6 @@
import Utils
import os
+import platform
import commands
import re
import sys
@@ -19,6 +20,7 @@
self.add_attribute('v_PKG_CONFIG', '', 'Directory, or directories separated by a \";\", to append to PKG_CONFIG environment variable')
self.add_attribute('post_installation', '', 'UNIX Command to run after the installation')
self.add_attribute('pre_installation', '', 'UNIX Command to run before the installation')
+ self.add_attribute('supported_os', '', 'List of supported Operating Systems for the module', mandatory=False)
# self.add_attribute('condition_to_build', '', 'Condition that, if existent, should be true for allowing the instalation')
@classmethod
@@ -43,13 +45,30 @@
def check_version(self, env):
raise NotImplemented()
+ def check_os(self, supportedOs) :
+ osName = platform.system().lower()
+
+ if len(supportedOs) is 0 :
+ elements = []
+ else :
+ elements = supportedOs.split(';')
+
+ supportedOS = False
+
+ for element in elements :
+ if(osName.startswith(element.lower())):
+ supportedOS = True
+
+ return supportedOS
+
+
def perform_pre_installation(self, env):
if self.attribute('pre_installation').value != '':
commandList = self.attribute('pre_installation').value.split(' or ')
for comandToExecute in commandList :
try:
- resultStatus = commands.getstatusoutput(comandToExecute)
+ resultStatus = commands.getstatusoutput(env.replace_variables(comandToExecute))
if(resultStatus[0] == 0) :
return True
except Exception as e:
--- a/bake/ModuleSource.py Fri Jul 20 17:56:05 2012 +0200
+++ b/bake/ModuleSource.py Mon Jul 23 16:26:26 2012 +0200
@@ -3,6 +3,7 @@
from Utils import ModuleAttributeBase
import os
import urlparse
+import re
from datetime import date
from sets import Set
@@ -226,12 +227,12 @@
def getCommand(self, distribution):
"""Finds the proper installer command line, given the linux distribution."""
distributions = [
- ['debian', 'sudo apt-get -y install '],
- ['ubuntu', 'sudo apt-get -y install '],
- ['fedora', 'sudo yum -y install '],
- ['redhat', 'sudo yum -y install '],
- ['centos', 'sudo yum -y install '],
- ['suse', 'sudo yast --install '],
+ ['debian', 'apt-get -y install '],
+ ['ubuntu', 'apt-get -y install '],
+ ['fedora', 'yum -y install '],
+ ['redhat', 'yum -y install '],
+ ['centos', 'yum -y install '],
+ ['suse', 'yast --install '],
]
for name, command in distributions:
@@ -241,7 +242,6 @@
def remove(self, env):
import platform
- import re
# if the download is dependent of the machine's architecture
osName = platform.system().lower()
@@ -268,6 +268,13 @@
return True
+
+ def addCommandCalls(self, stringToChange, elements):
+ for element in elements:
+ stringToChange= re.sub(element + "(\s|\)|$)" , 'env.check_program(\'' + element + '\')\\1', stringToChange)
+ return stringToChange
+
+
def checkDependencyExpression(self, env, valueToTest):
"""Verifies if the preconditions exist or not."""
@@ -300,11 +307,9 @@
for element in elementsToChange:
elementsSet.add(element)
- stringToChange = valueToTest
- for element in elementsSet :
- if element :
- stringToChange = re.sub(element,'env.check_program(\''+element+'\')',stringToChange)
-
+
+ stringToChange = self.addCommandCalls(valueToTest,elementsSet)
+
# Evaluate if all the programs exist
returnValue = eval(stringToChange)
--- a/dceConf.xml Fri Jul 20 17:56:05 2012 +0200
+++ b/dceConf.xml Mon Jul 23 16:26:26 2012 +0200
@@ -71,21 +71,6 @@
</build>
</module>
- </modules>
-
- <module name="ns-3-dev">
- <source type="mercurial">
- <attribute name="url" value="http://code.nsnam.org/ns-3-dev"/>
- </source>
- <depends_on name="nsc" optional="True"/>
- <depends_on name="pybindgen" optional="True"/>
- <depends_on name="click-1.8.0" optional="True"/>
- <depends_on name="openflow-ns3" optional="True"/>
- <build type="waf" objdir="yes">
- <attribute name="configure_arguments" value="configure --prefix=`pwd`/../build --enable-tests --with-nsc=$INSTALLDIR --with-nsclick=$INSTALLDIR --with-openflow=$INSTALLDIR"/>
- </build>
- </module>
-
<module name="click-1.8.0">
<source type="archive">
<attribute name="url" value="http://read.cs.ucla.edu/click/click-1.8.0.tar.gz"/>
@@ -134,16 +119,19 @@
<depends_on name="pygccxml" optional="True"/>
</module>
+
<module name="nsc">
<source type="mercurial">
<attribute name="url" value="https://secure.wand.net.nz/mercurial/nsc"/>
</source>
<!-- problem: scons has no generic command-line support for builddir and installdir -->
<build type="inline" classname="NscModuleBuild">
+ <attribute name="supported_os" value="linux;linux2"/>
<code>class NscModuleBuild(InlineModuleBuild):
def __init__(self):
InlineModuleBuild.__init__(self)
def build(self, env, jobs):
+
env.run(['python', os.path.join(env.srcdir, 'scons.py'),
'-j', str(jobs), '--prefix=' + env.installdir, 'install'],
directory=env.srcdir)
@@ -164,18 +152,33 @@
<attribute name="name_apt-get" value="qt4-dev-tools"/>
<attribute name="more_information" value="Didn't find QT 4, download and install it from http://qt.nokia.com/downloads/"/>
</source>
+ <build type="none" objdir="no">
+ </build>
</module>
<module name="net_anim">
<source type="mercurial">
<attribute name="url" value="http://code.nsnam.org/netanim"/>
</source>
- <build type="waf" objdir="yes">
- <attribute name="pre_installation" value="qmake NetAnim.pro or qmake-qt4 NetAnim.pro or qmake -spec macx-g++ NetAnim.pro"/>
+ <build type="make" objdir="no">
+ <attribute name="pre_installation" value="cd $SRCDIR;qmake NetAnim.pro or cd $SRCDIR;qmake-qt4 NetAnim.pro or cd $SRCDIR;qmake -spec macx-g++ NetAnim.pro"/>
</build>
<depends_on name="qt4" optional="False"/>
</module>
+ <module name="ns-3">
+ <source type="mercurial">
+ <attribute name="url" value="http://code.nsnam.org/ns-3-dev"/>
+ </source>
+ <depends_on name="net_anim" optional="True"/>
+ <depends_on name="nsc" optional="True"/>
+ <depends_on name="pybindgen" optional="True"/>
+ <depends_on name="click-1.8.0" optional="True"/>
+ <depends_on name="openflow-ns3" optional="True"/>
+ <build type="waf" objdir="yes">
+ <attribute name="configure_arguments" value="configure --prefix=`pwd`/../build --enable-tests --with-nsc=$INSTALLDIR --with-nsclick=$INSTALLDIR --with-openflow=$INSTALLDIR"/>
+ </build>
+ </module>
</modules>
--- a/test/build.py Fri Jul 20 17:56:05 2012 +0200
+++ b/test/build.py Mon Jul 23 16:26:26 2012 +0200
@@ -36,14 +36,14 @@
testStatus = commands.getoutput('rm -f '+ pathname +'/bakefile.xml')
testStatus = commands.getoutput('rm -rf /tmp/source')
- def DD_test_ModuleBuild(self):
+ def test_ModuleBuild(self):
"""Tests the WafModuleBuild Class from ModuleBuild. """
build = ModuleBuild.create("non_Existing_BuilTool")
self.assertEqual(build , None)
- def DD_test_PythonModuleBuild(self):
+ def test_PythonModuleBuild(self):
"""Tests the WafModuleBuild Class from ModuleBuild. """
# creating python build module test
@@ -148,7 +148,7 @@
# self.assertEqual(created, "0")
- def DD_test_WafModuleBuild(self):
+ def test_WafModuleBuild(self):
"""Tests the WafModuleBuild Class from ModuleBuild. """
waf = ModuleBuild.create("waf")
@@ -271,7 +271,7 @@
# testResult = waf._is_1_6_x(self._env)
# self.assertFalse(testResult)
- def DD_test_WafModuleBuildPybind(self):
+ def test_WafModuleBuildPybind(self):
"""Tests the WafModuleBuild Class from ModuleBuild. """
waf = ModuleBuild.create("waf")
@@ -388,7 +388,7 @@
# testResult = waf._is_1_6_x(self._env)
# self.assertFalse(testResult)
- def DD_test_CmakeModule(self):
+ def test_CmakeModule(self):
"""Tests the WafModuleBuild Class from ModuleBuild. """
cmake = ModuleBuild.create("cmake")
@@ -472,7 +472,7 @@
created = re.compile('\d+').search(testStatus).group()
self.assertNotEqual(created, "0")
- def DD_test_makeModule(self):
+ def test_makeModule(self):
"""Tests the WafModuleBuild Class from ModuleBuild. """
make = ModuleBuild.create("make")
@@ -558,7 +558,7 @@
created = re.compile('\d+').search(testStatus).group()
self.assertEqual(created, "0")
- def DD_test_genneralBuildArguments(self):
+ def test_genneralBuildArguments(self):
"""Tests the genneral arguments passed to the Build. """
waf = ModuleBuild.create("waf")
@@ -652,9 +652,11 @@
"""Tests pre instalation command call. """
waf = ModuleBuild.create("waf")
+ self._env.start_build("testModule", "testModule",
+ waf.supports_objdir)
self.assertNotEqual(waf, None)
self.assertEqual(waf.name(), "waf")
-
+
waf.attribute("pre_installation").value = "ls"
testResult = waf.perform_pre_installation(self._env)
self.assertTrue(testResult)
@@ -680,6 +682,34 @@
self.assertTrue(testResult)
+ def test_supportedOS(self):
+ """Tests pre instalation command call. """
+
+ waf = ModuleBuild.create("waf")
+ self.assertNotEqual(waf, None)
+ self.assertEqual(waf.name(), "waf")
+ import platform
+ osName = platform.system().lower()
+
+ self.assertTrue(osName.startswith('linux'))
+
+ waf.attribute("supported_os").value = "linux"
+ testResult = waf.check_os(waf.attribute("supported_os").value)
+ self.assertTrue(testResult)
+
+ waf.attribute("supported_os").value = "darwing;linux"
+ testResult = waf.check_os(waf.attribute("supported_os").value)
+ self.assertTrue(testResult)
+
+ waf.attribute("supported_os").value = "darwing;bsd"
+ testResult = waf.check_os(waf.attribute("supported_os").value)
+ self.assertFalse(testResult)
+
+ waf.attribute("supported_os").value = ""
+ testResult = waf.check_os(waf.attribute("supported_os").value)
+ self.assertFalse(testResult)
+
+
# testStatus = commands.getoutput('ls -l /tmp/source/openflow-ns3/object|wc')
# created = re.compile('\d+').search(testStatus).group()
# self.assertNotEqual(created, "0")
--- a/test/source.py Fri Jul 20 17:56:05 2012 +0200
+++ b/test/source.py Mon Jul 23 16:26:26 2012 +0200
@@ -33,14 +33,14 @@
print (inst) # the exception instance
self.fail("Could not execute command %s over directory %s failed" % (command, dir))
- def DD_test_generalFailures(self):
+ def test_generalFailures(self):
"""Tests Some general failures that could happen in the Module Source. """
#Verifies the return of the creation of a non existent module
module = ModuleSource.create("NonExistentModule")
self.assertEqual(module, None)
- def DD_test_archiveModuleSource(self):
+ def test_archiveModuleSource(self):
"""Tests the ArchiveModuleSource class. """
# it first needs to be able to create the class otherwise will not be
@@ -183,7 +183,7 @@
#
# testStatus = commands.getoutput('chmod 755 /tmp/click-1.8.0; rm -rf /tmp/click-1.8.0')
- def DD_test_SystemDependencySource(self):
+ def test_SystemDependencySource(self):
"""Tests the SelfInstallerModule class. """
# it first needs to be able to create the class otherwise will not be
@@ -324,7 +324,7 @@
self.assertTrue(testResult)
- def DD_test_mercurial(self):
+ def test_mercurial(self):
"""Tests the MercurialModuleSource class. """
# it first needs to be able to create the class otherwise will not be
@@ -449,7 +449,7 @@
# last clean up
self.executeCommand(["rm", "-rf", "bake"], "/tmp")
- def DD_test_bazaar(self):
+ def test_bazaar(self):
"""Tests the BazaarModuleSource class. """
# checks if can create the class
@@ -606,7 +606,7 @@
# last clean up
self.executeCommand(["rm", "-rf", "pybindgen"], "/tmp")
- def DD_test_cvs(self):
+ def test_cvs(self):
"""Tests the CvsModuleSourceclass. """
# checks if can create the class
@@ -737,7 +737,7 @@
# last clean up
self.executeCommand(["rm", "-rf", "gccxml"], "/tmp")
- def DD_test_git(self):
+ def test_git(self):
"""Tests the GitModuleSource. """
# checks if can create the class