Exemple #1
0
 def __init__(self, basename, sources, path, destination = '.',
              preload = None):
   self.__destination = drake.Path(destination)
   basename = drake.Path(basename)
   self.__target = drake.node(self.__destination / basename)
   self.__destination = drake.path_build(self.__destination)
   self.__path = drake.path_build(path)
   self.__preload = preload
   if preload is not None:
     sources += [preload]
   super().__init__(sources, [self.__target])
Exemple #2
0
 def command_configure(self):
   if self.__configure is None:
       return None
   config = [str(drake.path_build(absolute = True) / self.__configure.path())]
   if self.__configure_interpreter is not None:
     config.insert(0, self.__configure_interpreter)
   return config + self.__configure_args
Exemple #3
0
 def command_configure(self):
   if self.__configure is None:
       return None
   config = [str(drake.path_build(absolute = True) / self.__configure.path())]
   if self.__configure_interpreter is not None:
     config.insert(0, self.__configure_interpreter)
   return config + self.__configure_args
Exemple #4
0
    def __init__(self, path = None, command = GitCommand()):
        """Create a GitVersion.

        path -- path to the repository; the source dir by default.
        """
        if path is None:
            path = '.'
        self.__path = drake.path_source(path)
        self.__name = drake.path_build(path)
        super().__init__(self.__name / 'git')
Exemple #5
0
 def _set_local_libcxx(tgt):
     if cxx_toolkit.os in [drake.os.macos]:
         with drake.WritePermissions(drake.node(tgt)):
             return drake.command([
                 'install_name_tool', '-change', '/usr/lib/libc++.1.dylib',
                 '@rpath/libc++.1.dylib',
                 str(drake.path_build(tgt, True))
             ])
     else:
         return True
Exemple #6
0
 def __init__(self,
              input_libs,
              output_lib,
              headers=[],
              input_headers=None,
              output_headers=None):
     drake.Builder.__init__(
         self, input_libs,
         itertools.chain([output_lib],
                         (drake.node(output_headers / p) for p in headers)))
     self.__input_libs = input_libs
     self.__output_lib = output_lib
     self.__headers = headers
     if input_headers:
         self.__input_headers = drake.path_build(input_headers)
     else:
         self.__input_headers = None
     if output_headers:
         self.__output_headers = drake.path_build(output_headers)
     else:
         self.__output_headers = None
Exemple #7
0
 def __init__(self,
              basename,
              attributes,
              sources,
              path,
              destination='.',
              preload=None,
              cleanup_source_directory=True):
     path = drake.Path(path)
     self.__destination = drake.Path(destination)
     basename = drake.Path(basename)
     self.__target = drake.node(self.__destination / basename)
     self.__destination = drake.path_build(self.__destination)
     self.__path = drake.path_build(path)
     self.__preload = preload
     self.__attrs = attributes
     self.__control = drake.node(path / 'DEBIAN/control')
     if preload is not None:
         sources += [preload]
     self.__cleanup_source_directory = cleanup_source_directory
     super().__init__(sources, [self.__control, self.__target])
Exemple #8
0
 def __init__(self,
              basename,
              attributes,
              sources,
              path,
              destination = '.',
              preload = None,
              cleanup_source_directory = True):
   path = drake.Path(path)
   self.__destination = drake.Path(destination)
   basename = drake.Path(basename)
   self.__target = drake.node(self.__destination / basename)
   self.__destination = drake.path_build(self.__destination)
   self.__path = drake.path_build(path)
   self.__preload = preload
   self.__attrs = attributes
   self.__control = drake.node(path / 'DEBIAN/control')
   if preload is not None:
     sources += [preload]
   self.__cleanup_source_directory = cleanup_source_directory
   super().__init__(
     sources, [self.__control, self.__target])
Exemple #9
0
    def __init__(self, name, root, nodes, fullname=None):
        '''Create a python Package

    name  -- the node name
    root  -- the package root
    nodes -- the package files
    '''
        super().__init__(name)
        self.__root = root
        self.__root_source = drake.path_source(root)
        self.__root_build = drake.path_build(root)
        self.__nodes = nodes
        for node in nodes:
            self.dependency_add(node)
        self.__fullname = fullname or name
