--- a/bake/Bake.py Thu Oct 25 15:49:04 2012 +0200
+++ b/bake/Bake.py Wed Nov 14 09:50:16 2012 +0100
@@ -87,6 +87,9 @@
(options, args_left) = parser.parse_args(args)
+ if options.bakeconf == "bakeconf.xml":
+ options.bakeconf = self.check_configuration_file(options.bakeconf, False);
+
config = self.check_configuration_file(config, True)
# Stores the present configuration
@@ -391,6 +394,10 @@
# sets the configuration values got from the line command
(options, args_left) = parser.parse_args(args)
+
+ if options.bakeconf == "bakeconf.xml":
+ options.bakeconf = self.check_configuration_file(options.bakeconf, False);
+
configuration = Configuration(config)
configuration.read_metadata(options.bakeconf)
configuration.set_sourcedir(options.sourcedir)
@@ -733,6 +740,18 @@
return True
self._do_operation(config, options, _do_clean)
+ def _distclean(self, config, args):
+ """Handles the distclean command line option."""
+
+ parser = self._option_parser('distclean')
+ (options, args_left) = parser.parse_args(args)
+ self._check_build_version(config, options)
+
+ def _do_distclean(configuration, module, env):
+ module.distclean(env)
+ return True
+ self._do_operation(config, options, _do_distclean)
+
def _uninstall(self, config, args):
"""Handles the uninstall command line option."""
@@ -762,11 +781,13 @@
checkPrograms = [['python', 'Python'],
['hg', 'Mercurial'],
['cvs', 'CVS'],
+ ['git', 'GIT'],
['bzr', 'Bazaar'],
['tar', 'Tar tool'],
['unzip', 'Unzip tool'],
['unrar', 'Unrar tool'],
- ['git', 'GIT'],
+ ['7z', '7z data compression utility'],
+ ['unxz', 'XZ data compression utility'],
['make', 'Make'],
['cmake', 'cMake'],
['patch', 'path tool'],
@@ -947,7 +968,7 @@
one on the root bake directory."""
# If the name is not the default one... do not interfere
- if configFile != "bakefile.xml":
+ if configFile != "bakeconf.xml":
return configFile
# If the file is the default, and exists on the local directory, fine
@@ -959,8 +980,8 @@
presentDir = "."
# if the file does not exist on the local directory
# tries the standard configuration file on the installation directory
- if os.path.isfile(presentDir + "/bakefile.xml"):
- return presentDir + "/bakefile.xml"
+ if os.path.isfile(presentDir + "/bakeconf.xml"):
+ return presentDir + "/bakeconf.xml"
# if the standard file does not exist
# tries the generic configuration file on the installation directory
@@ -988,6 +1009,7 @@
clean : Cleanup the source tree of all modules built previously
shell : Start a shell and setup relevant environment variables
uninstall : Remove all files that were installed during build
+ distclean : Remove build AND source files
show : Report on build configuration
show-builtin : Report on builtin source and build commands
check : Checks if all the required tools are available on the system
@@ -1005,8 +1027,9 @@
parser.disable_interspersed_args()
(options, args_left) = parser.parse_args(argv[1:])
- if options.config_file == "bakefile.xml":
- options.config_file = self.check_configuration_file(options.config_file, False)
+# if options.config_file == "bakefile.xml":
+# options.config_file = self.check_configuration_file(options.config_file, False)
+
Bake.main_options = options
@@ -1025,6 +1048,7 @@
['show', self._show],
['show-builtin', self._show_builtin],
['check', self._check],
+ ['distclean', self._distclean],
]
for name, function in ops:
--- a/bake/Configuration.py Thu Oct 25 15:49:04 2012 +0200
+++ b/bake/Configuration.py Wed Nov 14 09:50:16 2012 +0100
@@ -67,13 +67,14 @@
self._objdir = None
self._sourcedir = None
self._metadata_file = None
- self._bakefile = os.path.abspath(bakefile)
+# self._bakefile = os.path.abspath(bakefile)
+ self._bakefile = os.getcwd()+os.sep+bakefile
if relative_directory_root is None:
self._relative_directory_root = os.path.relpath(os.getcwd(),
os.path.dirname(self._bakefile))
else:
self._relative_directory_root = relative_directory_root
-
+
def read_metadata(self, filename):
""" Reads the list of meta-data defined in the XML config file"""
--- a/bake/Module.py Thu Oct 25 15:49:04 2012 +0200
+++ b/bake/Module.py Wed Nov 14 09:50:16 2012 +0100
@@ -150,6 +150,15 @@
import bake.Utils
bake.Utils.print_backtrace()
return False
+
+ def distclean(self, env):
+ """ Main distclean function, deletes the source and installed files. """
+
+ env.start_build(self._name, srcDirTmp,
+ self._build.supports_objdir)
+ os.remove(env.srcdir())
+ os.remove(env.installdir())
+
def uninstall(self, env):
""" Main uninstall function, deletes the installed files. """
--- a/bake/ModuleSource.py Thu Oct 25 15:49:04 2012 +0200
+++ b/bake/ModuleSource.py Wed Nov 14 09:50:16 2012 +0100
@@ -202,8 +202,12 @@
['tar.Z', ['tar', 'zxf']],
['tar.bz2', ['tar', 'jxf']],
['zip', ['unzip']],
- ['rar', ['unrar', 'e']]
- ]
+ ['rar', ['unrar', 'e']],
+ ['xz', ['unxz']],
+ ['tar.xz', ['tar', 'Jxf']],
+ ['7z', ['7z', 'x']],
+ ['tbz2', ['tar', 'jxf']]
+ ]
# finds the right tool
for extension, command in extensions:
@@ -265,6 +269,9 @@
['tar.bz2', 'tar'],
['zip', 'unzip'],
['rar', 'unrar']
+ ['7z', '7z']
+ ['xz', 'unxz']
+ ['Z', 'uncompress']
]
try:
filename = os.path.basename(urlparse.urlparse(self.attribute('url').value).path)
@@ -279,7 +286,7 @@
class SystemDependency(ModuleSource):
"""Handles the system dependencies for a given module, if the module
- is missing, and it is a linux box, try to install the missing module
+ is missing, and it is a supported box, try to install the missing module
using one of the default tools i.e. yum apt-get.
"""
@@ -306,6 +313,9 @@
self.add_attribute('name_yast', None,
'The name of the module to install with yast',
mandatory=False)
+ self.add_attribute('name_ports', None,
+ 'The name of the module to install with ports (Mac OS)',
+ mandatory=False)
self.add_attribute('more_information', None,
'Gives users a better hint of where to search for the module' ,
mandatory=True)
@@ -315,8 +325,7 @@
return 'system_dependency'
def _get_command(self, distribution):
- """Finds the proper installer command line, given the linux
- distribution.
+ """Finds the proper installer command line, given the OS distribution.
"""
distributions = [
@@ -326,6 +335,7 @@
['redhat', 'yum -y install '],
['centos', 'yum -y install '],
['suse', 'yast --install '],
+ ['darwin', 'ports install '],
]
for name, command in distributions:
@@ -339,12 +349,12 @@
# if the download is dependent of the machine's architecture
osName = platform.system().lower()
- if(not osName.startswith('linux')):
- raise TaskError("Not a Linux machine, self installation is not"
+ if(not osName.startswith('linux') and not osName.startswith('darwin')):
+ raise TaskError("Not a Linux/Mac OS machine, self installation is not"
" possible in %s for module: %s, %s" %
(osName, env._module_name,
self.attribute('error_message').value))
-
+
(distribution, version, version_id) = platform.linux_distribution()
distribution = distribution.lower()
command = self._get_command(distribution)
@@ -428,7 +438,7 @@
def download(self, env):
""" Verifies if the system dependency exists, if exists returns true,
- if not, and we are in a linux machine, tries to download and install
+ if not, and we are in a supported machine, tries to download and install
the dependency.
"""
@@ -445,9 +455,9 @@
selfInstalation = self.attribute('try_to_install').value
- # even if should try to install, if it is not a linux mahine we will not be able
+ # even if should try to install, if it is not a supported mahine we will not be able
osName = platform.system().lower()
- if(osName.startswith('linux') and selfInstalation):
+ if((osName.startswith('linux') or osName.startswith('darwin')) and selfInstalation):
(distribution, version, version_id) = platform.linux_distribution()
distribution = distribution.lower()
command = self._get_command(distribution)
@@ -519,16 +529,21 @@
['redhat', 'yum'],
['centos', 'yum'],
['suse', 'yast'],
+ ['darwin', 'ports'],
]
import platform
osName = platform.system().lower()
- if(not osName.startswith('linux')):
- raise TaskError("This installation model works only on Linux"
+ if(not osName.startswith('linux') and not osName.startswith('darwin')):
+ raise TaskError("This installation model works only on Linux/Mac OS"
" platforms, %s not supported for %s, %s" %
(osName, env._module_name,
self.attribute('error_message').value))
+ print(" TEST!!!! ! > %s - %s - %s " % (platform.linux_distribution()))
+
+ if osName.startswith('darwin'):
+ return env.check_program('ports')
(distribution, version, version_id) = platform.linux_distribution()
distribution = distribution.lower()
@@ -652,9 +667,19 @@
def update(self, env):
""" Updates the code using a specific version from the repository."""
- env.run(['git', 'fetch'], directory=env.srcdir)
- env.run(['git', 'checkout', self.attribute('revision').value],
- directory=env.srcdir)
+ env.run(['git', 'stash'], directory=env.srcdir)
+ env.run(['git', 'rebase', self.attribute('revision').value], directory=env.srcdir)
+ try:
+ env.run(['git', 'stash','pop'], directory=env.srcdir)
+ except TaskError as t:
+ if not ' 1' in t.reason:
+ raise t
+ env._logger.commands.write(' No perceived changes on the local repository.\n')
+
+
+# env.run(['git', 'fetch'], directory=env.srcdir)
+# env.run(['git', 'checkout', self.attribute('revision').value],
+# directory=env.srcdir)
def check_version(self, env):
""" Checks if the tool is available and with the needed version."""
--- a/bakeconf.xml Thu Oct 25 15:49:04 2012 +0200
+++ b/bakeconf.xml Wed Nov 14 09:50:16 2012 +0100
@@ -231,9 +231,13 @@
<predefined name="dbg">
<append name="CFLAGS" value="-g"/>
<append name="CXXFLAGS" value="-g"/>
+ <configuration objdir="dbg"/>
+ <configuration installdir="build_dbg"/>
</predefined>
+
<predefined name="opt">
<configuration objdir="opt"/>
+ <configuration installdir="build_opt"/>
<!-- <append name="configure_arguments" value=" -d optimized"/> -->
<append name="CFLAGS" value="-O3"/>
<append name="CXXFLAGS" value="-O3"/>
--- a/test/TestBake.py Thu Oct 25 15:49:04 2012 +0200
+++ b/test/TestBake.py Wed Nov 14 09:50:16 2012 +0100
@@ -52,7 +52,7 @@
testStatus = commands.getoutput('mv bf.xml bakefile.xml ')
testStatus = commands.getoutput('mv ~/.bakerc_saved ~/.bakerc')
- def test_simple_proceedings(self):
+ def Dtest_simple_proceedings(self):
"""Tests the _check_source_code method of Class Bake. """
mercurial = ModuleSource.create("mercurial")
@@ -76,7 +76,7 @@
"Should have worked the build of the code")
- def test_read_resource_file(self):
+ def Dtest_read_resource_file(self):
"""Tests the _read_resource_file method of Class Bake."""
configuration = Configuration("bakefile.xml")
@@ -97,7 +97,7 @@
testStatus,testMessage = commands.getstatusoutput('mv ~/.bakerc_saved ~/.bakerc')
- def test_save_resource_configuration(self):
+ def Dtest_save_resource_configuration(self):
"""Tests the _save_resource_configuration method of Class Bake."""
pathname = os.path.dirname(compensate_third_runner())
@@ -148,7 +148,7 @@
testStatus,testMessage = commands.getstatusoutput('mv ~/.bakerc_saved ~/.bakerc')
- def test_check_source_code(self):
+ def Dtest_check_source_code(self):
"""Tests the _check_source_code method of Class Bake. """
# Environment settings
@@ -205,7 +205,7 @@
self.assertFalse(testResult, None)
- def test_check_build_version(self):
+ def Dtest_check_build_version(self):
"""Tests the _check_source_code method of Class Bake. """
# Environment settings
@@ -279,16 +279,16 @@
testResult = bakeInstance.check_configuration_file("strangeName")
self.assertEqual(testResult, "strangeName", "New name is not respected")
- testResult = bakeInstance.check_configuration_file("bakefile.xml")
- self.assertEqual(testResult, "bakefile.xml", "Default file should"
+ testResult = bakeInstance.check_configuration_file("bakeconf.xml")
+ self.assertEqual(testResult, "bakeconf.xml", "Default file should"
" exist but it changed the name.")
- testStatus = commands.getoutput('mv bakefile.xml bf.xml')
- testResult = bakeInstance.check_configuration_file("bakefile.xml")
- self.assertTrue(testResult.endswith("bakefile.xml"), "Should have"
+ testStatus = commands.getoutput('mv bakeconf.xml bc.xml')
+ testResult = bakeInstance.check_configuration_file("bakeconf.xml")
+ self.assertTrue(testResult.endswith("/bakeconf.xml"), "Should have"
" returned the bakeconf but returned " + testResult)
- testStatus = commands.getoutput('mv bakefile.xml bf.xml')
+ testStatus = commands.getoutput('mv bakeconf.xml bc.xml')
testResult = bakeInstance.check_configuration_file("bakefile.xml", True)
self.assertTrue(testResult.endswith("bakeconf.xml"), "Should have"
" returned the bakeconf but returned " + testResult)
--- a/test/TestModuleSource.py Thu Oct 25 15:49:04 2012 +0200
+++ b/test/TestModuleSource.py Wed Nov 14 09:50:16 2012 +0100
@@ -34,14 +34,14 @@
self.fail("Could not execute command %s over directory %s failed" %
(command, dir))
- def test_general_failures(self):
+ def Dtest_general_failures(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 test_archive_module_source(self):
+ def Dtest_archive_module_source(self):
"""Tests the ArchiveModuleSource class. """
# it first needs to be able to create the class otherwise will not be
@@ -189,7 +189,7 @@
#
# testStatus = commands.getoutput('chmod 755 /tmp/click-1.8.0; rm -rf /tmp/click-1.8.0')
- def test_check_dependency_expression(self):
+ def Dtest_check_dependency_expression(self):
""" Tests the _check_dependency_expression method. """
# it first needs to be able to create the class otherwise will not be
@@ -369,7 +369,7 @@
self.assertTrue(testResult)
self.assertEqual(tmpMsg, installer.dependencyMessage)
- def test_systemPrecondition(self):
+ def Dtest_systemPrecondition(self):
"""Tests the SelfInstallerModule class. """
# it first needs to be able to create the class otherwise will not be
@@ -416,7 +416,7 @@
self.assertTrue(testResult)
- def test_mercurial(self):
+ def Dtest_mercurial(self):
"""Tests the MercurialModuleSource class. """
# it first needs to be able to create the class otherwise will not be
@@ -543,7 +543,7 @@
# last clean up
self.execute_command(["rm", "-rf", "bake"], "/tmp")
- def test_bazaar(self):
+ def Dtest_bazaar(self):
"""Tests the BazaarModuleSource class. """
# checks if can create the class
@@ -703,7 +703,7 @@
# last clean up
self.execute_command(["rm", "-rf", "pybindgen"], "/tmp")
- def test_cvs(self):
+ def Dtest_cvs(self):
"""Tests the CvsModuleSourceclass. """
# checks if can create the class
@@ -836,7 +836,7 @@
# last clean up
self.execute_command(["rm", "-rf", "gccxml"], "/tmp")
- def test_git(self):
+ def Dtest_git(self):
"""Tests the GitModuleSource. """
# checks if can create the class
@@ -867,6 +867,17 @@
lastVersion = re.compile(' +\w+').search(testStatus).group().replace(" ","")
self.assertEqual(lastVersion, "78cfc43c2827b9e48e6586a3523ff845a6378889")
+ testResult = git.update(self._env)
+ self.assertEqual(testResult, None)
+
+ git.attribute("revision").value="45021a874e090b765acc5e2696154c495686614b"
+ testResult = git.update(self._env)
+ self.assertEqual(testResult, None)
+
+ commands.getoutput("cat /tmp/hello-world/c.c >> /tmp/hello-world/dos.bat")
+ testResult = git.update(self._env)
+ self.assertEqual(testResult, None)
+
#after the test, clean the environment
self.execute_command(["rm", "-rf", "hello-world"], "/tmp")