Skip to content

Commit

Permalink
expand the flag passthrough logic more, and add a FIXME
Browse files Browse the repository at this point in the history
now blocking on pantsbuild#6271
  • Loading branch information
cosmicexplorer committed Jul 30, 2018
1 parent afacb4c commit 2d360ee
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ static const char *hello_str = "Hello from outside of Pants!";

static PyObject *
hello(PyObject *self, PyObject *args) {
/* FIXME: make this depend on some env var we pass in!? */
return Py_BuildValue("s", hello_str);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# FIXME: do an integration test showing that each of these works (can be imported and run)!
try:
from pants.backend.python.distutils_extensions import pants_setup as setup
except ImportError as e:
except ImportError:
from setuptools import setup


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ def select_llvm_c_toolchain(platform, native_toolchain):
# These arguments are shared across platforms.
llvm_c_compiler_args = [
'-x', 'c', '-std=c11',
# FIXME: we need #6271 so we can get all the system header/lib dirs before we can use this --
# (otherwise compilation will fail).
'-nobuiltininc',
]

Expand Down
11 changes: 11 additions & 0 deletions src/python/pants/backend/python/distutils_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ def customize_compiler_from_env(compiler):
compiler_cxx=cxx_cmd,
linker_so=link_cmd)

include_dirs = os.environ['CPATH'].split(':')
compiler.set_include_dirs(include_dirs)

lib_dirs = os.environ['LIBRARY_PATH'].split(':')
compiler.set_library_dirs(lib_dirs)

all_runtime_library_dir_candidates = (os.environ.get('LD_LIBRARY_PATH', '').split(':') +
os.environ.get('DYLD_LIBRARY_PATH', '').split(':'))
compiler.set_runtime_library_dirs(all_runtime_library_dir_candidates)


class pants_build_ext(distutils_build_ext):
"""???"""
Expand Down Expand Up @@ -96,6 +106,7 @@ def run(self):
self._append_to_compiler_property(self.rpath, self.compiler.add_runtime_library_dir)
self._append_to_compiler_property(self.link_objects, self.compiler.add_link_object)

# TODO: ???
self.compiler.define_macro('PANTS_PYTHON_DIST', None)

# Now actually compile and link everything.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,8 @@ def as_environment(self):
all_include_dirs = cpp_compiler.include_dirs + c_compiler.include_dirs
ret['CPATH'] = create_path_env_var(all_include_dirs)

shared_compile_flags = safe_shlex_join(plat.resolve_platform_specific({
'darwin': lambda: [MIN_OSX_VERSION_ARG],
'linux': lambda: [],
}))
ret['CFLAGS'] = shared_compile_flags
ret['CXXFLAGS'] = shared_compile_flags
ret['CFLAGS'] = safe_shlex_join(c_compiler.extra_args)
ret['CXXFLAGS'] = safe_shlex_join(cpp_compiler.extra_args)

ret['CC'] = c_compiler.exe_filename
ret['CXX'] = cpp_compiler.exe_filename
Expand Down

0 comments on commit 2d360ee

Please sign in to comment.