Skip to content

Commit

Permalink
rename library_dirs -> runtime_library_dirs (made easier with the alg…
Browse files Browse the repository at this point in the history
…ebra)
  • Loading branch information
cosmicexplorer committed Dec 17, 2018
1 parent 7b17851 commit 7ad32f9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 28 deletions.
24 changes: 10 additions & 14 deletions src/python/pants/backend/native/config/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

import os
from abc import abstractmethod, abstractproperty
from builtins import object

from pants.engine.rules import SingletonRule
from pants.util.meta import AbstractClass, classproperty
from pants.util.memo import memoized_classproperty
from pants.util.meta import AbstractClass
from pants.util.objects import datatype
from pants.util.osutil import all_normalized_os_names, get_normalized_os_name
from pants.util.strutil import create_path_env_var
Expand Down Expand Up @@ -55,20 +54,18 @@ def _list_field(func):


def _algebraic_data(metaclass):
"""A class decorator to pull out `_list_fields` from a mixin class for use with a `datatype`.
"""
"""A class decorator to pull out `_list_fields` from a mixin class for use with a `datatype`."""
def wrapper(cls):
cls.__bases__ += (metaclass,)
cls._list_fields = metaclass._list_fields
return cls
return wrapper


# NB: prototypal inheritance seems *deeply* linked with the idea here!
class _ExtensibleAlgebraic(AbstractClass):
"""A mixin to make it more concise to coalesce datatypes with related collection fields."""

# NB: prototypal inheritance seems *deeply* linked with the idea here!

