diff --git a/conan/CMakeLists.txt b/conan/CMakeLists.txt deleted file mode 100644 index 65f902876e1..00000000000 --- a/conan/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -message(STATUS "Conan FlatBuffers Wrapper") - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -if (WIN32 AND MSVC_LIKE AND FLATBUFFERS_BUILD_SHAREDLIB) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif(WIN32 AND MSVC_LIKE AND FLATBUFFERS_BUILD_SHAREDLIB) - -include(${CMAKE_SOURCE_DIR}/CMakeListsOriginal.txt) diff --git a/conan/build.py b/conan/build.py deleted file mode 100644 index 104f9e0f832..00000000000 --- a/conan/build.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import os -import re -import subprocess -from cpt.packager import ConanMultiPackager - - -def get_branch(): - try: - for line in ( - subprocess.check_output("git branch", shell=True).decode().splitlines() - ): - line = line.strip() - if line.startswith("*") and " (HEAD detached" not in line: - return line.replace("*", "", 1).strip() - return "" - except Exception: - pass - return "" - - -def get_version(): - version = get_branch() - match = re.search(r"v(\d+\.\d+\.\d+.*)", version) - if match: - return match.group(1) - return version - - -def get_reference(username): - return "flatbuffers/{}@google/stable".format(get_version()) - - -if __name__ == "__main__": - login_username = os.getenv("CONAN_LOGIN_USERNAME", "aardappel") - username = os.getenv("CONAN_USERNAME", "google") - upload = os.getenv( - "CONAN_UPLOAD", "https://api.bintray.com/conan/aardappel/flatbuffers" - ) - stable_branch_pattern = os.getenv( - "CONAN_STABLE_BRANCH_PATTERN", r"v\d+\.\d+\.\d+.*" - ) - test_folder = os.getenv( - "CPT_TEST_FOLDER", os.path.join("conan", "test_package") - ) - upload_only_when_stable = os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", True) - - builder = ConanMultiPackager( - reference=get_reference(username), - username=username, - login_username=login_username, - upload=upload, - stable_branch_pattern=stable_branch_pattern, - upload_only_when_stable=upload_only_when_stable, - test_folder=test_folder, - ) - builder.add_common_builds(pure_c=False) - builder.run() diff --git a/conan/test_package/CMakeLists.txt b/conan/test_package/CMakeLists.txt deleted file mode 100644 index 9c1c78c582d..00000000000 --- a/conan/test_package/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -project(test_package CXX) -cmake_minimum_required(VERSION 2.8.11) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/conan/test_package/conanfile.py b/conan/test_package/conanfile.py deleted file mode 100644 index afa78945c11..00000000000 --- a/conan/test_package/conanfile.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -from conans import CMake, ConanFile - - -class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) - self.run("flatc --version", run_environment=True) - self.run("flathash fnv1_16 conan", run_environment=True) diff --git a/conan/test_package/test_package.cpp b/conan/test_package/test_package.cpp deleted file mode 100644 index df7d577ae64..00000000000 --- a/conan/test_package/test_package.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2018 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include "flatbuffers/util.h" - -// Test to validate Conan package generated - -int main(int /*argc*/, const char * /*argv*/ []) { - - const std::string filename("conanbuildinfo.cmake"); - - if (flatbuffers::FileExists(filename.c_str())) { - std::cout << "File " << filename << " exists.\n"; - } else { - std::cout << "File " << filename << " does not exist.\n"; - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} diff --git a/conanfile.py b/conanfile.py deleted file mode 100644 index dc63d14e246..00000000000 --- a/conanfile.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -"""Conan recipe package for Google FlatBuffers""" -import os -import shutil -from conans import CMake, ConanFile, tools - - -class FlatbuffersConan(ConanFile): - name = "flatbuffers" - license = "Apache-2.0" - url = "https://github.com/google/flatbuffers" - homepage = "http://google.github.io/flatbuffers/" - author = "Wouter van Oortmerssen" - topics = ("conan", "flatbuffers", "serialization", "rpc", "json-parser") - description = "Memory Efficient Serialization Library" - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - generators = "cmake" - exports = "LICENSE" - exports_sources = [ - "CMake/*", - "include/*", - "src/*", - "grpc/*", - "CMakeLists.txt", - "conan/CMakeLists.txt", - ] - - def source(self): - """Wrap the original CMake file to call conan_basic_setup""" - shutil.move("CMakeLists.txt", "CMakeListsOriginal.txt") - shutil.move(os.path.join("conan", "CMakeLists.txt"), "CMakeLists.txt") - - 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 - cmake.definitions["FLATBUFFERS_BUILD_FLATLIB"] = not self.options.shared - cmake.configure() - 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""" - cmake = self.configure_cmake() - cmake.install() - self.copy(pattern="LICENSE", dst="licenses") - self.copy( - pattern="FindFlatBuffers.cmake", - dst=os.path.join("lib", "cmake", "flatbuffers"), - src="CMake", - ) - self.copy(pattern="flathash*", dst="bin", src="bin") - self.copy(pattern="flatc*", dst="bin", src="bin") - 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) - self.user_info.flatc = os.path.join(self.package_folder, "bin", "flatc") diff --git a/docs/source/building.md b/docs/source/building.md index e0f1d8a570e..9351c052791 100644 --- a/docs/source/building.md +++ b/docs/source/building.md @@ -89,6 +89,17 @@ CC=clang PATH=$PATH:$(pwd)/swift-${SWIFT_VERSION}-RELEASE-debian12/usr/bin bazel If you are unsure which versions to use, check our CI config at `.bazelci/presubmit.yml`. +## Building with Conan + +You can download and install flatbuffers using the [Conan](https://conan.io/) dependency manager: + + conan install --requires="flatbuffers/[*]" --build=missing + +The flatbuffers package in Conan Center is maintained by +[ConanCenterIndex](https://github.com/conan-io/conan-center-index) community. +If the version is out of date or the package does not work, +please create an issue or pull request on the [Conan Center Index repository](https://github.com/conan-io/conan-center-index). + ## Building with VCPKG You can download and install flatbuffers using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager: