forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rewrite BinaryTool a little and remove native toolchain subsystem
- Loading branch information
1 parent
cfe5c86
commit 48d7a93
Showing
15 changed files
with
207 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
python_library( | ||
dependencies=[ | ||
'src/python/pants/binaries:binary_util', | ||
], | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# 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.binaries.binary_tool import NativeTool | ||
|
||
|
||
class LD(NativeTool): | ||
options_scope = 'ld' | ||
# TODO: figure out how to express the "mutual" version for linux and osx ld | ||
default_version = '???' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# 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.binaries.binary_tool import NativeTool | ||
|
||
|
||
class LLVM(NativeTool): | ||
options_scope = 'llvm' | ||
default_version = '5.0.1' | ||
archive_type = 'tgz' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# 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) | ||
|
||
import os | ||
|
||
# from pex.executor import Executor | ||
from pex.interpreter import PythonInterpreter | ||
|
||
from pants.util.memo import memoized_method | ||
|
||
|
||
# INC_DIR_INPUT = b""" | ||
# import sys | ||
# from distutils import sysconfig | ||
|
||
# sys.stdout.write(sysconfig.get_python_inc()) | ||
# """ | ||
|
||
|
||
class SandboxedInterpreter(PythonInterpreter): | ||
|
||
class ToolchainLocationError(Exception): | ||
def __init__(self, dir_path): | ||
msg = "path '{}' does not exist or is not a directory".format(dir_path) | ||
super(ToolchainLocationError, self).__init__(msg) | ||
|
||
class BaseInterpreterError(Exception): pass | ||
|
||
# using another PythonInterpreter to populate the superclass constructor args | ||
def __init__(self, llvm_base_dir, base_interp): | ||
|
||
if not os.path.isdir(llvm_base_dir): | ||
raise ToolchainLocationError(llvm_base_dir) | ||
if not isinstance(base_interp, PythonInterpreter): | ||
raise BaseInterpreterError( | ||
"invalid PythonInterpreter: '{}'".format(repr(base_interp))) | ||
|
||
self._llvm_base_dir = llvm_base_dir | ||
|
||
# this feels a little hacky -- what if pex's PythonInterpreter later needs | ||
# another constructor arg that's not just a property of the class? | ||
super(SandboxedInterpreter, self).__init__( | ||
base_interp.binary, base_interp.identity, extras=base_interp.extras) | ||
|
||
# made into an instance method here (unlike PythonInterpreter superclass) to | ||
# use instance property self._llvm_base_dir | ||
@memoized_method | ||
def sanitized_environment(self): | ||
sanitized_env = super(SandboxedInterpreter, self).sanitized_environment() | ||
|
||
# use our compiler at the front of the path | ||
# TODO: when we provide ld, remove the previous PATH entries | ||
sanitized_env['PATH'] = ':'.join([ | ||
os.path.join(self._llvm_base_dir, 'bin'), | ||
os.environ.get('PATH'), | ||
]) | ||
|
||
# llvm_include = os.path.join(self._llvm_base_dir, 'include') | ||
# python_inc_stdout, _ = Executor.execute([self.binary], env=sanitized_env, stdin_payload=INC_DIR_INPUT) | ||
# sanitized_env['CPATH'] = '{}:{}'.format(llvm_include, python_inc_stdout) | ||
|
||
# TODO: we may not need this. if removed, (probably) remove the 'lib/' dir | ||
# from the llvm packaging script too! | ||
# sanitized_env['LD_LIBRARY_PATH'] = os.path.join(self._llvm_base_dir, 'lib') | ||
|
||
# TODO: see Lib/distutils/sysconfig.py and Lib/_osx_support.py in CPython. | ||
# this line tells distutils to only compile for 64-bit archs -- if not, it | ||
# will attempt to build a fat binary for 32- and 64-bit archs, which makes | ||
# clang invoke "lipo", an osx command which does not appear to be open | ||
# source. | ||
sanitized_env['ARCHFLAGS'] = '-arch x86_64' | ||
|
||
env_vars_to_scrub = ['CC', 'CXX'] | ||
for env_var in env_vars_to_scrub: | ||
sanitized_env.pop(env_var, None) | ||
|
||
return sanitized_env |
135 changes: 0 additions & 135 deletions
135
src/python/pants/backend/python/subsystems/python_native_toolchain.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.