Defaulting to built-in capnproto

- Adding code to detect if bundled capnproto is already built
This commit is contained in:
Jacob Alexander
2019-10-15 09:05:01 -07:00
parent 7789ebbf96
commit 67d5276936
3 changed files with 19 additions and 13 deletions

View File

@@ -25,15 +25,9 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# Install capnproto
curl -O https://capnproto.org/capnproto-c++-0.7.0.tar.gz
tar zxf capnproto-c++-0.7.0.tar.gz
cd capnproto-c++-0.7.0
./configure
make -j check
sudo make install
- name: Build pycapnp and install
run: |
python setup.py build # Not necessary, but shows output on stdout
pip install .
- name: Lint with flake8
run: |

View File

@@ -13,8 +13,11 @@ def build_libcapnp(bundle_dir, build_dir, verbose=False):
capnp_dir = os.path.join(bundle_dir, 'capnproto-c++')
build_dir = os.path.abspath(build_dir)
tmp_dir = os.path.join(capnp_dir, 'build')
if not os.path.exists(tmp_dir):
os.mkdir(tmp_dir)
# Clean the tmp build directory every time
if os.path.exists(tmp_dir):
shutil.rmtree(tmp_dir)
os.mkdir(tmp_dir)
cxxflags = os.environ.get('CXXFLAGS', None)
os.environ['CXXFLAGS'] = (cxxflags or '') + ' -O2 -DNDEBUG'
@@ -38,7 +41,7 @@ def build_libcapnp(bundle_dir, build_dir, verbose=False):
conf = subprocess.Popen(args, cwd=tmp_dir, stdout=sys.stdout)
returncode = conf.wait()
if returncode != 0:
raise RuntimeError('CMake failed')
raise RuntimeError('CMake failed {}'.format(returncode))
# Run build through cmake
build = subprocess.Popen([
@@ -54,4 +57,4 @@ def build_libcapnp(bundle_dir, build_dir, verbose=False):
else:
os.environ['CXXFLAGS'] = cxxflags
if returncode != 0:
raise RuntimeError('capnproto compilation failed')
raise RuntimeError('capnproto compilation failed: {}'.format(returncode))

View File

@@ -141,9 +141,18 @@ class build_libcapnp_ext(build_ext_c):
build_dir = os.path.join(_this_dir, "build")
if not os.path.exists(build_dir):
os.mkdir(build_dir)
fetch_libcapnp(bundle_dir, libcapnp_url)
build_libcapnp(bundle_dir, build_dir)
# Check if we've already built capnproto
capnp_bin = os.path.join(build_dir, 'bin', 'capnp')
if os.name == 'nt':
capnp_bin = os.path.join(build_dir, 'bin', 'capnp.exe')
if not os.path.exists(capnp_bin):
# Not built, fetch and build
fetch_libcapnp(bundle_dir, libcapnp_url)
build_libcapnp(bundle_dir, build_dir)
else:
info("capnproto already built at {}".format(build_dir))
self.include_dirs += [os.path.join(build_dir, 'include')]
self.library_dirs += [os.path.join(build_dir, 'lib')]