X-Git-Url: http://git.efficios.com/?p=deliverable%2Flttng-ivc.git;a=blobdiff_plain;f=lttng_ivc%2Futils%2Fproject.py;h=5111819d432ed93c75d890bfff40d7c432c91bb9;hp=50df68796cdcd0d646c00232f6f3e979517852dc;hb=8e2c5f79e23839ec13866fc4827a1c402aab1687;hpb=18aedaf96b66a383f46487b7203bc35fc2280900 diff --git a/lttng_ivc/utils/project.py b/lttng_ivc/utils/project.py index 50df687..5111819 100644 --- a/lttng_ivc/utils/project.py +++ b/lttng_ivc/utils/project.py @@ -1,8 +1,32 @@ +# Copyright (c) 2017 Jonathan Rajotte-Julien +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + import os import shutil import git import subprocess import logging +import lttng_ivc.settings as Settings + +from lttng_ivc.utils.utils import sha256_checksum +from lttng_ivc.utils.utils import find_dir, find_file _logger = logging.getLogger('project') @@ -19,21 +43,29 @@ class Project(object): if ccache is not None: self.custom_configure_flags.append("CC={} gcc".format(ccache)) self.custom_configure_flags.append("CXX={} g++".format(ccache)) + self.custom_configure_flags.append("CFLAGS=-g -O0".format(ccache)) """ A collection of Project dependencies """ self.dependencies = {} + # used for project cache and pickle validation self._immutable = False + self._py_file_checksum = sha256_checksum(Settings.project_py_file_location) # State self.isBuilt = False self.isConfigured = False self.isInstalled = False + self.skip = False self.basedir = tmpdir self.log_path = os.path.join(tmpdir, "log") self.source_path = os.path.join(tmpdir, "source") self.installation_path = os.path.join(tmpdir, "install") + if os.path.isdir(self.basedir): + # Perform cleanup since it should not happen + shutil.rmtree(self.basedir) + os.makedirs(self.log_path) os.makedirs(self.source_path) os.makedirs(self.installation_path) @@ -130,12 +162,26 @@ class Project(object): if self.isConfigured ^ self.isBuilt ^ self.isInstalled: raise Exception("Project steps where manually triggered. Can't autobuild") - _logger.debug("% Autobuild configure", self.label) - self.configure() - _logger.debug("% Autobuild build", self.label) - self.build() - _logger.debug("% Autobuild install", self.label) - self.install() + _logger.debug("{} Autobuild configure".format(self.label)) + try: + self.configure() + except subprocess.CalledProcessError as e: + _logger.error("{} Configure failed. See {} for more details.".format(self.label, self.log_path)) + raise e + + _logger.debug("{} Autobuild build".format(self.label)) + try: + self.build() + except subprocess.CalledProcessError as e: + _logger.error("{} Build failed. See {} for more details.".format(self.label, self.log_path)) + raise e + + _logger.debug("{} Autobuild install".format(self.label)) + try: + self.install() + except subprocess.CalledProcessError as e: + _logger.error("{} Install failed. See {} for more details.".format(self.label, self.log_path)) + raise e def checkout(self): if self._immutable: @@ -209,13 +255,13 @@ class Project(object): os.chdir(self.source_path) args = ['make'] env = self.get_env() - env['CFLAGS'] = '-g -O0' # Number of usable cpu # https://docs.python.org/3/library/os.html#os.cpu_count num_cpu = str(len(os.sched_getaffinity(0))) args.append('-j') args.append(num_cpu) + args.append('V=1') # TODO: log output and add INFO log point with args with open(out, 'w') as stdout, open(err, 'w') as stderr: @@ -233,8 +279,8 @@ class Project(object): if self._immutable: raise Exception("Object is immutable. Illegal install") - out = os.path.join(self.log_path, "build.out") - err = os.path.join(self.log_path, "build.err") + out = os.path.join(self.log_path, "install.out") + err = os.path.join(self.log_path, "install.err") os.chdir(self.source_path) args = ['make', 'install'] @@ -255,6 +301,11 @@ class Project(object): class Lttng_modules(Project): + def __init__(self, label, git_path, sha1, tmpdir): + super(Lttng_modules, self).__init__(label=label, git_path=git_path, + sha1=sha1, tmpdir=tmpdir) + self.add_special_env_variable("MODPROBE_OPTIONS","-d {}".format(self.installation_path)) + def bootstrap(self): pass @@ -277,12 +328,34 @@ class Lttng_modules(Project): p.check_returncode() self.isInstalled = True + def autobuild(self): + try: + super(Lttng_modules, self).autobuild() + except subprocess.CalledProcessError as e: + self.skip = True + class Lttng_ust(Project): def __init__(self, label, git_path, sha1, tmpdir): super(Lttng_ust, self).__init__(label=label, git_path=git_path, sha1=sha1, tmpdir=tmpdir) self.custom_configure_flags.extend(['--disable-man-pages']) + self.custom_configure_flags.extend(['--enable-python-agent']) + self.custom_configure_flags.extend(['--enable-java-agent-jul']) + + jul_path = os.path.join(self.installation_path, + "share/java/liblttng-ust-agent.jar") + classpath = ":".join([jul_path, '.']) + self.add_special_env_variable("CLASSPATH", classpath) + + def install(self): + super(Lttng_ust, self).install() + python_path = find_dir(self.installation_path, "lttngust") + if python_path: + # Fetch the parent of lttngust folder + python_path = os.path.dirname(python_path) + self.add_special_env_variable("PYTHONPATH", python_path) + class Lttng_tools(Project): @@ -292,6 +365,15 @@ class Lttng_tools(Project): self.add_special_env_variable("LTTNG_SESSION_CONFIG_XSD_PATH", os.path.join(self.installation_path, "share/xml/lttng/")) + # Find the mi xsd + for xsd in Settings.mi_xsd_file_name: + mi = find_file(self.source_path, xsd) + if mi: + break + if not mi: + raise Exception("MI xsd not found") + self.mi_xsd = mi + class Babeltrace(Project): pass