Guess include and lib directory using capnp executable
This commit is contained in:
committed by
Jacob Alexander
parent
a7efe4e3f8
commit
722579d671
@@ -148,7 +148,7 @@ def detect_version(basedir, compiler=None, **compiler_attrs):
|
|||||||
return props
|
return props
|
||||||
|
|
||||||
|
|
||||||
def test_build():
|
def test_build(**compiler_attrs):
|
||||||
"""do a test build of libcapnp"""
|
"""do a test build of libcapnp"""
|
||||||
tmp_dir = tempfile.mkdtemp()
|
tmp_dir = tempfile.mkdtemp()
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ def test_build():
|
|||||||
# info("Configure: Autodetecting Cap'n Proto settings...")
|
# info("Configure: Autodetecting Cap'n Proto settings...")
|
||||||
# info(" Custom Cap'n Proto dir: %s" % prefix)
|
# info(" Custom Cap'n Proto dir: %s" % prefix)
|
||||||
try:
|
try:
|
||||||
detected = detect_version(tmp_dir)
|
detected = detect_version(tmp_dir, None, **compiler_attrs)
|
||||||
finally:
|
finally:
|
||||||
erase_dir(tmp_dir)
|
erase_dir(tmp_dir)
|
||||||
|
|
||||||
|
|||||||
9
setup.py
9
setup.py
@@ -11,6 +11,7 @@ import sys
|
|||||||
from distutils.command.clean import clean as _clean
|
from distutils.command.clean import clean as _clean
|
||||||
from distutils.errors import CompileError
|
from distutils.errors import CompileError
|
||||||
from distutils.extension import Extension
|
from distutils.extension import Extension
|
||||||
|
from distutils.spawn import find_executable
|
||||||
|
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
@@ -113,10 +114,16 @@ class build_libcapnp_ext(build_ext_c):
|
|||||||
elif force_system_libcapnp:
|
elif force_system_libcapnp:
|
||||||
need_build = False
|
need_build = False
|
||||||
else:
|
else:
|
||||||
|
# Try to use capnp executable to find include and lib path
|
||||||
|
capnp_executable = find_executable("capnp")
|
||||||
|
if capnp_executable:
|
||||||
|
self.include_dirs += [os.path.join(os.path.dirname(capnp_executable), '..', 'include')]
|
||||||
|
self.library_dirs += [os.path.join(os.path.dirname(capnp_executable), '..', 'lib')]
|
||||||
|
|
||||||
# Try to autodetect presence of library. Requires compile/run
|
# Try to autodetect presence of library. Requires compile/run
|
||||||
# step so only works for host (non-cross) compliation
|
# step so only works for host (non-cross) compliation
|
||||||
try:
|
try:
|
||||||
test_build()
|
test_build(include_dirs=self.include_dirs, library_dirs=self.library_dirs)
|
||||||
need_build = False
|
need_build = False
|
||||||
except CompileError:
|
except CompileError:
|
||||||
need_build = True
|
need_build = True
|
||||||
|
|||||||
Reference in New Issue
Block a user