Skip to content

Commit

Permalink
(#18652) wineditline: migrate to Conan v2
Browse files Browse the repository at this point in the history
* wineditline: migrate to Conan v2

* wineditline: simplify patching

* Use upstream CMakeLists

Signed-off-by: Uilian Ries <[email protected]>

---------

Signed-off-by: Uilian Ries <[email protected]>
Co-authored-by: Uilian Ries <[email protected]>
  • Loading branch information
valgur and uilianries authored Jun 28, 2024
1 parent 635672d commit c8e4d78
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 110 deletions.
8 changes: 0 additions & 8 deletions recipes/wineditline/all/CMakeLists.txt

This file was deleted.

6 changes: 1 addition & 5 deletions recipes/wineditline/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
sources:
"2.206":
sha256: "2d255c417244e963261dc6171684265f405df030e90ba6e6690a99284d645161"
url: https://sourceforge.net/projects/mingweditline/files/wineditline-2.206.zip/download
patches:
"2.206":
- patch_file: patches/0001-fix-cmakelists.patch
base_path: source_subfolder
url: "https://sourceforge.net/projects/mingweditline/files/wineditline-2.206.zip"
69 changes: 34 additions & 35 deletions recipes/wineditline/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,64 +1,63 @@
import functools
import os

from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get

required_conan_version = ">=1.43.0"
required_conan_version = ">=1.53.0"


class WineditlineConan(ConanFile):
name = "wineditline"
description = (
"A BSD-licensed EditLine API implementation for the native "
"Windows Console"
)
description = "A BSD-licensed EditLine API implementation for the native Windows Console"
license = "BSD-3-Clause"
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")

package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
}
default_options = {
"shared": False,
}
exports_sources = ("patches/*", "CMakeLists.txt")
provides = "editline"

@property
def _target_name(self):
return "edit" if self.options.shared else "edit_static"

def configure(self):
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")

def layout(self):
cmake_layout(self, src_folder="src")

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

@property
def _source_subfolder(self):
return "source_subfolder"
raise ConanInvalidConfiguration(f"{self.ref} is supported only on Windows.")

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

def configure(self):
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd
def generate(self):
tc = CMakeToolchain(self)
tc.generate()

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

def build(self):
for patch in self.conan_data["patches"][self.version]:
tools.patch(**patch)
self._configure_cmake().build()
cmake.build(target=self._target_name)

def package(self):
self.copy("COPYING", "licenses", self._source_subfolder)
self._configure_cmake().install()
copy(self, "COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
copy(self, "*.h", dst=os.path.join(self.package_folder, "include", "editline"), src=os.path.join(self.source_folder, "src", "editline"))
copy(self, "*.lib", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False)
copy(self, "*.dll", dst=os.path.join(self.package_folder, "bin"), src=self.build_folder, keep_path=False)

def package_info(self):
self.cpp_info.libs = ["edit"]
self.cpp_info.libs = [self._target_name]
43 changes: 0 additions & 43 deletions recipes/wineditline/all/patches/0001-fix-cmakelists.patch

This file was deleted.

5 changes: 1 addition & 4 deletions recipes/wineditline/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.15)
project(test_package C)

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

find_package(wineditline REQUIRED CONFIG)

add_executable(test_package test_package.c)
Expand Down
22 changes: 15 additions & 7 deletions recipes/wineditline/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os

from conans import ConanFile, CMake, tools


class TestPackageConan(ConanFile):
settings = ("os", "compiler", "build_type", "arch")
generators = ("cmake", "cmake_find_package_multi")
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

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)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
11 changes: 3 additions & 8 deletions recipes/wineditline/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
#include <editline/readline.h>
#include <stddef.h>

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

free_history_entry(NULL);

return 0;
int main() {
free_history_entry(NULL);
return 0;
}
8 changes: 8 additions & 0 deletions recipes/wineditline/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(test_package)

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

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
${CMAKE_CURRENT_BINARY_DIR}/test_package/)
18 changes: 18 additions & 0 deletions recipes/wineditline/all/test_v1_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)

0 comments on commit c8e4d78

Please sign in to comment.