forked from conan-io/conan-center-index
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request conan-io#1680 from madebr/libedit_recipe
Add libedit/3.1 recipe
- Loading branch information
Showing
6 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"3.1": | ||
folder: all |