From 4f5194c89b20082940e66adcbb8bfb6ecf3d636e Mon Sep 17 00:00:00 2001 From: Danny McClanahan <1305167+cosmicexplorer@users.noreply.github.com> Date: Tue, 24 Jul 2018 13:25:07 -0700 Subject: [PATCH] remove CToolchain/CppToolchain rules and add explanatory comment in environment.py --- .../pants/backend/native/config/environment.py | 5 ++++- .../backend/native/subsystems/native_toolchain.py | 14 -------------- src/python/pants/backend/native/tasks/c_compile.py | 4 ++-- .../pants/backend/native/tasks/cpp_compile.py | 4 ++-- 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/python/pants/backend/native/config/environment.py b/src/python/pants/backend/native/config/environment.py index 70e9f3ba7a0b..a72c684cd68e 100644 --- a/src/python/pants/backend/native/config/environment.py +++ b/src/python/pants/backend/native/config/environment.py @@ -165,7 +165,10 @@ def as_invocation_environment_dict(self): return ret -# TODO(#4020): These classes are performing the work of variants. +# NB: These wrapper classes for LLVM and GCC toolchains are performing the work of variants. A +# CToolchain cannot be requested directly, but native_toolchain.py provides an LLVMCToolchain, +# which contains a CToolchain representing the clang compiler and a linker paired to work with +# objects compiled by that compiler. class CToolchain(datatype([('c_compiler', CCompiler), ('c_linker', Linker)])): pass diff --git a/src/python/pants/backend/native/subsystems/native_toolchain.py b/src/python/pants/backend/native/subsystems/native_toolchain.py index 582ca564a001..c1e6279a5c72 100644 --- a/src/python/pants/backend/native/subsystems/native_toolchain.py +++ b/src/python/pants/backend/native/subsystems/native_toolchain.py @@ -291,18 +291,6 @@ def select_gcc_cpp_toolchain(platform, native_toolchain): yield GCCCppToolchain(CppToolchain(working_cpp_compiler, working_linker)) -@rule(CToolchain, [Select(NativeToolchain)]) -def select_default_c_toolchain(native_toolchain): - llvm_c_toolchain = yield Get(LLVMCToolchain, NativeToolchain, native_toolchain) - yield llvm_c_toolchain.c_toolchain - - -@rule(CppToolchain, [Select(NativeToolchain)]) -def select_default_cpp_toolchain(native_toolchain): - llvm_cpp_toolchain = yield Get(LLVMCppToolchain, NativeToolchain, native_toolchain) - yield llvm_cpp_toolchain.cpp_toolchain - - def create_native_toolchain_rules(): return [ select_libc_dev, @@ -313,7 +301,5 @@ def create_native_toolchain_rules(): select_llvm_cpp_toolchain, select_gcc_c_toolchain, select_gcc_cpp_toolchain, - select_default_c_toolchain, - select_default_cpp_toolchain, RootRule(NativeToolchain), ] diff --git a/src/python/pants/backend/native/tasks/c_compile.py b/src/python/pants/backend/native/tasks/c_compile.py index 6f9471f971c1..d962687a9574 100644 --- a/src/python/pants/backend/native/tasks/c_compile.py +++ b/src/python/pants/backend/native/tasks/c_compile.py @@ -4,7 +4,7 @@ from __future__ import absolute_import, division, print_function, unicode_literals -from pants.backend.native.config.environment import CToolchain +from pants.backend.native.config.environment import LLVMCToolchain from pants.backend.native.subsystems.native_compile_settings import CCompileSettings from pants.backend.native.subsystems.native_toolchain import NativeToolchain from pants.backend.native.targets.native_library import CLibrary @@ -40,7 +40,7 @@ def get_compile_settings(self): @memoized_property def _c_toolchain(self): - return self._request_single(CToolchain, self._native_toolchain) + return self._request_single(LLVMCToolchain, self._native_toolchain).c_toolchain def get_compiler(self): return self._c_toolchain.c_compiler diff --git a/src/python/pants/backend/native/tasks/cpp_compile.py b/src/python/pants/backend/native/tasks/cpp_compile.py index 33aef5bfc249..322c62432c26 100644 --- a/src/python/pants/backend/native/tasks/cpp_compile.py +++ b/src/python/pants/backend/native/tasks/cpp_compile.py @@ -4,7 +4,7 @@ from __future__ import absolute_import, division, print_function, unicode_literals -from pants.backend.native.config.environment import CppToolchain +from pants.backend.native.config.environment import LLVMCppToolchain from pants.backend.native.subsystems.native_compile_settings import CppCompileSettings from pants.backend.native.subsystems.native_toolchain import NativeToolchain from pants.backend.native.targets.native_library import CppLibrary @@ -40,7 +40,7 @@ def get_compile_settings(self): @memoized_property def _cpp_toolchain(self): - return self._request_single(CppToolchain, self._native_toolchain) + return self._request_single(LLVMCppToolchain, self._native_toolchain).cpp_toolchain def get_compiler(self): return self._cpp_toolchain.cpp_compiler