Esempio n. 1
0
    def configure_step(self):
        """
        Configure build by creating tools/build/user.settings from configure options.
        """
        # construct build options
        defines = ['NDEBUG']
        self.cfg.update('buildopts', "mode=release")

        self.detect_cxx()
        cxx_ver = None
        if self.toolchain.comp_family() in [toolchain.GCC]:  #@UndefinedVariable
            cxx_ver = '.'.join(get_software_version('GCC').split('.')[:2])
        elif self.toolchain.comp_family() in [toolchain.INTELCOMP]:  #@UndefinedVariable
            cxx_ver = '.'.join(get_icc_version().split('.')[:2])
        else:
            raise EasyBuildError("Don't know how to determine C++ compiler version.")
        self.cfg.update('buildopts', "cxx=%s cxx_ver=%s" % (self.cxx, cxx_ver))

        if self.toolchain.options.get('usempi', None):
            self.cfg.update('buildopts', 'extras=mpi')
            defines.extend(['USEMPI', 'MPICH_IGNORE_CXX_SEEK'])

        # make sure important environment variables are passed down
        # e.g., compiler env vars for MPI wrappers
        env_vars = {}
        for (key, val) in os.environ.items():
            if key in ['I_MPI_CC', 'I_MPI_CXX', 'MPICH_CC', 'MPICH_CXX', 'OMPI_CC', 'OMPI_CXX']:
                env_vars.update({key: val})
        self.log.debug("List of extra environment variables to pass down: %s" % str(env_vars))

        # create user.settings file
        paths = os.getenv('PATH').split(':')
        ld_library_paths = os.getenv('LD_LIBRARY_PATH').split(':')
        cpaths = os.getenv('CPATH').split(':')
        flags = [str(f).strip('-') for f in self.toolchain.variables['CXXFLAGS'].copy()]

        txt = '\n'.join([
            "settings = {",
            "   'user': {",
            "       'prepends': {",
            "           'library_path': %s," % str(ld_library_paths),
            "           'include_path': %s," % str(cpaths),
            "       },",
            "       'appends': {",
            "           'program_path': %s," % str(paths),
            "           'flags': {",
            "               'compile': %s," % str(flags),
            #"              'mode': %s," % str(o_flags),
            "           },",
            "           'defines': %s," % str(defines),
            "       },",
            "       'overrides': {",
            "           'cc': '%s'," % os.getenv('CC'),
            "           'cxx': '%s'," % os.getenv('CXX'),
            "           'ENV': {",
            "               'INTEL_LICENSE_FILE': '%s'," % os.getenv('INTEL_LICENSE_FILE'),  # Intel license file
            "               'PATH': %s," % str(paths),
            "               'LD_LIBRARY_PATH': %s," % str(ld_library_paths),
        ])
        txt += '\n'
        for (key, val) in env_vars.items():
            txt += "               '%s': '%s',\n" % (key, val)
        txt += '\n'.join([
            "           },",
            "       },",
            "       'removes': {",
            "       },",
            "   },",
            "}",
        ])
        us_fp = os.path.join(self.srcdir, "tools/build/user.settings")
        try:
            self.log.debug("Creating '%s' with: %s" % (us_fp, txt))
            f = file(us_fp, 'w')
            f.write(txt)
            f.close()
        except IOError, err:
            raise EasyBuildError("Failed to write settings file %s: %s", us_fp, err)
