flatbuffers/conanfile.py

75 lines
2.8 KiB
Python
Raw Normal View History

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Conan recipe package for Google FlatBuffers
"""
import os
Conan build packages on CI (#4590) (#4594) * Build Conan package on Travis CI (#4590) - Added multi package support on Linux, running on Travis CI - Only upload when branch is a tag and named "vX.Y.Z" - Replace Conan injection by Conan wrapper - Removed os_build os_arch -- Conan 1.0.1 hotfix Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on OSX (#4590) - Added jobs to build Flatbuffers on OSX running on Travis Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on Windows (#4590) - Added support necessary to build Flatbuffers on Windows (conan) - Added Appveyor jobs to build Conan package - Only build Conan package when release (tag) Signed-off-by: Uilian Ries <uilianries@gmail.com> * Reduce Conan CI support to simple scripts (#4590) - Removed msvc 10 x86_64 workaround - Updated conan remote address - Added Bincrafters' package tools Signed-off-by: Uilian Ries <uilianries@gmail.com> * Add fPIC option on Conan recipe (#4590) - Add fPIC as optional. It works on Linux and OSX - Update recipe metadata: author, homepage, license - Checking for flatc and flathash on Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on CI (#4590) - Add rule to run conan job only for tags - Run Conan on Linux, OSX and Windows - Update package tool to new interface Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update Conan username (#4590) - Use google as default username Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update OSX version on CI (#4590) - Use latest OSX 9.3 version to build Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com>
2018-08-16 19:17:52 +00:00
import shutil
from conans import ConanFile, CMake, tools
class FlatbuffersConan(ConanFile):
name = "flatbuffers"
version = "1.10.0"
Conan build packages on CI (#4590) (#4594) * Build Conan package on Travis CI (#4590) - Added multi package support on Linux, running on Travis CI - Only upload when branch is a tag and named "vX.Y.Z" - Replace Conan injection by Conan wrapper - Removed os_build os_arch -- Conan 1.0.1 hotfix Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on OSX (#4590) - Added jobs to build Flatbuffers on OSX running on Travis Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on Windows (#4590) - Added support necessary to build Flatbuffers on Windows (conan) - Added Appveyor jobs to build Conan package - Only build Conan package when release (tag) Signed-off-by: Uilian Ries <uilianries@gmail.com> * Reduce Conan CI support to simple scripts (#4590) - Removed msvc 10 x86_64 workaround - Updated conan remote address - Added Bincrafters' package tools Signed-off-by: Uilian Ries <uilianries@gmail.com> * Add fPIC option on Conan recipe (#4590) - Add fPIC as optional. It works on Linux and OSX - Update recipe metadata: author, homepage, license - Checking for flatc and flathash on Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on CI (#4590) - Add rule to run conan job only for tags - Run Conan on Linux, OSX and Windows - Update package tool to new interface Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update Conan username (#4590) - Use google as default username Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update OSX version on CI (#4590) - Use latest OSX 9.3 version to build Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com>
2018-08-16 19:17:52 +00:00
license = "Apache-2.0"
url = "https://github.com/google/flatbuffers"
Conan build packages on CI (#4590) (#4594) * Build Conan package on Travis CI (#4590) - Added multi package support on Linux, running on Travis CI - Only upload when branch is a tag and named "vX.Y.Z" - Replace Conan injection by Conan wrapper - Removed os_build os_arch -- Conan 1.0.1 hotfix Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on OSX (#4590) - Added jobs to build Flatbuffers on OSX running on Travis Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on Windows (#4590) - Added support necessary to build Flatbuffers on Windows (conan) - Added Appveyor jobs to build Conan package - Only build Conan package when release (tag) Signed-off-by: Uilian Ries <uilianries@gmail.com> * Reduce Conan CI support to simple scripts (#4590) - Removed msvc 10 x86_64 workaround - Updated conan remote address - Added Bincrafters' package tools Signed-off-by: Uilian Ries <uilianries@gmail.com> * Add fPIC option on Conan recipe (#4590) - Add fPIC as optional. It works on Linux and OSX - Update recipe metadata: author, homepage, license - Checking for flatc and flathash on Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on CI (#4590) - Add rule to run conan job only for tags - Run Conan on Linux, OSX and Windows - Update package tool to new interface Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update Conan username (#4590) - Use google as default username Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update OSX version on CI (#4590) - Use latest OSX 9.3 version to build Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com>
2018-08-16 19:17:52 +00:00
homepage = "http://google.github.io/flatbuffers/"
author = "Wouter van Oortmerssen"
description = "Memory Efficient Serialization Library"
Conan build packages on CI (#4590) (#4594) * Build Conan package on Travis CI (#4590) - Added multi package support on Linux, running on Travis CI - Only upload when branch is a tag and named "vX.Y.Z" - Replace Conan injection by Conan wrapper - Removed os_build os_arch -- Conan 1.0.1 hotfix Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on OSX (#4590) - Added jobs to build Flatbuffers on OSX running on Travis Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on Windows (#4590) - Added support necessary to build Flatbuffers on Windows (conan) - Added Appveyor jobs to build Conan package - Only build Conan package when release (tag) Signed-off-by: Uilian Ries <uilianries@gmail.com> * Reduce Conan CI support to simple scripts (#4590) - Removed msvc 10 x86_64 workaround - Updated conan remote address - Added Bincrafters' package tools Signed-off-by: Uilian Ries <uilianries@gmail.com> * Add fPIC option on Conan recipe (#4590) - Add fPIC as optional. It works on Linux and OSX - Update recipe metadata: author, homepage, license - Checking for flatc and flathash on Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on CI (#4590) - Add rule to run conan job only for tags - Run Conan on Linux, OSX and Windows - Update package tool to new interface Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update Conan username (#4590) - Use google as default username Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update OSX version on CI (#4590) - Use latest OSX 9.3 version to build Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com>
2018-08-16 19:17:52 +00:00
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = "shared=False", "fPIC=True"
generators = "cmake"
exports = "LICENSE.txt"
Conan build packages on CI (#4590) (#4594) * Build Conan package on Travis CI (#4590) - Added multi package support on Linux, running on Travis CI - Only upload when branch is a tag and named "vX.Y.Z" - Replace Conan injection by Conan wrapper - Removed os_build os_arch -- Conan 1.0.1 hotfix Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on OSX (#4590) - Added jobs to build Flatbuffers on OSX running on Travis Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on Windows (#4590) - Added support necessary to build Flatbuffers on Windows (conan) - Added Appveyor jobs to build Conan package - Only build Conan package when release (tag) Signed-off-by: Uilian Ries <uilianries@gmail.com> * Reduce Conan CI support to simple scripts (#4590) - Removed msvc 10 x86_64 workaround - Updated conan remote address - Added Bincrafters' package tools Signed-off-by: Uilian Ries <uilianries@gmail.com> * Add fPIC option on Conan recipe (#4590) - Add fPIC as optional. It works on Linux and OSX - Update recipe metadata: author, homepage, license - Checking for flatc and flathash on Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on CI (#4590) - Add rule to run conan job only for tags - Run Conan on Linux, OSX and Windows - Update package tool to new interface Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update Conan username (#4590) - Use google as default username Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update OSX version on CI (#4590) - Use latest OSX 9.3 version to build Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com>
2018-08-16 19:17:52 +00:00
exports_sources = ["CMake/*", "include/*", "src/*", "grpc/*", "CMakeLists.txt", "conan/CMakeLists.txt"]
Conan build packages on CI (#4590) (#4594) * Build Conan package on Travis CI (#4590) - Added multi package support on Linux, running on Travis CI - Only upload when branch is a tag and named "vX.Y.Z" - Replace Conan injection by Conan wrapper - Removed os_build os_arch -- Conan 1.0.1 hotfix Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on OSX (#4590) - Added jobs to build Flatbuffers on OSX running on Travis Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on Windows (#4590) - Added support necessary to build Flatbuffers on Windows (conan) - Added Appveyor jobs to build Conan package - Only build Conan package when release (tag) Signed-off-by: Uilian Ries <uilianries@gmail.com> * Reduce Conan CI support to simple scripts (#4590) - Removed msvc 10 x86_64 workaround - Updated conan remote address - Added Bincrafters' package tools Signed-off-by: Uilian Ries <uilianries@gmail.com> * Add fPIC option on Conan recipe (#4590) - Add fPIC as optional. It works on Linux and OSX - Update recipe metadata: author, homepage, license - Checking for flatc and flathash on Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on CI (#4590) - Add rule to run conan job only for tags - Run Conan on Linux, OSX and Windows - Update package tool to new interface Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update Conan username (#4590) - Use google as default username Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update OSX version on CI (#4590) - Use latest OSX 9.3 version to build Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com>
2018-08-16 19:17:52 +00:00
def source(self):
"""Wrap the original CMake file to call conan_basic_setup
"""
Conan build packages on CI (#4590) (#4594) * Build Conan package on Travis CI (#4590) - Added multi package support on Linux, running on Travis CI - Only upload when branch is a tag and named "vX.Y.Z" - Replace Conan injection by Conan wrapper - Removed os_build os_arch -- Conan 1.0.1 hotfix Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on OSX (#4590) - Added jobs to build Flatbuffers on OSX running on Travis Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on Windows (#4590) - Added support necessary to build Flatbuffers on Windows (conan) - Added Appveyor jobs to build Conan package - Only build Conan package when release (tag) Signed-off-by: Uilian Ries <uilianries@gmail.com> * Reduce Conan CI support to simple scripts (#4590) - Removed msvc 10 x86_64 workaround - Updated conan remote address - Added Bincrafters' package tools Signed-off-by: Uilian Ries <uilianries@gmail.com> * Add fPIC option on Conan recipe (#4590) - Add fPIC as optional. It works on Linux and OSX - Update recipe metadata: author, homepage, license - Checking for flatc and flathash on Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on CI (#4590) - Add rule to run conan job only for tags - Run Conan on Linux, OSX and Windows - Update package tool to new interface Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update Conan username (#4590) - Use google as default username Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update OSX version on CI (#4590) - Use latest OSX 9.3 version to build Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com>
2018-08-16 19:17:52 +00:00
shutil.move("CMakeLists.txt", "CMakeListsOriginal.txt")
shutil.move(os.path.join("conan", "CMakeLists.txt"), "CMakeLists.txt")
Conan build packages on CI (#4590) (#4594) * Build Conan package on Travis CI (#4590) - Added multi package support on Linux, running on Travis CI - Only upload when branch is a tag and named "vX.Y.Z" - Replace Conan injection by Conan wrapper - Removed os_build os_arch -- Conan 1.0.1 hotfix Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on OSX (#4590) - Added jobs to build Flatbuffers on OSX running on Travis Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on Windows (#4590) - Added support necessary to build Flatbuffers on Windows (conan) - Added Appveyor jobs to build Conan package - Only build Conan package when release (tag) Signed-off-by: Uilian Ries <uilianries@gmail.com> * Reduce Conan CI support to simple scripts (#4590) - Removed msvc 10 x86_64 workaround - Updated conan remote address - Added Bincrafters' package tools Signed-off-by: Uilian Ries <uilianries@gmail.com> * Add fPIC option on Conan recipe (#4590) - Add fPIC as optional. It works on Linux and OSX - Update recipe metadata: author, homepage, license - Checking for flatc and flathash on Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on CI (#4590) - Add rule to run conan job only for tags - Run Conan on Linux, OSX and Windows - Update package tool to new interface Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update Conan username (#4590) - Use google as default username Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update OSX version on CI (#4590) - Use latest OSX 9.3 version to build Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com>
2018-08-16 19:17:52 +00:00
def config_options(self):
"""Remove fPIC option on Windows platform
"""
if self.settings.os == "Windows":
self.options.remove("fPIC")
def configure_cmake(self):
"""Create CMake instance and execute configure step
"""
cmake = CMake(self)
cmake.definitions["FLATBUFFERS_BUILD_TESTS"] = False
cmake.definitions["FLATBUFFERS_BUILD_SHAREDLIB"] = self.options.shared
Conan build packages on CI (#4590) (#4594) * Build Conan package on Travis CI (#4590) - Added multi package support on Linux, running on Travis CI - Only upload when branch is a tag and named "vX.Y.Z" - Replace Conan injection by Conan wrapper - Removed os_build os_arch -- Conan 1.0.1 hotfix Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on OSX (#4590) - Added jobs to build Flatbuffers on OSX running on Travis Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on Windows (#4590) - Added support necessary to build Flatbuffers on Windows (conan) - Added Appveyor jobs to build Conan package - Only build Conan package when release (tag) Signed-off-by: Uilian Ries <uilianries@gmail.com> * Reduce Conan CI support to simple scripts (#4590) - Removed msvc 10 x86_64 workaround - Updated conan remote address - Added Bincrafters' package tools Signed-off-by: Uilian Ries <uilianries@gmail.com> * Add fPIC option on Conan recipe (#4590) - Add fPIC as optional. It works on Linux and OSX - Update recipe metadata: author, homepage, license - Checking for flatc and flathash on Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on CI (#4590) - Add rule to run conan job only for tags - Run Conan on Linux, OSX and Windows - Update package tool to new interface Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update Conan username (#4590) - Use google as default username Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update OSX version on CI (#4590) - Use latest OSX 9.3 version to build Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com>
2018-08-16 19:17:52 +00:00
cmake.definitions["FLATBUFFERS_BUILD_FLATLIB"] = not self.options.shared
cmake.configure()
Conan build packages on CI (#4590) (#4594) * Build Conan package on Travis CI (#4590) - Added multi package support on Linux, running on Travis CI - Only upload when branch is a tag and named "vX.Y.Z" - Replace Conan injection by Conan wrapper - Removed os_build os_arch -- Conan 1.0.1 hotfix Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on OSX (#4590) - Added jobs to build Flatbuffers on OSX running on Travis Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on Windows (#4590) - Added support necessary to build Flatbuffers on Windows (conan) - Added Appveyor jobs to build Conan package - Only build Conan package when release (tag) Signed-off-by: Uilian Ries <uilianries@gmail.com> * Reduce Conan CI support to simple scripts (#4590) - Removed msvc 10 x86_64 workaround - Updated conan remote address - Added Bincrafters' package tools Signed-off-by: Uilian Ries <uilianries@gmail.com> * Add fPIC option on Conan recipe (#4590) - Add fPIC as optional. It works on Linux and OSX - Update recipe metadata: author, homepage, license - Checking for flatc and flathash on Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on CI (#4590) - Add rule to run conan job only for tags - Run Conan on Linux, OSX and Windows - Update package tool to new interface Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update Conan username (#4590) - Use google as default username Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update OSX version on CI (#4590) - Use latest OSX 9.3 version to build Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com>
2018-08-16 19:17:52 +00:00
return cmake
def build(self):
"""Configure, build and install FlatBuffers using CMake.
"""
cmake = self.configure_cmake()
cmake.build()
def package(self):
"""Copy Flatbuffers' artifacts to package folder
"""
Conan build packages on CI (#4590) (#4594) * Build Conan package on Travis CI (#4590) - Added multi package support on Linux, running on Travis CI - Only upload when branch is a tag and named "vX.Y.Z" - Replace Conan injection by Conan wrapper - Removed os_build os_arch -- Conan 1.0.1 hotfix Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on OSX (#4590) - Added jobs to build Flatbuffers on OSX running on Travis Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on Windows (#4590) - Added support necessary to build Flatbuffers on Windows (conan) - Added Appveyor jobs to build Conan package - Only build Conan package when release (tag) Signed-off-by: Uilian Ries <uilianries@gmail.com> * Reduce Conan CI support to simple scripts (#4590) - Removed msvc 10 x86_64 workaround - Updated conan remote address - Added Bincrafters' package tools Signed-off-by: Uilian Ries <uilianries@gmail.com> * Add fPIC option on Conan recipe (#4590) - Add fPIC as optional. It works on Linux and OSX - Update recipe metadata: author, homepage, license - Checking for flatc and flathash on Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on CI (#4590) - Add rule to run conan job only for tags - Run Conan on Linux, OSX and Windows - Update package tool to new interface Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update Conan username (#4590) - Use google as default username Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update OSX version on CI (#4590) - Use latest OSX 9.3 version to build Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com>
2018-08-16 19:17:52 +00:00
cmake = self.configure_cmake()
cmake.install()
self.copy(pattern="LICENSE.txt", dst="licenses")
self.copy(pattern="flathash*", dst="bin", src="bin")
2018-08-06 19:45:35 +00:00
self.copy(pattern="flatc*", dst="bin", src="bin")
Conan build packages on CI (#4590) (#4594) * Build Conan package on Travis CI (#4590) - Added multi package support on Linux, running on Travis CI - Only upload when branch is a tag and named "vX.Y.Z" - Replace Conan injection by Conan wrapper - Removed os_build os_arch -- Conan 1.0.1 hotfix Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on OSX (#4590) - Added jobs to build Flatbuffers on OSX running on Travis Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on Windows (#4590) - Added support necessary to build Flatbuffers on Windows (conan) - Added Appveyor jobs to build Conan package - Only build Conan package when release (tag) Signed-off-by: Uilian Ries <uilianries@gmail.com> * Reduce Conan CI support to simple scripts (#4590) - Removed msvc 10 x86_64 workaround - Updated conan remote address - Added Bincrafters' package tools Signed-off-by: Uilian Ries <uilianries@gmail.com> * Add fPIC option on Conan recipe (#4590) - Add fPIC as optional. It works on Linux and OSX - Update recipe metadata: author, homepage, license - Checking for flatc and flathash on Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on CI (#4590) - Add rule to run conan job only for tags - Run Conan on Linux, OSX and Windows - Update package tool to new interface Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update Conan username (#4590) - Use google as default username Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update OSX version on CI (#4590) - Use latest OSX 9.3 version to build Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com>
2018-08-16 19:17:52 +00:00
if self.settings.os == "Windows" and self.options.shared:
if self.settings.compiler == "Visual Studio":
shutil.move(os.path.join(self.package_folder, "lib", "%s.dll" % self.name),
os.path.join(self.package_folder, "bin", "%s.dll" % self.name))
elif self.settings.compiler == "gcc":
shutil.move(os.path.join(self.package_folder, "lib", "lib%s.dll" % self.name),
os.path.join(self.package_folder, "bin", "lib%s.dll" % self.name))
def package_info(self):
"""Collect built libraries names and solve flatc path.
"""
self.cpp_info.libs = tools.collect_libs(self)
2018-08-06 19:45:35 +00:00
self.user_info.flatc = os.path.join(self.package_folder, "bin", "flatc")