Skip to content

Commit

Permalink
correct gcc to non-platform specific, but remove from osx for now
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Mar 16, 2018
1 parent dfe7340 commit aaae18c
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 25 deletions.
2 changes: 2 additions & 0 deletions src/python/pants/backend/native/subsystems/clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)

import os

from pants.binaries.binary_tool import NativeTool
from pants.binaries.execution_environment_mixin import ExecutionPathEnvironment

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from contextlib import contextmanager

from pants.backend.native.subsystems.clang import Clang
from pants.backend.native.subsystems.gcc import GCC
from pants.backend.native.subsystems.platform_specific.linux.binutils import Binutils
from pants.backend.native.subsystems.platform_specific.linux.gcc import GCC
from pants.binaries.execution_environment_mixin import ExecutionEnvironmentMixin
from pants.subsystem.subsystem import Subsystem
from pants.util.memo import memoized_property
Expand All @@ -18,8 +18,13 @@

class NativeToolchain(Subsystem, ExecutionEnvironmentMixin):

options_scope = 'native-toolchain'

PLATFORM_SPECIFIC_TOOLCHAINS = {
'darwin': [Clang],
# FIXME: OSX should use gcc and clang too, but it needs to have the
# appropriate headers as well. This will probably require merging the
# toolchains in the bootstrap tools cache directory.
'darwin': [],
'linux': [GCC, Binutils, Clang],
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)

import os

from pants.binaries.binary_tool import NativeTool
from pants.binaries.execution_environment_mixin import ExecutionPathEnvironment

Expand Down
2 changes: 2 additions & 0 deletions src/python/pants/backend/python/subsystems/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
python_library(
dependencies = [
'3rdparty/python:setuptools',
'src/python/pants/binaries:execution_environment_mixin',
'src/python/pants/backend/native',
'src/python/pants/option',
'src/python/pants/subsystem',
'src/python/pants/util:memo',
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# coding=utf-8
# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)

from pants.backend.native.subsystems.native_toolchain import NativeToolchain
from pants.binaries.execution_environment_mixin import ExecutionEnvironmentMixin
from pants.subsystem.subsystem import Subsystem
from pants.util.memo import memoized_property


class PythonDistBuildEnvironment(Subsystem, ExecutionEnvironmentMixin):

options_scope = 'python-native-toolchain'

@classmethod
def subsystem_dependencies(cls):
return super(PythonDistBuildEnvironment, cls).subsystem_dependencies() + (NativeToolchain.scoped(cls),)

@memoized_property
def _native_toolchain(self):
return NativeToolchain.scoped_instance(self)

def modify_environment(self, env):
env = self._native_toolchain.modify_environment(env)
env['CC'] = 'clang'
env['CXX'] = 'clang++'
env['ARCHFLAGS'] = '-arch x86_64'
return env

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pex.interpreter import PythonInterpreter

from pants.backend.python.python_requirement import PythonRequirement
from pants.backend.python.subsystems import PythonNativeExtensionToolchain
from pants.backend.python.subsystems.python_dist_build_environment import PythonDistBuildEnvironment
from pants.backend.python.targets.python_requirement_library import PythonRequirementLibrary
from pants.backend.python.tasks.pex_build_util import is_local_python_dist
from pants.backend.python.tasks.setup_py import SetupPyRunner
Expand Down Expand Up @@ -49,14 +49,14 @@ def implementation_version(cls):

@classmethod
def subsystem_dependencies(cls):
return super(BuildLocalPythonDistributions, cls).subsystem_dependencies() + (PythonNativeExtensionToolchain.scoped(cls))
return super(BuildLocalPythonDistributions, cls).subsystem_dependencies() + (PythonDistBuildEnvironment.scoped(cls),)

# TODO: seriously consider subclassing UnixCCompiler as well as the build_ext
# command from distutils to control the compiler and linker invocations
# transparently instead of guessing what distutils does by default.
@memoized_property
def _python_native_extension_toolchain(self):
return PythonNativeExtensionToolchain.scoped_instance(self)
def _python_dist_build_environment(self):
return PythonDistBuildEnvironment.scoped_instance(self)

@property
def cache_target_dirs(self):
Expand Down Expand Up @@ -106,7 +106,7 @@ def _create_dist(self, dist_tgt, dist_target_dir, interpreter):
"""Create a .whl file for the specified python_distribution target."""
self.context.log.debug("dist_target_dir: '{}'".format(dist_target_dir))
self._copy_sources(dist_tgt, dist_target_dir)
with self._python_native_extension_toolchain.execution_environment():
with self._python_dist_build_environment.execution_environment():
# Build a whl using SetupPyRunner and return its absolute path.
setup_runner = SetupPyRunner(dist_target_dir, 'bdist_wheel', interpreter=interpreter)
setup_runner.run()
Expand Down

0 comments on commit aaae18c

Please sign in to comment.