Exemplo n.º 1
0
def header_list():
    """Returns an instance of header list"""
    h = [
        '/dir1/Python.h',
        '/dir2/datetime.h',
        '/dir1/pyconfig.h',
        '/dir3/core.h',
        'pymem.h'
    ]
    h = HeaderList(h)
    h.add_macro('-DBOOST_LIB_NAME=boost_regex')
    h.add_macro('-DBOOST_DYN_LINK')
    return h
Exemplo n.º 2
0
def header_list():
    """Returns an instance of header list"""
    # Test all valid extensions: ['.h', '.hpp', '.hh', '.cuh']
    headers = [
        '/dir1/Python.h',
        '/dir2/date.time.h',
        '/dir1/pyconfig.hpp',
        '/dir3/core.hh',
        'pymem.cuh',
    ]
    h = HeaderList(headers)
    h.add_macro('-DBOOST_LIB_NAME=boost_regex')
    h.add_macro('-DBOOST_DYN_LINK')
    return h
Exemplo n.º 3
0
def header_list():
    """Returns an instance of header list"""
    h = [
        '/dir1/Python.h', '/dir2/datetime.h', '/dir1/pyconfig.h',
        '/dir3/core.h', 'pymem.h'
    ]
    h = HeaderList(h)
    h.add_macro('-DBOOST_LIB_NAME=boost_regex')
    h.add_macro('-DBOOST_DYN_LINK')
    return h
Exemplo n.º 4
0
    def test_add(self, header_list):
        pylist = [
            '/dir1/Python.h',  # removed from the final list
            '/dir2/pyconfig.hpp',
            '/dir4/date.time.h'
        ]
        another = HeaderList(pylist)
        h = header_list + another
        assert len(h) == 7

        # Invariant : l == l + l
        assert h == h + h

        # Always produce an instance of HeaderList
        assert type(header_list + pylist) == type(header_list)
        assert type(pylist + header_list) == type(header_list)
Exemplo n.º 5
0
def header_list():
    """Returns an instance of header list"""
    # Test all valid extensions: ['.h', '.hpp', '.hh', '.cuh']
    headers = [
        '/dir1/Python.h',
        '/dir2/date.time.h',
        '/dir1/pyconfig.hpp',
        '/dir3/core.hh',
        'pymem.cuh',
    ]
    h = HeaderList(headers)
    h.add_macro('-DBOOST_LIB_NAME=boost_regex')
    h.add_macro('-DBOOST_DYN_LINK')
    return h
Exemplo n.º 6
0
def test_set_build_environment_variables(
        config, mock_packages, working_env, monkeypatch,
        installation_dir_with_headers
):
    """Check that build_environment supplies the needed library/include
    directories via the SPACK_LINK_DIRS and SPACK_INCLUDE_DIRS environment
    variables.
    """

    # https://github.com/spack/spack/issues/13969
    cuda_headers = HeaderList([
        'prefix/include/cuda_runtime.h',
        'prefix/include/cuda/atomic',
        'prefix/include/cuda/std/detail/libcxx/include/ctype.h'])
    cuda_include_dirs = cuda_headers.directories
    assert(os.path.join('prefix', 'include')
           in cuda_include_dirs)
    assert(os.path.join('prefix', 'include', 'cuda', 'std', 'detail',
                        'libcxx', 'include')
           not in cuda_include_dirs)

    root = spack.spec.Spec('dt-diamond')
    root.concretize()

    for s in root.traverse():
        s.prefix = '/{0}-prefix/'.format(s.name)

    dep_pkg = root['dt-diamond-left'].package
    dep_lib_paths = ['/test/path/to/ex1.so', '/test/path/to/subdir/ex2.so']
    dep_lib_dirs = ['/test/path/to', '/test/path/to/subdir']
    dep_libs = LibraryList(dep_lib_paths)

    dep2_pkg = root['dt-diamond-right'].package
    dep2_pkg.spec.prefix = str(installation_dir_with_headers)

    setattr(dep_pkg, 'libs', dep_libs)
    try:
        pkg = root.package
        env_mods = EnvironmentModifications()
        spack.build_environment.set_build_environment_variables(
            pkg, env_mods, dirty=False)

        env_mods.apply_modifications()

        def normpaths(paths):
            return list(os.path.normpath(p) for p in paths)

        link_dir_var = os.environ['SPACK_LINK_DIRS']
        assert (
            normpaths(link_dir_var.split(':')) == normpaths(dep_lib_dirs))

        root_libdirs = ['/dt-diamond-prefix/lib', '/dt-diamond-prefix/lib64']
        rpath_dir_var = os.environ['SPACK_RPATH_DIRS']
        # The 'lib' and 'lib64' subdirectories of the root package prefix
        # should always be rpathed and should be the first rpaths
        assert (
            normpaths(rpath_dir_var.split(':')) ==
            normpaths(root_libdirs + dep_lib_dirs))

        header_dir_var = os.environ['SPACK_INCLUDE_DIRS']

        # The default implementation looks for header files only
        # in <prefix>/include and subdirectories
        prefix = str(installation_dir_with_headers)
        include_dirs = normpaths(header_dir_var.split(':'))

        assert os.path.join(prefix, 'include') in include_dirs
        assert os.path.join(prefix, 'include', 'boost') not in include_dirs
        assert os.path.join(prefix, 'path', 'to') not in include_dirs
        assert os.path.join(prefix, 'path', 'to', 'subdir') not in include_dirs

    finally:
        delattr(dep_pkg, 'libs')