diff --git a/recipes/ocilib/all/conandata.yml b/recipes/ocilib/all/conandata.yml new file mode 100644 index 0000000000000..2f5cc065e7d14 --- /dev/null +++ b/recipes/ocilib/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "4.7.6": + url: "https://github.com/vrogier/ocilib/releases/download/v4.7.6/ocilib-4.7.6-gnu.tar.gz" + sha256: "35657c00b3cfbcff09a398a6566b95b23067b0d15c1155a17615da7780715a85" diff --git a/recipes/ocilib/all/conanfile.py b/recipes/ocilib/all/conanfile.py new file mode 100644 index 0000000000000..905b8d0df7599 --- /dev/null +++ b/recipes/ocilib/all/conanfile.py @@ -0,0 +1,80 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get, rm, rmdir, chdir +from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.54.0" + +class OCILIBConan(ConanFile): + name = "ocilib" + description = "An open source and cross platform Oracle Driver that delivers efficient access to Oracle databases." + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/vrogier/ocilib" + topics = ("database", "db", "sql", "oracle") + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_oracle_charset": ["ansi", "wide"], + "with_oracle_import": ["runtime", "linkage"], + } + default_options = { + "shared": False, + "fPIC": True, + "with_oracle_charset": "ansi", + "with_oracle_import": "runtime", + } + + @property + def _min_cppstd(self): + return 11 + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + if self.settings.os != "Linux": + raise ConanInvalidConfiguration(f"{self.ref} recipe only supports Linux for now. Pull requests to add new configurtations are welcomed.") + # TODO: Check support for other platforms + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = AutotoolsToolchain(self) + tc.configure_args.extend([ + f"--with-oracle-charset={self.options.with_oracle_charset}", + f"--with-oracle-import={self.options.with_oracle_import}", + ]) + tc.generate() + + def build(self): + with chdir(self, self.source_folder): + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + autotools = Autotools(self) + autotools.install() + + copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) + copy(self, "*", os.path.join(self.source_folder, "include"), os.path.join(self.package_folder, "include")) + copy(self, "*.lib", self.source_folder, os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, "*.a", self.source_folder, os.path.join(self.package_folder, "lib"), keep_path=False) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.libs = ["ocilib"] + self.cpp_info.set_property("pkg_config_name", "ocilib") + self.cpp_info.system_libs.append("dl") diff --git a/recipes/ocilib/all/test_package/CMakeLists.txt b/recipes/ocilib/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2454efc589586 --- /dev/null +++ b/recipes/ocilib/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 11) + +find_package(ocilib REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE ocilib::ocilib) diff --git a/recipes/ocilib/all/test_package/conanfile.py b/recipes/ocilib/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a808db45f245 --- /dev/null +++ b/recipes/ocilib/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +# It will become the standard on Conan 2.x +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/ocilib/all/test_package/test_package.cpp b/recipes/ocilib/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..e71599957563d --- /dev/null +++ b/recipes/ocilib/all/test_package/test_package.cpp @@ -0,0 +1,26 @@ +#include +#include + +#include "ocilib.hpp" + +using namespace ocilib; + +int main(void) +{ + try + { + std::cout << "OCILIB Version: "; + std::cout << OCILIB_MAJOR_VERSION << "."; + std::cout << OCILIB_MINOR_VERSION << "."; + std::cout << OCILIB_REVISION_VERSION << std::endl; + + Environment::Initialize(); + } + catch (...) + { + } + + Environment::Cleanup(); + + return EXIT_SUCCESS; +} diff --git a/recipes/ocilib/config.yml b/recipes/ocilib/config.yml new file mode 100644 index 0000000000000..947442bf2969b --- /dev/null +++ b/recipes/ocilib/config.yml @@ -0,0 +1,3 @@ +versions: + "4.7.6": + folder: all