Skip to content

Commit

Permalink
Merge pull request conan-io#1680 from madebr/libedit_recipe
Browse files Browse the repository at this point in the history
Add libedit/3.1 recipe
  • Loading branch information
SSE4 authored May 27, 2020
2 parents 3d94e48 + 15baa81 commit 85c701c
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 0 deletions.
4 changes: 4 additions & 0 deletions recipes/editline/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"3.1":
url: "http://thrysoee.dk/editline/libedit-20191231-3.1.tar.gz"
sha256: "dbb82cb7e116a5f8025d35ef5b4f7d4a3cdd0a3909a146a39112095a2d229071"
94 changes: 94 additions & 0 deletions recipes/editline/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -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"))
8 changes: 8 additions & 0 deletions recipes/editline/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
17 changes: 17 additions & 0 deletions recipes/editline/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 10 additions & 0 deletions recipes/editline/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "histedit.h"

#include <stdio.h>

int main(int argc, char *argv[])
{
EditLine *el = el_init(argv[0], stdin, stdout, stderr);
el_end(el);
return 0;
}
3 changes: 3 additions & 0 deletions recipes/editline/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"3.1":
folder: all

0 comments on commit 85c701c

Please sign in to comment.