Skip to content

Commit

Permalink
remove CToolchain/CppToolchain rules and add explanatory comment in e…
Browse files Browse the repository at this point in the history
…nvironment.py
  • Loading branch information
cosmicexplorer committed Jul 24, 2018
1 parent 7ebfe51 commit 4f5194c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 19 deletions.
5 changes: 4 additions & 1 deletion src/python/pants/backend/native/config/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
14 changes: 0 additions & 14 deletions src/python/pants/backend/native/subsystems/native_toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
]
4 changes: 2 additions & 2 deletions src/python/pants/backend/native/tasks/c_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions src/python/pants/backend/native/tasks/cpp_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 4f5194c

Please sign in to comment.