Exemple #10
0
  def __init__(self, name, root, nodes, fullname = None):
    '''Create a python Package

    name  -- the node name
    root  -- the package root
    nodes -- the package files
    '''
    super().__init__(name)
    self.__root = root
    self.__root_source = drake.path_source(root)
    self.__root_build = drake.path_build(root)
    self.__nodes = nodes
    for node in nodes:
      self.dependency_add(node)
    self.__fullname = fullname or name
Exemple #11
0
    def __init__(self, path = None):
        """Create a GitVersion.

        path -- path to the repository; the source dir by default.
        """
        if path is None:
            path = '.'
        self.__path = drake.path_source(path)
        self.__name = drake.path_build(path)
        VirtualNode.__init__(self, self.__name / 'git')
        self.__author_date = None
        self.__revision    = None
        self.__description = None
        self.__version    = None
        self.__message     = None
Exemple #12
0
 def __init__(self,
              template,
              content = {},
              sources = [],
              pythonpath = (),
              hooks = {}):
   self.__template = template
   self.__hooks = hooks
   dst = template.name_relative.without_last_extension()
   self.__target = drake.node(dst)
   super().__init__(self.__template,
                    self.__target,
                    additional_sources = sources)
   self.__content = content
   self.__pythonpath = []
   for path in pythonpath:
     self.__pythonpath.append(drake.path_source(path))
     self.__pythonpath.append(drake.path_build(path))
Exemple #13
0
 def __init__(self,
              template,
              content={},
              sources=[],
              pythonpath=(),
              hooks={},
              lookup=[],
              post_process=None):
     self.__template = template
     self.__hooks = hooks
     dst = template.name_relative.without_last_extension()
     self.__target = drake.node(dst)
     super().__init__(self.__template,
                      self.__target,
                      additional_sources=sources)
     self.__content = content
     self.__lookup = lookup
     self.__post_process = post_process
     self.__pythonpath = []
     for path in pythonpath:
         self.__pythonpath.append(drake.path_source(path))
         self.__pythonpath.append(drake.path_build(path))
Exemple #14
0
 def execute(self):
   env = dict(self.__env)
   import os
   env.update(os.environ)
   with drake.CWDPrinter(drake.path_root() / drake.path_build() / self.work_directory):
     # Patch
     if self.__patch is not None:
       patch_path = str(drake.path_root() / self.__patch.path())
       patch_cmd = ['patch', '-N', '-p', '1', '-i', patch_path],
       if not self.cmd('Patch %s' % self.work_directory,
                       patch_cmd,
                       cwd = self.work_directory):
         return False
     # Configure step
     if self.__configure is not None:
        if not self.cmd('Configure %s' % self.work_directory,
                        self.command_configure,
                        cwd = self.work_directory,
                        env = env,
                        leave_stdout = False):
            return False
     # Build step
     if not self.cmd('Build %s' % self.work_directory,
                     self.command_build,
                     cwd = self.work_directory,
                     env = env,
                     leave_stdout = False):
       return False
   for target in self.__targets:
     path = target.path().without_prefix(self.work_directory)
     if isinstance(target, drake.cxx.DynLib):
       rpath = '.'
     elif isinstance(target, drake.cxx.Executable):
       rpath = '../lib'
     else:
       continue
     with drake.WritePermissions(target):
       cmd = self.__toolkit.rpath_set_command(target.path(), rpath)
       if self.__toolkit.os is not drake.os.windows:
         if not self.cmd('Fix rpath for %s' % target.path(), cmd):
           return False
       # On OS X, we ensure that the library id and paths to dependency
       # libraries are correct.
       if self.__toolkit.os is drake.os.macos:
         cmd = ['install_name_tool',
                '-id', '@rpath/%s' % target.name().basename(),
                 str(target.path())]
         if not self.cmd('Fix rpath for %s' % target.path(), cmd):
           return False
         lib_dependecies = self.parse_otool_libraries(target.path())
         for dep in lib_dependecies:
           if dep.basename() in (t.path().basename() for t in self.__targets):
             cmd = [
               'install_name_tool',
               '-change',
               str(dep),
               '@rpath/%s' % dep.basename(),
               str(target.path()),
             ]
             if not self.cmd('Fix dependency name for %s' % target.path(), cmd):
               return False
   return True
Exemple #15
0
 def command(self):
   return ['makensis',
           '-NOCD',
           '-XOutFile %s' % drake.path_build(self.__target.name()),
           self.__script]
Exemple #16
0
 def output_dir(self):
     return drake.path_build(self.__output)
Exemple #17
0
    def __init__(self,
                 cxx_toolkit=None,
                 prefix=None,
                 version=Version(),
                 version_effective=None,
                 prefer_shared=True):
        """Find and create a configuration for Boost.

    prefix -- Where to find Boost, should contain
              include/boost/version.hpp among others. /usr and
              /usr/local are searched by default. If relative, it
              is rooted in the source tree.
    version -- Requested version.
    prefer_shared -- Check dynamic libraries first.
    """
        # Fix arguments
        cxx_toolkit = cxx_toolkit or drake.cxx.Toolkit()
        self.__cxx_toolkit = cxx_toolkit
        self.__prefer_shared = prefer_shared
        # Compute the search path.
        if prefix is None:
            test = [
                path.dirname() for path in cxx_toolkit.include_path
                if path.basename() == 'include'
            ]
        else:
            test = [Path(prefix)]
        token = drake.Path('boost/version.hpp')
        include_subdirs = {drake.Path('include')}
        for prefix in test:
            for subdir in include_subdirs:
                if not (prefix / subdir).exists():
                    continue
                include_subdirs = include_subdirs.union(
                    (subdir / p for p in (prefix / subdir).list()
                     if p.startswith('boost-')))
        tokens = map(lambda p: p / token, include_subdirs)
        prefixes = self._search_many_all(list(tokens), test)
        miss = []
        if version_effective is not None:
            assert prefix is not None
        # Try every search path
        for path, include_subdir in prefixes:
            path = drake.path_build(path)
            include_subdir = include_subdir.without_suffix(token)
            # Create basic configuration for version checking.
            cfg = Config()
            cfg.add_system_include_path(
                path.without_prefix(drake.path_build()) / include_subdir)
            self.__lib_path = path / 'lib'
            cfg.lib_path(path.without_prefix(drake.path_build()) / 'lib')
            # Check the version.
            if version_effective is None:
                version_eff = cxx_toolkit.preprocess(
                    '#include <boost/version.hpp>\nBOOST_VERSION', config=cfg)
                version_eff = int(version_eff.split('\n')[-2].strip())
                version_eff = Version(version_eff // 100000,
                                      version_eff // 100 % 1000,
                                      version_eff % 100)
            else:
                version_eff = version_effective
            if version_eff not in version:
                miss.append(version_eff)
                continue
            # Fill configuration
            self.__prefix = path
            self.__cfg = cfg
            for prop in self.__libraries:
                setattr(self, '_Boost__config_%s_dynamic' % prop, None)
                setattr(self, '_Boost__config_%s_static' % prop, None)
                setattr(self, '_Boost__config_%s_dynamic_header' % prop, None)
                setattr(self, '_Boost__config_%s_static_header' % prop, None)
                setattr(self, '_Boost__%s_dynamic' % prop, None)
                setattr(self, '_Boost__%s_static' % prop, None)
            self.__version = version_eff
            return

        raise Exception('no matching boost for the requested version '
                        '(%s) in %s. Found versions: %s.' % \
                        (version, self._format_search([path for path, include_subdir in prefixes]),
                         ', '.join(map(str, miss))))
