diff --git a/src/python/pants/backend/native/config/environment.py b/src/python/pants/backend/native/config/environment.py index b376664499aa..af9bdc8a6a0f 100644 --- a/src/python/pants/backend/native/config/environment.py +++ b/src/python/pants/backend/native/config/environment.py @@ -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 @@ -55,8 +54,7 @@ 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 @@ -64,11 +62,10 @@ def wrapper(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 = [] @@ -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): @@ -182,7 +178,7 @@ 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), } @@ -190,7 +186,7 @@ def as_invocation_environment_dict(self): class Assembler(datatype([ 'path_entries', 'exe_filename', - 'library_dirs', + 'runtime_library_dirs', 'extra_args', ])): pass @@ -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', @@ -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', ])): @@ -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', ])): diff --git a/src/python/pants/backend/native/subsystems/binaries/binutils.py b/src/python/pants/backend/native/subsystems/binaries/binutils.py index 600f7db06ff8..d8b3375b0c4f 100644 --- a/src/python/pants/backend/native/subsystems/binaries/binutils.py +++ b/src/python/pants/backend/native/subsystems/binaries/binutils.py @@ -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=[], diff --git a/src/python/pants/backend/native/subsystems/binaries/gcc.py b/src/python/pants/backend/native/subsystems/binaries/gcc.py index 5f48e12fb853..dc038cf3d865 100644 --- a/src/python/pants/backend/native/subsystems/binaries/gcc.py +++ b/src/python/pants/backend/native/subsystems/binaries/gcc.py @@ -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=[]) @@ -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=[]) diff --git a/src/python/pants/backend/native/subsystems/binaries/llvm.py b/src/python/pants/backend/native/subsystems/binaries/llvm.py index a49146cbbd1d..c040dc92b4ce 100644 --- a/src/python/pants/backend/native/subsystems/binaries/llvm.py +++ b/src/python/pants/backend/native/subsystems/binaries/llvm.py @@ -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=[], @@ -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=[]) @@ -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=[]) diff --git a/src/python/pants/backend/native/subsystems/native_toolchain.py b/src/python/pants/backend/native/subsystems/native_toolchain.py index dc79c8fe09e3..1b19aa3d8170 100644 --- a/src/python/pants/backend/native/subsystems/native_toolchain.py +++ b/src/python/pants/backend/native/subsystems/native_toolchain.py @@ -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', @@ -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++'] diff --git a/src/python/pants/backend/native/subsystems/xcode_cli_tools.py b/src/python/pants/backend/native/subsystems/xcode_cli_tools.py index 2fec0139dbec..3c2e472785ca 100644 --- a/src/python/pants/backend/native/subsystems/xcode_cli_tools.py +++ b/src/python/pants/backend/native/subsystems/xcode_cli_tools.py @@ -134,7 +134,7 @@ def assembler(self): return Assembler( path_entries=self.path_entries(), exe_filename='as', - library_dirs=[], + runtime_library_dirs=[], extra_args=[]) @memoized_method @@ -142,7 +142,7 @@ 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=[], @@ -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]) @@ -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])