Esempio n. 2
0
    def configure_step(self):
        """
        Configure build by creating tools/build/user.settings from configure options.
        """
        # construct build options
        defines = ['NDEBUG']
        self.cfg.update('buildopts', "mode=release")

        self.detect_cxx()
        cxx_ver = None
        if self.toolchain.comp_family() in [toolchain.GCC]:  #@UndefinedVariable
            cxx_ver = '.'.join(get_software_version('GCC').split('.')[:2])
        elif self.toolchain.comp_family() in [toolchain.INTELCOMP]:  #@UndefinedVariable
            cxx_ver = '.'.join(get_icc_version().split('.')[:2])
        else:
            raise EasyBuildError("Don't know how to determine C++ compiler version.")
        self.cfg.update('buildopts', "cxx=%s cxx_ver=%s" % (self.cxx, cxx_ver))

        if self.toolchain.options.get('usempi', None):
            self.cfg.update('buildopts', 'extras=mpi')
            defines.extend(['USEMPI', 'MPICH_IGNORE_CXX_SEEK'])

        # make sure important environment variables are passed down
        # e.g., compiler env vars for MPI wrappers
        env_vars = {}
        for (key, val) in os.environ.items():
            if key in ['I_MPI_CC', 'I_MPI_CXX', 'MPICH_CC', 'MPICH_CXX', 'OMPI_CC', 'OMPI_CXX']:
                env_vars.update({key: val})
        self.log.debug("List of extra environment variables to pass down: %s" % str(env_vars))

        # create user.settings file
        paths = os.getenv('PATH').split(':')
        ld_library_paths = os.getenv('LD_LIBRARY_PATH').split(':')
        cpaths = os.getenv('CPATH').split(':')
        flags = [str(f).strip('-') for f in self.toolchain.variables['CXXFLAGS'].copy()]

        txt = '\n'.join([
            "settings = {",
            "   'user': {",
            "       'prepends': {",
            "           'library_path': %s," % str(ld_library_paths),
            "           'include_path': %s," % str(cpaths),
            "       },",
            "       'appends': {",
            "           'program_path': %s," % str(paths),
            "           'flags': {",
            "               'compile': %s," % str(flags),
            #"              'mode': %s," % str(o_flags),
            "           },",
            "           'defines': %s," % str(defines),
            "       },",
            "       'overrides': {",
            "           'cc': '%s'," % os.getenv('CC'),
            "           'cxx': '%s'," % os.getenv('CXX'),
            "           'ENV': {",
            "               'INTEL_LICENSE_FILE': '%s'," % os.getenv('INTEL_LICENSE_FILE'),  # Intel license file
            "               'PATH': %s," % str(paths),
            "               'LD_LIBRARY_PATH': %s," % str(ld_library_paths),
        ])
        txt += '\n'
        for (key, val) in env_vars.items():
            txt += "               '%s': '%s',\n" % (key, val)
        txt += '\n'.join([
            "           },",
            "       },",
            "       'removes': {",
            "       },",
            "   },",
            "}",
        ])
        us_fp = os.path.join(self.srcdir, "tools/build/user.settings")
        try:
            self.log.debug("Creating '%s' with: %s" % (us_fp, txt))
            f = file(us_fp, 'w')
            f.write(txt)
            f.close()
        except IOError, err:
            raise EasyBuildError("Failed to write settings file %s: %s", us_fp, err)
    def configure_step(self):
        """
        Configure build by creating tools/build/user.settings from configure options.
        """
        # construct build options
        defines = ['NDEBUG']
        self.cfg.update('buildopts', "mode=release")

        self.detect_cxx()
        cxx_ver = None
        if self.toolchain.comp_family() in [toolchain.GCC
                                            ]:  # @UndefinedVariable
            cxx_ver = '.'.join(get_software_version('GCC').split('.')[:2])
        elif self.toolchain.comp_family() in [toolchain.INTELCOMP
                                              ]:  # @UndefinedVariable
            cxx_ver = '.'.join(get_icc_version().split('.')[:2])
        else:
            raise EasyBuildError(
                "Don't know how to determine C++ compiler version.")
        self.cfg.update('buildopts', "cxx=%s cxx_ver=%s" % (self.cxx, cxx_ver))

        if self.toolchain.options.get('usempi', None):
            self.cfg.update('buildopts', 'extras=mpi')
            defines.extend(['USEMPI', 'MPICH_IGNORE_CXX_SEEK'])

        # make sure important environment variables are passed down
        # e.g., compiler env vars for MPI wrappers
        env_vars = {}
        for (key, val) in os.environ.items():
            if key in [
                    'I_MPI_CC', 'I_MPI_CXX', 'MPICH_CC', 'MPICH_CXX',
                    'OMPI_CC', 'OMPI_CXX'
            ]:
                env_vars.update({key: val})
        self.log.debug("List of extra environment variables to pass down: %s" %
                       str(env_vars))

        # create user.settings file
        paths = os.getenv('PATH')
        paths = paths.split(':') if paths else []
        ld_library_paths = os.getenv('LD_LIBRARY_PATH')
        ld_library_paths = ld_library_paths.split(
            ':') if ld_library_paths else []
        cpaths = os.getenv('CPATH')
        cpaths = cpaths.split(':') if cpaths else []
        flags = [
            str(f).strip('-')
            for f in self.toolchain.variables['CXXFLAGS'].copy()
        ]

        txt = '\n'.join([
            "settings = {",
            "   'user': {",
            "       'prepends': {",
            "           'library_path': %s," % str(ld_library_paths),
            "           'include_path': %s," % str(cpaths),
            "       },",
            "       'appends': {",
            "           'program_path': %s," % str(paths),
            "           'flags': {",
            "               'compile': %s," % str(flags),
            # "              'mode': %s," % str(o_flags),
            "           },",
            "           'defines': %s," % str(defines),
            "       },",
            "       'overrides': {",
            "           'cc': '%s'," % os.getenv('CC'),
            "           'cxx': '%s'," % os.getenv('CXX'),
            "           'ENV': {",
            "               'INTEL_LICENSE_FILE': '%s'," %
            os.getenv('INTEL_LICENSE_FILE'),  # Intel license file
            "               'PATH': %s," % str(paths),
            "               'LD_LIBRARY_PATH': %s," % str(ld_library_paths),
        ])
        txt += '\n'
        for (key, val) in env_vars.items():
            txt += "               '%s': '%s',\n" % (key, val)
        txt += '\n'.join([
            "           },",
            "       },",
            "       'removes': {",
            "       },",
            "   },",
            "}",
        ])
        us_fp = os.path.join(self.srcdir, "tools/build/user.settings")
        self.log.debug("Creating '%s' with: %s", us_fp, txt)
        write_file(us_fp, txt)

        # make sure specified compiler version is accepted by patching it in
        os_fp = os.path.join(self.srcdir, "tools/build/options.settings")
        cxxver_re = re.compile(r'(.*"%s".*)(,\s*"\*"\s*],.*)' % self.cxx, re.M)
        for line in fileinput.input(os_fp, inplace=1, backup='.orig.eb'):
            line = cxxver_re.sub(r'\1, "%s"\2' % cxx_ver, line)
            sys.stdout.write(line)