Exemple #18
0
  def __init__(self,
               cxx_toolkit = None,
               prefix = None,
               version = Version(),
               version_effective = None,
               prefer_shared = True):
    """Find and create a configuration for Boost.

    prefix -- Where to find Boost, should contain
              include/boost/version.hpp among others. /usr and
              /usr/local are searched by default. If relative, it
              is rooted in the source tree.
    version -- Requested version.
    prefer_shared -- Check dynamic libraries first.
    """
    # Fix arguments
    cxx_toolkit = cxx_toolkit or drake.cxx.Toolkit()
    self.__cxx_toolkit = cxx_toolkit
    self.__prefer_shared = prefer_shared
    # Compute the search path.
    if prefix is None:
      test = [path.dirname() for path in cxx_toolkit.include_path
              if path.basename() == 'include']
    else:
      test = [Path(prefix)]
    token = drake.Path('boost/version.hpp')
    include_subdirs = {drake.Path('include')}
    for prefix in test:
      for subdir in include_subdirs:
        if not (prefix / subdir).exists():
          continue
        include_subdirs = include_subdirs.union(
          (subdir / p for p in (prefix / subdir).list()
           if p.startswith('boost-')))
    tokens = map(lambda p: p / token, include_subdirs)
    prefixes = self._search_many_all(list(tokens), test)
    miss = []
    if version_effective is not None:
      assert prefix is not None
    # Try every search path
    for path, include_subdir in prefixes:
      path = drake.path_build(path)
      include_subdir = include_subdir.without_suffix(token)
      # Create basic configuration for version checking.
      cfg = Config()
      cfg.add_system_include_path(path.without_prefix(drake.path_build()) / include_subdir)
      self.__lib_path = path / 'lib'
      cfg.lib_path(path.without_prefix(drake.path_build()) / 'lib')
      # Check the version.
      if version_effective is None:
        version_eff = cxx_toolkit.preprocess(
            '#include <boost/version.hpp>\nBOOST_VERSION',
            config = cfg)
        version_eff = int(version_eff.split('\n')[-2].strip())
        version_eff = Version(version_eff // 100000,
                              version_eff // 100 % 1000,
                              version_eff % 100)
      else:
        version_eff = version_effective
      if version_eff not in version:
        miss.append(version_eff)
        continue
      # Fill configuration
      self.__prefix = path
      self.__cfg = cfg
      for prop in self.__libraries:
        setattr(self, '_Boost__config_%s_dynamic' % prop, None)
        setattr(self, '_Boost__config_%s_static' % prop, None)
        setattr(self, '_Boost__config_%s_dynamic_header' % prop, None)
        setattr(self, '_Boost__config_%s_static_header' % prop, None)
        setattr(self, '_Boost__%s_dynamic' % prop, None)
        setattr(self, '_Boost__%s_static' % prop, None)
      self.__version = version_eff
      return

    raise Exception('no matching boost for the requested version '
                    '(%s) in %s. Found versions: %s.' % \
                    (version, self._format_search([path for path, include_subdir in prefixes]),
                     ', '.join(map(str, miss))))
