Skip to content

Commit

Permalink
(#8553) Add wineditline/2.206
Browse files Browse the repository at this point in the history
* Add wineditline/2.206

* Use `conan_basic_setup(TARGETS)` in test_package

* Leave the fetched source untouched

The archive that contains the source also comes with prebuilt binaries.
I deleted these thinking it'd be a waste to leave in the source.

Co-authored-by: friendlyanon <friendlyanon@users.noreply.github.com>
  • Loading branch information
friendlyanon and friendlyanon authored Jan 7, 2022
1 parent aa023f3 commit e7a0155
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 0 deletions.
25 changes: 25 additions & 0 deletions recipes/wineditline/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.1)

project(wineditline_wrapper C)

include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
conan_basic_setup()

set(src source_subfolder/src)

add_library(edit "${src}/editline.c" "${src}/fn_complete.c" "${src}/history.c")
if(BUILD_SHARED_LIBS)
target_sources(edit PRIVATE "${src}/libedit.def")
endif()

target_include_directories(edit PRIVATE "${src}")

include(GNUInstallDirs)

install(
TARGETS edit
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)

install(DIRECTORY "${src}/editline" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
4 changes: 4 additions & 0 deletions recipes/wineditline/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"2.206":
sha256: "2d255c417244e963261dc6171684265f405df030e90ba6e6690a99284d645161"
url: https://sourceforge.net/projects/mingweditline/files/wineditline-2.206.zip/download
76 changes: 76 additions & 0 deletions recipes/wineditline/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import functools
import os

from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration

required_conan_version = ">=1.43.0"


class WineditlineConan(ConanFile):
name = "wineditline"
description = (
"A BSD-licensed EditLine API implementation for the native "
"Windows Console"
)
url = "https://github.com/conan-io/conan-center-index"
homepage = "http://mingweditline.sourceforge.net/"
topics = ("readline", "editline", "windows")
license = "BSD-3-Clause"
generators = ("cmake",)
settings = ("os", "arch", "compiler", "build_type")
options = {
"shared": [True, False],
}
default_options = {
"shared": False,
}

exports_sources = ("CMakeLists.txt",)

@property
def _source_subfolder(self):
return "source_subfolder"

def validate(self):
if self.settings.os != "Windows":
message = "wineditline is supported only on Windows."
raise ConanInvalidConfiguration(message)

def source(self):
root = self._source_subfolder
get_args = self.conan_data["sources"][self.version]
tools.get(**get_args, destination=root, strip_root=True)

def configure(self):
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

@functools.lru_cache(1)
def _configure_cmake(self):
cmake = CMake(self)
cmake.configure()
return cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy("COPYING", "licenses", self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()

def package_info(self):
name = self.name
info = self.cpp_info

info.set_property("cmake_file_name", name)
info.set_property("cmake_target_name", f"{name}::{name}")

info.names.update({
"cmake_find_package": name,
"cmake_find_package_multi": name,
})

info.libs = ["edit"]
10 changes: 10 additions & 0 deletions recipes/wineditline/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)

find_package(wineditline REQUIRED CONFIG)

include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
conan_basic_setup(TARGETS)

add_executable(test_package test_package.c)
target_link_libraries(test_package PRIVATE wineditline::wineditline)
18 changes: 18 additions & 0 deletions recipes/wineditline/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os

from conans import ConanFile, CMake, tools


class TestPackageConan(ConanFile):
settings = ("os", "compiler", "build_type", "arch")
generators = ("cmake", "cmake_find_package_multi")

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
12 changes: 12 additions & 0 deletions recipes/wineditline/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <editline/readline.h>
#include <stddef.h>

int main(int argc, char const* argv[])
{
(void)argc;
(void)argv;

free_history_entry(NULL);

return 0;
}
3 changes: 3 additions & 0 deletions recipes/wineditline/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"2.206":
folder: all

0 comments on commit e7a0155

Please sign in to comment.