@memoized_classproperty
def _list_fields(cls):
all_list_fields = []
Expand Down Expand Up @@ -147,16 +144,15 @@ def exe_filename(self):
"""
raise NotImplementedError('exe_filename is a scalar field of _Executable!')

# TODO: rename this to 'runtime_library_dirs'!
@_list_field
def library_dirs(self):
def runtime_library_dirs(self):
"""Directories containing shared libraries that must be on the runtime library search path.
Note: this is for libraries needed for the current _Executable to run -- see _LinkerMixin below
for libraries that are needed at link time.
:rtype: list of str
"""
raise NotImplementedError('library_dirs is a list field of _Executable!')
raise NotImplementedError('runtime_library_dirs is a list field of _Executable!')

@_list_field
def extra_args(self):
Expand All @@ -182,15 +178,15 @@ def as_invocation_environment_dict(self):
})
return {
'PATH': create_path_env_var(self.path_entries),
lib_env_var: create_path_env_var(self.library_dirs),
lib_env_var: create_path_env_var(self.runtime_library_dirs),
}


@_algebraic_data(_Executable)
class Assembler(datatype([
'path_entries',
'exe_filename',
'library_dirs',
'runtime_library_dirs',
'extra_args',
])): pass

Expand Down Expand Up @@ -235,7 +231,7 @@ def as_invocation_environment_dict(self):
class Linker(datatype([
'path_entries',
'exe_filename',
'library_dirs',
'runtime_library_dirs',
'linking_library_dirs',
'extra_args',
'extra_object_files',
Expand Down Expand Up @@ -266,7 +262,7 @@ def as_invocation_environment_dict(self):
class CCompiler(datatype([
'path_entries',
'exe_filename',
'library_dirs',
'runtime_library_dirs',
'include_dirs',
'extra_args',
])):
Expand All @@ -284,7 +280,7 @@ def as_invocation_environment_dict(self):
class CppCompiler(datatype([
'path_entries',
'exe_filename',
'library_dirs',
'runtime_library_dirs',
'include_dirs',
'extra_args',
])):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ def assembler(self):
return Assembler(
path_entries=self.path_entries(),
exe_filename='as',
library_dirs=[],
runtime_library_dirs=[],
extra_args=[])

def linker(self):
return Linker(
path_entries=self.path_entries(),
exe_filename='ld',
library_dirs=[],
runtime_library_dirs=[],
linking_library_dirs=[],
extra_args=[],
extra_object_files=[],
Expand Down
4 changes: 2 additions & 2 deletions src/python/pants/backend/native/subsystems/binaries/gcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def c_compiler(self, platform):
return CCompiler(
path_entries=self.path_entries,
exe_filename='gcc',
library_dirs=self._common_lib_dirs(platform),
runtime_library_dirs=self._common_lib_dirs(platform),
include_dirs=self._common_include_dirs,
extra_args=[])

Expand All @@ -91,7 +91,7 @@ def cpp_compiler(self, platform):
return CppCompiler(
path_entries=self.path_entries,
exe_filename='g++',
library_dirs=self._common_lib_dirs(platform),
runtime_library_dirs=self._common_lib_dirs(platform),
include_dirs=(self._common_include_dirs + self._cpp_include_dirs),
extra_args=[])

Expand Down
6 changes: 3 additions & 3 deletions src/python/pants/backend/native/subsystems/binaries/llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def linker(self, platform):
path_entries=self.path_entries,
exe_filename=platform.resolve_platform_specific(
self._PLATFORM_SPECIFIC_LINKER_NAME),
library_dirs=[],
runtime_library_dirs=[],
linking_library_dirs=[],
extra_args=[],
extra_object_files=[],
Expand All @@ -108,7 +108,7 @@ def c_compiler(self):
return CCompiler(
path_entries=self.path_entries,
exe_filename='clang',
library_dirs=self._common_lib_dirs,
runtime_library_dirs=self._common_lib_dirs,
include_dirs=self._common_include_dirs,
extra_args=[])

Expand All @@ -120,7 +120,7 @@ def cpp_compiler(self):
return CppCompiler(
path_entries=self.path_entries,
exe_filename='clang++',
library_dirs=self._common_lib_dirs,
runtime_library_dirs=self._common_lib_dirs,
include_dirs=(self._cpp_include_dirs + self._common_include_dirs),
extra_args=[])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def select_llvm_c_toolchain(platform, native_toolchain):
.sequence(provided_gcc)
.append_field('extra_args', gcc_install.as_clang_argv)
# We need g++'s version of the GLIBCXX library to be able to run.
.prepend_field('library_dirs', provided_gcc.library_dirs))
.prepend_field('runtime_library_dirs', provided_gcc.runtime_library_dirs))

working_c_compiler = joined_c_compiler.prepend_field('extra_args', [
'-x', 'c', '-std=c11',
Expand Down Expand Up @@ -212,8 +212,8 @@ def select_llvm_cpp_toolchain(platform, native_toolchain):
.copy(include_dirs=provided_gpp.include_dirs)
.append_field('extra_args', gcc_install.as_clang_argv)
# We need g++'s version of the GLIBCXX library to be able to run.
.prepend_field('library_dirs', provided_gpp.library_dirs))
extra_llvm_linking_library_dirs = provided_gpp.library_dirs + provided_clangpp.library_dirs
.prepend_field('runtime_library_dirs', provided_gpp.runtime_library_dirs))
extra_llvm_linking_library_dirs = provided_gpp.runtime_library_dirs + provided_clangpp.runtime_library_dirs
# Ensure we use libstdc++, provided by g++, during the linking stage.
linker_extra_args=['-stdlib=libstdc++']

Expand Down
8 changes: 4 additions & 4 deletions src/python/pants/backend/native/subsystems/xcode_cli_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ def assembler(self):
return Assembler(
path_entries=self.path_entries(),
exe_filename='as',
library_dirs=[],
runtime_library_dirs=[],
extra_args=[])

@memoized_method
def linker(self):
return Linker(
path_entries=self.path_entries(),
exe_filename='ld',
library_dirs=[],
runtime_library_dirs=[],
linking_library_dirs=[],
extra_args=[MIN_OSX_VERSION_ARG],
extra_object_files=[],
Expand All @@ -153,7 +153,7 @@ def c_compiler(self):
return CCompiler(
path_entries=self.path_entries(),
exe_filename='clang',
library_dirs=self.lib_dirs(),
runtime_library_dirs=self.lib_dirs(),
include_dirs=self.include_dirs(),
extra_args=[MIN_OSX_VERSION_ARG])

Expand All @@ -162,7 +162,7 @@ def cpp_compiler(self):
return CppCompiler(
path_entries=self.path_entries(),
exe_filename='clang++',
library_dirs=self.lib_dirs(),
runtime_library_dirs=self.lib_dirs(),
include_dirs=self.include_dirs(include_cpp_inc=True),
extra_args=[MIN_OSX_VERSION_ARG])

Expand Down

0 comments on commit 7ad32f9

Please sign in to comment.