diff --git a/recipes/wineditline/all/CMakeLists.txt b/recipes/wineditline/all/CMakeLists.txt new file mode 100644 index 0000000000000..a173239c53c44 --- /dev/null +++ b/recipes/wineditline/all/CMakeLists.txt @@ -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}") diff --git a/recipes/wineditline/all/conandata.yml b/recipes/wineditline/all/conandata.yml new file mode 100644 index 0000000000000..60b4632ebe2ba --- /dev/null +++ b/recipes/wineditline/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.206": + sha256: "2d255c417244e963261dc6171684265f405df030e90ba6e6690a99284d645161" + url: https://sourceforge.net/projects/mingweditline/files/wineditline-2.206.zip/download diff --git a/recipes/wineditline/all/conanfile.py b/recipes/wineditline/all/conanfile.py new file mode 100644 index 0000000000000..bc220150a44d9 --- /dev/null +++ b/recipes/wineditline/all/conanfile.py @@ -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"] diff --git a/recipes/wineditline/all/test_package/CMakeLists.txt b/recipes/wineditline/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7a1892d6fe492 --- /dev/null +++ b/recipes/wineditline/all/test_package/CMakeLists.txt @@ -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) diff --git a/recipes/wineditline/all/test_package/conanfile.py b/recipes/wineditline/all/test_package/conanfile.py new file mode 100644 index 0000000000000..ec80e0c5cc134 --- /dev/null +++ b/recipes/wineditline/all/test_package/conanfile.py @@ -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) diff --git a/recipes/wineditline/all/test_package/test_package.c b/recipes/wineditline/all/test_package/test_package.c new file mode 100644 index 0000000000000..b51e6feba3274 --- /dev/null +++ b/recipes/wineditline/all/test_package/test_package.c @@ -0,0 +1,12 @@ +#include +#include + +int main(int argc, char const* argv[]) +{ + (void)argc; + (void)argv; + + free_history_entry(NULL); + + return 0; +} diff --git a/recipes/wineditline/config.yml b/recipes/wineditline/config.yml new file mode 100644 index 0000000000000..ae40e4fdf9630 --- /dev/null +++ b/recipes/wineditline/config.yml @@ -0,0 +1,3 @@ +versions: + "2.206": + folder: all