Exemple #19
0
 def execute(self):
     env = dict(self.__env)
     import os
     env.update(os.environ)
     with drake.CWDPrinter(drake.path_root() / drake.path_build() /
                           self.work_directory):
         # Patch
         if self.__patch is not None:
             patch_path = str(drake.path_root() / self.__patch.path())
             patch_cmd = ['patch', '-N', '-p', '1', '-i', patch_path],
             if not self.cmd('Patch %s' % self.work_directory,
                             patch_cmd,
                             cwd=self.work_directory):
                 return False
         # Configure step
         if self.__configure is not None:
             if not self.cmd('Configure %s' % self.work_directory,
                             self.command_configure,
                             cwd=self.work_directory,
                             env=env,
                             leave_stdout=False):
                 return False
         # Build step
         if not self.cmd('Build %s' % self.work_directory,
                         self.command_build,
                         cwd=self.work_directory,
                         env=env,
                         leave_stdout=False):
             return False
     for target in self.__targets:
         path = target.path().without_prefix(self.work_directory)
         if isinstance(target, drake.cxx.DynLib):
             rpath = '.'
         elif isinstance(target, drake.cxx.Executable):
             rpath = '../lib'
         else:
             continue
         with drake.WritePermissions(target):
             cmd = self.__toolkit.rpath_set_command(target.path(), rpath)
             if self.__toolkit.os is not drake.os.windows:
                 if not self.cmd('Fix rpath for %s' % target.path(), cmd):
                     return False
             # On OS X, we ensure that the library id and paths to dependency
             # libraries are correct.
             if self.__toolkit.os is drake.os.macos:
                 cmd = [
                     'install_name_tool', '-id',
                     '@rpath/%s' % target.name().basename(),
                     str(target.path())
                 ]
                 if not self.cmd('Fix rpath for %s' % target.path(), cmd):
                     return False
                 lib_dependecies = self.parse_otool_libraries(target.path())
                 for dep in lib_dependecies:
                     if dep.basename() in (t.path().basename()
                                           for t in self.__targets):
                         cmd = [
                             'install_name_tool',
                             '-change',
                             str(dep),
                             '@rpath/%s' % dep.basename(),
                             str(target.path()),
                         ]
                         if not self.cmd(
                                 'Fix dependency name for %s' %
                                 target.path(), cmd):
                             return False
     return True
Exemple #20
0
    def __init__(self,
                 cxx_toolkit=None,
                 prefix=None,
                 version=drake.Version(),
                 version_effective=None,
                 prefer_shared=True,
                 rcc=None,
                 qmake=None,
                 uic=None,
                 moc=None):
        """Find and create a configuration for Qt.

    prefix -- Where to find Qt, should contain
              include/Qt/qglobal.h among others. /usr and
              /usr/local are searched by default. If relative, it
              is rooted in the source tree.
    version -- Requested version.
    prefer_shared -- Check dynamic libraries first.
    """
        self.__rcc = rcc
        self.__qmake = qmake
        self.__uic = uic
        self.__moc = moc
        self.__moc_cache = {}
        self.__dependencies = {}
        self.__moc_files = set()
        cxx_toolkit = cxx_toolkit or drake.cxx.Toolkit()
        self.__cxx_toolkit = cxx_toolkit
        self.__prefer_shared = prefer_shared
        include_subdirs = set(
            drake.Path(p) for p in ['include', 'include/qt5'])
        if prefix is None:
            test = [
                path.dirname() for path in cxx_toolkit.include_path
                if path.basename() in include_subdirs
            ]
        else:
            test = [drake.Path(prefix)]
        for i in range(len(test)):
            if not test[i].absolute():
                test[i] = drake.path_source() / test[i]
        token = drake.Path('QtCore/qglobal.h')
        tokens = list(map(lambda p: p / token, include_subdirs))
        prefixes = self._search_many_all(tokens, test)
        miss = []
        # Try every search path
        for path, include_subdir in prefixes:
            include_subdir = include_subdir.without_suffix(token)
            # Create basic configuration for version checking.
            cfg = drake.cxx.Config()
            cfg.pic = True
            if not path.absolute():
                path = path.without_prefix(drake.path_build())
            cfg.add_system_include_path(path / include_subdir)
            if version_effective is None:
                try:
                    version_eff = cxx_toolkit.preprocess(
                        '#include <QtCore/qglobal.h>\nQT_VERSION',
                        config=cfg).split('\n')[-2].strip()
                    version_eff = eval(version_eff, {"__builtins__": None}, {})
                    version_eff = drake.Version(
                        version_eff >> 16,
                        (version_eff >> 8) % 256,
                        version_eff % 256,
                    )
                # If the token doesn't exists, ignore.
                except Exception as e:
                    continue
            else:
                version_eff = version_effective
            if version_eff not in version:
                miss.append(version_eff)
                continue
            # Fill configuration
            self.__prefix = path
            self.__cfg = cfg
            for prop in self.__libraries:
                setattr(self, '_Qt__config_%s_dynamic' % prop, None)
                setattr(self, '_Qt__config_%s_static' % prop, None)
                setattr(self, '_Qt__config_%s_dynamic_header' % prop, None)
                setattr(self, '_Qt__config_%s_static_header' % prop, None)
                setattr(self, '_Qt__%s_dynamic' % prop, None)
                setattr(self, '_Qt__%s_static' % prop, None)
            self.__version = version_eff
            Qt.__include_dir = path / include_subdir
            return

        raise Exception(
            'no matching Qt ({}) in {}. Found versions: {}.'.format(
                pretty_listing(version, any=True),
                pretty_listing([p for p, _ in prefixes], quantifier=True),
                pretty_listing(miss)))
Exemple #21
0
  def __init__(self,
               cxx_toolkit = None,
               prefix = None,
               version = drake.Version(),
               version_effective = None,
               prefer_shared = True,
               rcc = None,
               qmake = None,
               uic = None,
               moc = None):
    """Find and create a configuration for Qt.

    prefix -- Where to find Qt, should contain
              include/Qt/qglobal.h among others. /usr and
              /usr/local are searched by default. If relative, it
              is rooted in the source tree.
    version -- Requested version.
    prefer_shared -- Check dynamic libraries first.
    """
    self.__rcc = rcc
    self.__qmake = qmake
    self.__uic = uic
    self.__moc = moc
    self.__moc_cache = {}
    self.__dependencies = {}
    cxx_toolkit = cxx_toolkit or drake.cxx.Toolkit()
    self.__cxx_toolkit = cxx_toolkit
    self.__prefer_shared = prefer_shared
    include_subdirs = set(drake.Path(p)
                          for p in ['include', 'include/qt4'])
    if prefix is None:
      test = [path.dirname() for path in cxx_toolkit.include_path
              if path.basename() in include_subdirs]
    else:
      test = [Path(prefix)]
    for i in range(len(test)):
      if not test[i].absolute():
        test[i] = drake.path_source() / test[i]
    token = drake.Path('Qt/qglobal.h')
    tokens = list(map(lambda p: p / token, include_subdirs))
    prefixes = self._search_many_all(tokens, test)
    miss = []
    # Try every search path
    for path, include_subdir in prefixes:
      include_subdir = include_subdir.without_suffix(token)

      # Create basic configuration for version checking.
      cfg = Config()
      if not path.absolute():
        path = path.without_prefix(drake.path_build())
      cfg.add_system_include_path(path / include_subdir)
      if version_effective is None:
        try:
          version_eff = int(cxx_toolkit.preprocess(
            '#include <Qt/qglobal.h>\nQT_VERSION',
            config = cfg).split('\n')[-2].strip(), 16)
          version_eff = drake.Version(
            version_eff >> 16,
            (version_eff >> 8) % 256,
            version_eff % 256,
          )
        # If the token doesn't exists, ignore.
        except drake.Exception:
          continue
      else:
        version_eff = version_effective
      if version_eff not in version:
        miss.append(version_eff)
        continue
      # Fill configuration
      self.__prefix = path
      self.__cfg = cfg
      for prop in self.__libraries:
        setattr(self, '_Qt__config_%s_dynamic' % prop, None)
        setattr(self, '_Qt__config_%s_static' % prop, None)
        setattr(self, '_Qt__config_%s_dynamic_header' % prop, None)
        setattr(self, '_Qt__config_%s_static_header' % prop, None)
        setattr(self, '_Qt__%s_dynamic' % prop, None)
        setattr(self, '_Qt__%s_static' % prop, None)
      self.__version = version_eff
      self.plug(cxx_toolkit)
      Qt.__include_dir = path / include_subdir
      return

    raise Exception('no matching Qt for the requested version '
                    '(%s) in %s. Found versions: %s.' % \
                    (version, self._format_search([path for path, include_subdir in prefixes]),
                     ', '.join(map(str, miss))))
Exemple #22
0
 def output_dir(self):
   return drake.path_build(self.__output)