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: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install -r requirements.txt 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 - name: Build pycapnp and install
run: | run: |
python setup.py build # Not necessary, but shows output on stdout
pip install . pip install .
- name: Lint with flake8 - name: Lint with flake8
run: | run: |

View File

@@ -13,7 +13,10 @@ def build_libcapnp(bundle_dir, build_dir, verbose=False):
capnp_dir = os.path.join(bundle_dir, 'capnproto-c++') capnp_dir = os.path.join(bundle_dir, 'capnproto-c++')
build_dir = os.path.abspath(build_dir) build_dir = os.path.abspath(build_dir)
tmp_dir = os.path.join(capnp_dir, 'build') tmp_dir = os.path.join(capnp_dir, 'build')
if not os.path.exists(tmp_dir):
# Clean the tmp build directory every time
if os.path.exists(tmp_dir):
shutil.rmtree(tmp_dir)
os.mkdir(tmp_dir) os.mkdir(tmp_dir)
cxxflags = os.environ.get('CXXFLAGS', None) cxxflags = os.environ.get('CXXFLAGS', None)
@@ -38,7 +41,7 @@ def build_libcapnp(bundle_dir, build_dir, verbose=False):
conf = subprocess.Popen(args, cwd=tmp_dir, stdout=sys.stdout) conf = subprocess.Popen(args, cwd=tmp_dir, stdout=sys.stdout)
returncode = conf.wait() returncode = conf.wait()
if returncode != 0: if returncode != 0:
raise RuntimeError('CMake failed') raise RuntimeError('CMake failed {}'.format(returncode))
# Run build through cmake # Run build through cmake
build = subprocess.Popen([ build = subprocess.Popen([
@@ -54,4 +57,4 @@ def build_libcapnp(bundle_dir, build_dir, verbose=False):
else: else:
os.environ['CXXFLAGS'] = cxxflags os.environ['CXXFLAGS'] = cxxflags
if returncode != 0: 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") build_dir = os.path.join(_this_dir, "build")
if not os.path.exists(build_dir): if not os.path.exists(build_dir):
os.mkdir(build_dir) os.mkdir(build_dir)
fetch_libcapnp(bundle_dir, libcapnp_url)
# 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) 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.include_dirs += [os.path.join(build_dir, 'include')]
self.library_dirs += [os.path.join(build_dir, 'lib')] self.library_dirs += [os.path.join(build_dir, 'lib')]