Commit f0769b60 authored by Uilian Ries's avatar Uilian Ries Committed by Wouter van Oortmerssen

#4522 Conan package support (#4590)

- Added Conan recipe to build Flatbuffers
- Added Travis job to create Conan package
Signed-off-by: 's avatarUilian Ries <uilianries@gmail.com>
parent 79b80f84
...@@ -40,7 +40,7 @@ matrix: ...@@ -40,7 +40,7 @@ matrix:
env: env:
matrix: matrix:
- BUILD_TYPE=Debug BIICODE=false - BUILD_TYPE=Debug BIICODE=false
- BUILD_TYPE=Release BIICODE=false - BUILD_TYPE=Release BIICODE=false CONAN=true
# biicode .deb files no longer available. # biicode .deb files no longer available.
# - BUILD_TYPE=Release BIICODE=true # - BUILD_TYPE=Release BIICODE=true
# - BUILD_TYPE=Debug BIICODE=true # - BUILD_TYPE=Debug BIICODE=true
...@@ -56,6 +56,7 @@ matrix: ...@@ -56,6 +56,7 @@ matrix:
script: script:
- if [ "$BIICODE" == "false" ]; then cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE . && make && make test; fi - if [ "$BIICODE" == "false" ]; then cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE . && make && make test; fi
- if [ "$BIICODE" == "true" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then ./biicode/support/bii-travis.sh $BUILD_TYPE; fi - if [ "$BIICODE" == "true" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then ./biicode/support/bii-travis.sh $BUILD_TYPE; fi
- if [ "$CONAN" == "true" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo pip install conan && conan create . flatbuffers/testing -s build_type=$BUILD_TYPE; fi
- language: android - language: android
sudo: true sudo: true
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Conan recipe package for Google FlatBuffers
"""
import os
from conans import ConanFile, CMake, tools
class FlatbuffersConan(ConanFile):
name = "flatbuffers"
version = "1.8.0"
license = "https://github.com/google/flatbuffers/blob/master/LICENSE.txt"
url = "https://github.com/google/flatbuffers"
description = "Memory Efficient Serialization Library"
settings = "os", "compiler", "build_type", "arch", "os_build", "arch_build"
options = {"shared": [True, False]}
default_options = "shared=False"
generators = "cmake"
exports = "LICENSE.txt"
exports_sources = ["CMake/*", "include/*", "src/*", "grpc/*", "CMakeLists.txt"]
def _inject_magic_lines(self):
"""Inject Conan setup in cmake file to solve exteral dependencies.
"""
conan_magic_lines = '''project(FlatBuffers)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
'''
tools.replace_in_file("CMakeLists.txt", "project(FlatBuffers)", conan_magic_lines)
def build(self):
"""Configure, build and install FlatBuffers using CMake.
"""
self._inject_magic_lines()
cmake = CMake(self)
cmake.definitions["FLATBUFFERS_BUILD_TESTS"] = False
cmake.definitions["FLATBUFFERS_BUILD_SHAREDLIB"] = self.options.shared
cmake.configure()
cmake.build()
cmake.install()
def package(self):
"""Copy Flatbuffers' artifacts to package folder
"""
self.copy(pattern="LICENSE.txt", dst="licenses")
self.copy(pattern="flathash*", dst="bin", src="bin")
def package_info(self):
"""Collect built libraries names and solve flatc path.
"""
self.cpp_info.libs = tools.collect_libs(self)
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment