From a136f36fd5aa4e254ba5937560425a97914eddc4 Mon Sep 17 00:00:00 2001 From: toge Date: Mon, 23 Oct 2023 08:46:04 +0900 Subject: [PATCH 1/8] escape: add recipe --- recipes/escape/all/conandata.yml | 4 + recipes/escape/all/conanfile.py | 75 +++++++++++++++++++ .../escape/all/test_package/CMakeLists.txt | 8 ++ recipes/escape/all/test_package/conanfile.py | 26 +++++++ .../escape/all/test_package/test_package.cpp | 9 +++ recipes/escape/config.yml | 3 + 6 files changed, 125 insertions(+) create mode 100644 recipes/escape/all/conandata.yml create mode 100644 recipes/escape/all/conanfile.py create mode 100644 recipes/escape/all/test_package/CMakeLists.txt create mode 100644 recipes/escape/all/test_package/conanfile.py create mode 100644 recipes/escape/all/test_package/test_package.cpp create mode 100644 recipes/escape/config.yml diff --git a/recipes/escape/all/conandata.yml b/recipes/escape/all/conandata.yml new file mode 100644 index 0000000000000..e085298545b64 --- /dev/null +++ b/recipes/escape/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20230615": + url: "https://github.com/a-n-t-h-o-n-y/Escape/archive/e92030d2efd9afcd4290aa066ab90cd17f07f1cb.tar.gz" + sha256: "c497bca29ece14fd5c890ec284ec5a048542c39f7b4472b01d2bec1ec5d2fc89" diff --git a/recipes/escape/all/conanfile.py b/recipes/escape/all/conanfile.py new file mode 100644 index 0000000000000..c4555a3e883cf --- /dev/null +++ b/recipes/escape/all/conanfile.py @@ -0,0 +1,75 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import get, copy +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +import os + +required_conan_version = ">=1.53.0" + +class EscapeConan(ConanFile): + name = "escape" + description = "Terminal Escape Sequence Library in C++17" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/a-n-t-h-o-n-y/Escape" + topics = ("escape sequence", "mouse", "tui") + package_type = "static-library" + settings = "os", "arch", "compiler", "build_type" + options = { + "fPIC": [True, False], + } + default_options = { + "fPIC": True, + } + + @property + def _min_cppstd(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "gcc": "8", + "clang": "7", + "apple-clang": "12", + "Visual Studio": "16", + "msvc": "192", + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["escape"] diff --git a/recipes/escape/all/test_package/CMakeLists.txt b/recipes/escape/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..42f885ca82bd7 --- /dev/null +++ b/recipes/escape/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(escape REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE escape::escape) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/escape/all/test_package/conanfile.py b/recipes/escape/all/test_package/conanfile.py new file mode 100644 index 0000000000000..ef5d7042163ec --- /dev/null +++ b/recipes/escape/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + 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 can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/escape/all/test_package/test_package.cpp b/recipes/escape/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..f1b7ce42eed28 --- /dev/null +++ b/recipes/escape/all/test_package/test_package.cpp @@ -0,0 +1,9 @@ +#include +#include "esc/terminal.hpp" + +int main(void) { + esc::initialize_interactive_terminal(); + esc::uninitialize_terminal(); + + std::cout << "terminal size : " << esc::terminal_width() << " x " << esc::terminal_height() << std::endl; +} diff --git a/recipes/escape/config.yml b/recipes/escape/config.yml new file mode 100644 index 0000000000000..99e34846cfd31 --- /dev/null +++ b/recipes/escape/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20230615": + folder: all From b495538117d189a76258b96c11938c4b690406d0 Mon Sep 17 00:00:00 2001 From: toge Date: Mon, 23 Oct 2023 09:57:07 +0900 Subject: [PATCH 2/8] revise test_package --- recipes/escape/all/test_package/test_package.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/recipes/escape/all/test_package/test_package.cpp b/recipes/escape/all/test_package/test_package.cpp index f1b7ce42eed28..ddf64a2ce3a5f 100644 --- a/recipes/escape/all/test_package/test_package.cpp +++ b/recipes/escape/all/test_package/test_package.cpp @@ -1,9 +1,14 @@ #include -#include "esc/terminal.hpp" +#include "esc/true_color.hpp" int main(void) { - esc::initialize_interactive_terminal(); - esc::uninitialize_terminal(); + esc::RGB red_rgb(255, 0, 0); - std::cout << "terminal size : " << esc::terminal_width() << " x " << esc::terminal_height() << std::endl; + auto red_hsl = esc::rgb_to_hsl(red_rgb); + + std::cout + << "red => hue : " << static_cast(red_hsl.hue) + << " sat: " << static_cast(red_hsl.saturation) + << " lightness: " << static_cast(red_hsl.lightness) + << std::endl; } From 892d65984353c17b9616a6fd427515ca8b4bb969 Mon Sep 17 00:00:00 2001 From: toge Date: Tue, 24 Oct 2023 01:21:42 +0900 Subject: [PATCH 3/8] add build_requirements --- recipes/escape/all/conanfile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recipes/escape/all/conanfile.py b/recipes/escape/all/conanfile.py index c4555a3e883cf..025b08954866c 100644 --- a/recipes/escape/all/conanfile.py +++ b/recipes/escape/all/conanfile.py @@ -54,6 +54,9 @@ def validate(self): f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." ) + def build_requirements(self): + self.tool_requires("cmake/[>=3.16 <4]") + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) From 10b30b59fe247b19a420c5796903129607d79d27 Mon Sep 17 00:00:00 2001 From: toge Date: Sun, 11 Aug 2024 14:12:55 +0900 Subject: [PATCH 4/8] check debug build only Co-authored-by: Uilian Ries --- recipes/escape/all/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/escape/all/conanfile.py b/recipes/escape/all/conanfile.py index 025b08954866c..3b061cbc6e98b 100644 --- a/recipes/escape/all/conanfile.py +++ b/recipes/escape/all/conanfile.py @@ -53,6 +53,8 @@ def validate(self): raise ConanInvalidConfiguration( f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." ) + if self.setting.build_type == "Debug": + raise ConanInvalidConfiguration(f"{self.ref} does not support debug installation.") def build_requirements(self): self.tool_requires("cmake/[>=3.16 <4]") From f0568d92d99fc495ac3026d7304d4cf1b7f48b23 Mon Sep 17 00:00:00 2001 From: toge Date: Sun, 11 Aug 2024 17:11:03 +0900 Subject: [PATCH 5/8] fix typo --- recipes/escape/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/escape/all/conanfile.py b/recipes/escape/all/conanfile.py index 3b061cbc6e98b..22e429a736a16 100644 --- a/recipes/escape/all/conanfile.py +++ b/recipes/escape/all/conanfile.py @@ -53,7 +53,7 @@ def validate(self): raise ConanInvalidConfiguration( f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." ) - if self.setting.build_type == "Debug": + if self.settings.build_type == "Debug": raise ConanInvalidConfiguration(f"{self.ref} does not support debug installation.") def build_requirements(self): From 5caa887db15e2750dd8dd4b5db7fa381b1a89448 Mon Sep 17 00:00:00 2001 From: toge Date: Mon, 12 Aug 2024 23:47:14 +0900 Subject: [PATCH 6/8] drop support libc++ --- recipes/escape/all/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/escape/all/conanfile.py b/recipes/escape/all/conanfile.py index 22e429a736a16..261728921267d 100644 --- a/recipes/escape/all/conanfile.py +++ b/recipes/escape/all/conanfile.py @@ -55,6 +55,8 @@ def validate(self): ) if self.settings.build_type == "Debug": raise ConanInvalidConfiguration(f"{self.ref} does not support debug installation.") + if self.settings.compiler in ["clang", "apple-clang"] and self.settings.compiler.libcxx == "libc++": + raise ConanInvalidConfiguration(f"{self.ref} does not support libc++.") def build_requirements(self): self.tool_requires("cmake/[>=3.16 <4]") From 3283573048b567ba8af05a7d51d088f51a8caacd Mon Sep 17 00:00:00 2001 From: toge Date: Tue, 13 Aug 2024 02:00:25 +0900 Subject: [PATCH 7/8] drop msvc --- recipes/escape/all/conanfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/escape/all/conanfile.py b/recipes/escape/all/conanfile.py index 261728921267d..fa355b9009b2e 100644 --- a/recipes/escape/all/conanfile.py +++ b/recipes/escape/all/conanfile.py @@ -4,6 +4,7 @@ from conan.tools.build import check_min_cppstd from conan.tools.scm import Version from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.microsoft import is_msvc import os required_conan_version = ">=1.53.0" @@ -34,8 +35,6 @@ def _compilers_minimum_version(self): "gcc": "8", "clang": "7", "apple-clang": "12", - "Visual Studio": "16", - "msvc": "192", } def config_options(self): @@ -46,6 +45,8 @@ def layout(self): cmake_layout(self, src_folder="src") def validate(self): + if is_msvc(self): + raise ConanInvalidConfiguration(f"{self.ref} does not support Visual Studio.") if self.settings.compiler.cppstd: check_min_cppstd(self, self._min_cppstd) minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) From b323251ef6a77a48d488c4a53a6aff3d0a9d4af8 Mon Sep 17 00:00:00 2001 From: toge Date: Tue, 13 Aug 2024 02:00:41 +0900 Subject: [PATCH 8/8] update cci.20240119 --- recipes/escape/all/conandata.yml | 6 +++--- recipes/escape/config.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/escape/all/conandata.yml b/recipes/escape/all/conandata.yml index e085298545b64..ae328a8de2031 100644 --- a/recipes/escape/all/conandata.yml +++ b/recipes/escape/all/conandata.yml @@ -1,4 +1,4 @@ sources: - "cci.20230615": - url: "https://github.com/a-n-t-h-o-n-y/Escape/archive/e92030d2efd9afcd4290aa066ab90cd17f07f1cb.tar.gz" - sha256: "c497bca29ece14fd5c890ec284ec5a048542c39f7b4472b01d2bec1ec5d2fc89" + "cci.20240119": + url: "https://github.com/a-n-t-h-o-n-y/Escape/archive/dfba02f05b795f2ccd990335ff2bd13b39ba5a6a.tar.gz" + sha256: "2fbdd93901de8473c7a0a688b467af7554af610c74fa89e91d9b05c922650804" diff --git a/recipes/escape/config.yml b/recipes/escape/config.yml index 99e34846cfd31..74ca9261e7399 100644 --- a/recipes/escape/config.yml +++ b/recipes/escape/config.yml @@ -1,3 +1,3 @@ versions: - "cci.20230615": + "cci.20240119": folder: all