diff --git a/recipes/editline/all/conandata.yml b/recipes/editline/all/conandata.yml new file mode 100644 index 0000000000000..6a96752d03234 --- /dev/null +++ b/recipes/editline/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "3.1": + url: "http://thrysoee.dk/editline/libedit-20191231-3.1.tar.gz" + sha256: "dbb82cb7e116a5f8025d35ef5b4f7d4a3cdd0a3909a146a39112095a2d229071" diff --git a/recipes/editline/all/conanfile.py b/recipes/editline/all/conanfile.py new file mode 100644 index 0000000000000..662be782e2858 --- /dev/null +++ b/recipes/editline/all/conanfile.py @@ -0,0 +1,94 @@ +from conans import ConanFile, tools, AutoToolsBuildEnvironment +from conans.errors import ConanInvalidConfiguration +import glob +import os + + +class EditlineConan(ConanFile): + name = "editline" + description = "Autotool- and libtoolized port of the NetBSD Editline library (libedit)." + url = "https://github.com/conan-io/conan-center-index" + homepage = "http://thrysoee.dk/editline/" + topics = ("conan", "editline", "libedit", "line", "editing", "history", "tokenization") + license = "BSD-3-Clause" + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + "terminal_db": ["termcap", "ncurses", "tinfo"], + } + default_options = { + "shared": False, + "fPIC": True, + "terminal_db": "termcap", + } + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def requirements(self): + if self.options.terminal_db == "termcap": + self.requires("termcap/1.3.1") + elif self.options.terminal_db == "ncurses": + self.requires("ncurses/6.2") + elif self.options.terminal_db == "tinfo": + # TODO - Add tinfo when available + raise ConanInvalidConfiguration("tinfo is not (yet) available on CCI") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + if self.settings.os == "Windows": + raise ConanInvalidConfiguration("Windows is not supported by libedit (missing termios.h)") + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + archive_name = glob.glob("{}-*-{}".format("libedit", self.version))[0] + os.rename(archive_name, self._source_subfolder) + + def _configure_autotools(self): + if self._autotools: + return self._autotools + + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + self._autotools.libs = [] + + configure_args = [] + if self.options.shared: + configure_args.extend(["--disable-static", "--enable-shared"]) + else: + configure_args.extend(["--enable-static", "--disable-shared"]) + + self._autotools.configure(args=configure_args, configure_dir=self._source_subfolder) + return self._autotools + + def _patch_sources(self): + for patchdata in self.conan_data.get("patches",{}).get(self.version, []): + tools.patch(**patchdata) + + def build(self): + self._patch_sources() + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + autotools = self._configure_autotools() + autotools.install() + + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "share")) + os.unlink(os.path.join(self.package_folder, "lib", "libedit.la")) + + def package_info(self): + self.cpp_info.libs = ["edit"] + self.cpp_info.includedirs.append(os.path.join("include", "editline")) diff --git a/recipes/editline/all/test_package/CMakeLists.txt b/recipes/editline/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8f49103f0066e --- /dev/null +++ b/recipes/editline/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 2.8.11) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/editline/all/test_package/conanfile.py b/recipes/editline/all/test_package/conanfile.py new file mode 100644 index 0000000000000..efa177fece16d --- /dev/null +++ b/recipes/editline/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + with tools.environment_append({"TERM": "xtermc"}): + self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/editline/all/test_package/test_package.c b/recipes/editline/all/test_package/test_package.c new file mode 100644 index 0000000000000..68811611154ab --- /dev/null +++ b/recipes/editline/all/test_package/test_package.c @@ -0,0 +1,10 @@ +#include "histedit.h" + +#include + +int main(int argc, char *argv[]) +{ + EditLine *el = el_init(argv[0], stdin, stdout, stderr); + el_end(el); + return 0; +} diff --git a/recipes/editline/config.yml b/recipes/editline/config.yml new file mode 100644 index 0000000000000..992d10eb37c11 --- /dev/null +++ b/recipes/editline/config.yml @@ -0,0 +1,3 @@ +versions: + "3.1": + folder: all