From 19d884cf8b62504bd6555a25bc35ea6814acc72a Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Tue, 19 May 2020 20:52:15 +0200 Subject: [PATCH 1/5] Add libedit/3.1 recipe --- recipes/libedit/all/conandata.yml | 4 + recipes/libedit/all/conanfile.py | 120 ++++++++++++++++++ .../libedit/all/test_package/CMakeLists.txt | 8 ++ recipes/libedit/all/test_package/conanfile.py | 16 +++ .../libedit/all/test_package/test_package.c | 10 ++ recipes/libedit/config.yml | 3 + 6 files changed, 161 insertions(+) create mode 100644 recipes/libedit/all/conandata.yml create mode 100644 recipes/libedit/all/conanfile.py create mode 100644 recipes/libedit/all/test_package/CMakeLists.txt create mode 100644 recipes/libedit/all/test_package/conanfile.py create mode 100644 recipes/libedit/all/test_package/test_package.c create mode 100644 recipes/libedit/config.yml diff --git a/recipes/libedit/all/conandata.yml b/recipes/libedit/all/conandata.yml new file mode 100644 index 0000000000000..6a96752d03234 --- /dev/null +++ b/recipes/libedit/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/libedit/all/conanfile.py b/recipes/libedit/all/conanfile.py new file mode 100644 index 0000000000000..8a763e932fa8c --- /dev/null +++ b/recipes/libedit/all/conanfile.py @@ -0,0 +1,120 @@ +from conans import ConanFile, tools, AutoToolsBuildEnvironment +from conans.errors import ConanInvalidConfiguration +from contextlib import contextmanager +import glob +import os + + +class LibeditConan(ConanFile): + name = "libedit" + 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", "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": + raise ConanInvalidConfiguration("tinfo is not (yet) available on CCI") + self.requires("libtinfo/x.y.z") + + def build_requirements(self): + if tools.os_info.is_windows and "CONAN_BASH_PATH" not in os.environ \ + and tools.os_info.detect_windows_subsystem() != "msys2": + self.build_requires("msys2/20190524") + + 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 + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + archive_name = glob.glob("{}-*-{}".format(self.name, self.version))[0] + os.rename(archive_name, self._source_subfolder) + + @contextmanager + def _build_context(self): + env_vars = {} + if self.settings.compiler == "Visual Studio": + build_aux_path = os.path.join(self.build_folder, self._source_subfolder, "build-aux") + lt_compile = tools.unix_path(os.path.join(build_aux_path, "compile")) + lt_ar = tools.unix_path(os.path.join(build_aux_path, "ar-lib")) + env_vars.update({ + "CC": "{} cl -nologo".format(lt_compile), + "CXX": "{} cl -nologo".format(lt_compile), + "LD": "link", + "STRIP": ":", + "AR": "{} lib".format(lt_ar), + "RANLIB": ":", + "NM": "dumpbin -symbols" + }) + with tools.vcvars(self.settings): + with tools.environment_append(env_vars): + yield + else: + yield + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + + 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() + with self._build_context(): + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + with self._build_context(): + 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/libedit/all/test_package/CMakeLists.txt b/recipes/libedit/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8f49103f0066e --- /dev/null +++ b/recipes/libedit/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/libedit/all/test_package/conanfile.py b/recipes/libedit/all/test_package/conanfile.py new file mode 100644 index 0000000000000..b63178709d69f --- /dev/null +++ b/recipes/libedit/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +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): + self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/libedit/all/test_package/test_package.c b/recipes/libedit/all/test_package/test_package.c new file mode 100644 index 0000000000000..68811611154ab --- /dev/null +++ b/recipes/libedit/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/libedit/config.yml b/recipes/libedit/config.yml new file mode 100644 index 0000000000000..992d10eb37c11 --- /dev/null +++ b/recipes/libedit/config.yml @@ -0,0 +1,3 @@ +versions: + "3.1": + folder: all From 35da7150a8c5f59d1f7bbaf688418419db01b455 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Tue, 19 May 2020 21:05:15 +0200 Subject: [PATCH 2/5] libedit: empty libs attribute from autotools --- recipes/libedit/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/libedit/all/conanfile.py b/recipes/libedit/all/conanfile.py index 8a763e932fa8c..7c22c4acee448 100644 --- a/recipes/libedit/all/conanfile.py +++ b/recipes/libedit/all/conanfile.py @@ -85,6 +85,7 @@ 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: From 58ecc5453ca4ddb410e154e1b842c40d58544414 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 21 May 2020 23:04:54 +0200 Subject: [PATCH 3/5] libedit: disable Windows --- recipes/libedit/all/conanfile.py | 41 ++++++-------------------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/recipes/libedit/all/conanfile.py b/recipes/libedit/all/conanfile.py index 7c22c4acee448..efa9c7bded352 100644 --- a/recipes/libedit/all/conanfile.py +++ b/recipes/libedit/all/conanfile.py @@ -1,6 +1,5 @@ from conans import ConanFile, tools, AutoToolsBuildEnvironment from conans.errors import ConanInvalidConfiguration -from contextlib import contextmanager import glob import os @@ -39,11 +38,6 @@ def requirements(self): raise ConanInvalidConfiguration("tinfo is not (yet) available on CCI") self.requires("libtinfo/x.y.z") - def build_requirements(self): - if tools.os_info.is_windows and "CONAN_BASH_PATH" not in os.environ \ - and tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20190524") - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -53,37 +47,18 @@ def configure(self): 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(self.name, self.version))[0] os.rename(archive_name, self._source_subfolder) - @contextmanager - def _build_context(self): - env_vars = {} - if self.settings.compiler == "Visual Studio": - build_aux_path = os.path.join(self.build_folder, self._source_subfolder, "build-aux") - lt_compile = tools.unix_path(os.path.join(build_aux_path, "compile")) - lt_ar = tools.unix_path(os.path.join(build_aux_path, "ar-lib")) - env_vars.update({ - "CC": "{} cl -nologo".format(lt_compile), - "CXX": "{} cl -nologo".format(lt_compile), - "LD": "link", - "STRIP": ":", - "AR": "{} lib".format(lt_ar), - "RANLIB": ":", - "NM": "dumpbin -symbols" - }) - with tools.vcvars(self.settings): - with tools.environment_append(env_vars): - yield - else: - yield - def _configure_autotools(self): if self._autotools: return self._autotools + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) self._autotools.libs = [] @@ -102,15 +77,13 @@ def _patch_sources(self): def build(self): self._patch_sources() - with self._build_context(): - autotools = self._configure_autotools() - autotools.make() + autotools = self._configure_autotools() + autotools.make() def package(self): self.copy("COPYING", src=self._source_subfolder, dst="licenses") - with self._build_context(): - autotools = self._configure_autotools() - autotools.install() + 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")) From d6fc22daf9b5e0518a1b174e7605fc6af37eb095 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Fri, 22 May 2020 15:26:35 +0200 Subject: [PATCH 4/5] libtedit: add TODO for missing recipe Co-authored-by: Uilian Ries --- recipes/libedit/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/libedit/all/conanfile.py b/recipes/libedit/all/conanfile.py index efa9c7bded352..3381ccf353e9f 100644 --- a/recipes/libedit/all/conanfile.py +++ b/recipes/libedit/all/conanfile.py @@ -35,8 +35,8 @@ def requirements(self): 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") - self.requires("libtinfo/x.y.z") def config_options(self): if self.settings.os == "Windows": From 15baa813d4fe5c5e30f2d1fc174dcfc85f0d1dc6 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Tue, 26 May 2020 01:52:21 +0200 Subject: [PATCH 5/5] editline: renamed libedit to editline --- recipes/{libedit => editline}/all/conandata.yml | 0 recipes/{libedit => editline}/all/conanfile.py | 8 ++++---- .../{libedit => editline}/all/test_package/CMakeLists.txt | 0 .../{libedit => editline}/all/test_package/conanfile.py | 3 ++- .../{libedit => editline}/all/test_package/test_package.c | 0 recipes/{libedit => editline}/config.yml | 0 6 files changed, 6 insertions(+), 5 deletions(-) rename recipes/{libedit => editline}/all/conandata.yml (100%) rename recipes/{libedit => editline}/all/conanfile.py (93%) rename recipes/{libedit => editline}/all/test_package/CMakeLists.txt (100%) rename recipes/{libedit => editline}/all/test_package/conanfile.py (69%) rename recipes/{libedit => editline}/all/test_package/test_package.c (100%) rename recipes/{libedit => editline}/config.yml (100%) diff --git a/recipes/libedit/all/conandata.yml b/recipes/editline/all/conandata.yml similarity index 100% rename from recipes/libedit/all/conandata.yml rename to recipes/editline/all/conandata.yml diff --git a/recipes/libedit/all/conanfile.py b/recipes/editline/all/conanfile.py similarity index 93% rename from recipes/libedit/all/conanfile.py rename to recipes/editline/all/conanfile.py index 3381ccf353e9f..662be782e2858 100644 --- a/recipes/libedit/all/conanfile.py +++ b/recipes/editline/all/conanfile.py @@ -4,12 +4,12 @@ import os -class LibeditConan(ConanFile): - name = "libedit" +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", "libedit", "line", "editing", "history", "tokenization") + topics = ("conan", "editline", "libedit", "line", "editing", "history", "tokenization") license = "BSD-3-Clause" settings = "os", "compiler", "build_type", "arch" options = { @@ -52,7 +52,7 @@ def configure(self): def source(self): tools.get(**self.conan_data["sources"][self.version]) - archive_name = glob.glob("{}-*-{}".format(self.name, self.version))[0] + archive_name = glob.glob("{}-*-{}".format("libedit", self.version))[0] os.rename(archive_name, self._source_subfolder) def _configure_autotools(self): diff --git a/recipes/libedit/all/test_package/CMakeLists.txt b/recipes/editline/all/test_package/CMakeLists.txt similarity index 100% rename from recipes/libedit/all/test_package/CMakeLists.txt rename to recipes/editline/all/test_package/CMakeLists.txt diff --git a/recipes/libedit/all/test_package/conanfile.py b/recipes/editline/all/test_package/conanfile.py similarity index 69% rename from recipes/libedit/all/test_package/conanfile.py rename to recipes/editline/all/test_package/conanfile.py index b63178709d69f..efa177fece16d 100644 --- a/recipes/libedit/all/test_package/conanfile.py +++ b/recipes/editline/all/test_package/conanfile.py @@ -13,4 +13,5 @@ def build(self): def test(self): if not tools.cross_building(self.settings): - self.run(os.path.join("bin", "test_package"), run_environment=True) + with tools.environment_append({"TERM": "xtermc"}): + self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/libedit/all/test_package/test_package.c b/recipes/editline/all/test_package/test_package.c similarity index 100% rename from recipes/libedit/all/test_package/test_package.c rename to recipes/editline/all/test_package/test_package.c diff --git a/recipes/libedit/config.yml b/recipes/editline/config.yml similarity index 100% rename from recipes/libedit/config.yml rename to recipes/editline/config.yml