Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wineditline/2.206 #8553

Merged
merged 3 commits into from
Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}")
Comment on lines +1 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are CMakeLists in archive, maybe not super neat but it can be patched. It's better to rely on upstream CMakeLists if available, and eventually submit PR to improve it.

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,
})
Comment on lines +68 to +74
Copy link
Contributor

@SpaceIm SpaceIm Jan 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't recommend to explicitly set those values when upstream doesn't provide CMake config file, it's confusing for other maintainers.

And side comment: obfuscating self.cpp_info may not be a good idea

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have sent an email with a patch file to @ptosco to add a CMake package upstream, so let's hope that goes through.

I will remove this in a followup PR.


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>
uilianries marked this conversation as resolved.
Show resolved Hide resolved

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