(#2689) ncurses: add components + libtic + libtinfo

* ncurses: add components + libtic + libtinfo

* ncurses: disable building terminfo on Windows

* ncurses: disable tinfo + shared ticlib on Windows

* ncurses: bump msys2

* ncurses: add pcre2 to components + build no shared libraries with MSVC MT runtime
This commit is contained in:
Anonymous Maarten
2020-12-29 15:01:49 +01:00
committed by GitHub
parent d2e8ab5484
commit 5480802eef

View File

@@ -21,7 +21,9 @@ class NCursesConan(ConanFile):
"with_extended_colors": [True, False],
"with_cxx": [True, False],
"with_progs": [True, False],
"with_ticlib": ["auto", True, False],
"with_reentrant": [True, False],
"with_tinfo": ["auto", True, False],
"with_pcre2": [True, False],
}
default_options = {
@@ -31,7 +33,9 @@ class NCursesConan(ConanFile):
"with_extended_colors": True,
"with_cxx": True,
"with_progs": True,
"with_ticlib": "auto",
"with_reentrant": False,
"with_tinfo": "auto",
"with_pcre2": False,
}
@@ -41,6 +45,20 @@ class NCursesConan(ConanFile):
def _source_subfolder(self):
return "source_subfolder"
@property
def _with_ticlib(self):
if self.options.with_ticlib == "auto":
return self.settings.os != "Windows"
else:
return self.options.with_ticlib
@property
def _with_tinfo(self):
if self.options.with_tinfo == "auto":
return self.settings.os != "Windows"
else:
return self.options.with_tinfo
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
@@ -48,11 +66,19 @@ class NCursesConan(ConanFile):
def configure(self):
if self.options.shared:
del self.options.fPIC
if self.settings.compiler == "Visual Studio":
if "MT" in str(self.settings.compiler.runtime):
raise ConanInvalidConfiguration("Cannot build shared libraries with static (MT) runtime")
if not self.options.with_cxx:
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd
if not self.options.with_widec:
del self.options.with_extended_colors
if self.settings.os == "Windows":
if self._with_tinfo:
raise ConanInvalidConfiguration("terminfo cannot be built on Windows because it requires a term driver")
if self.options.shared and self._with_ticlib:
raise ConanInvalidConfiguration("ticlib cannot be built separately as a shared library on Windows")
def requirements(self):
if self.options.with_pcre2:
@@ -61,12 +87,11 @@ class NCursesConan(ConanFile):
self.requires("getopt-for-visual-studio/20200201")
self.requires("dirent/1.23.2")
if self.options.get_safe("with_extended_colors", False):
self.requires("naive-tsearch/0.1.0")
self.requires("naive-tsearch/0.1.1")
def build_requirements(self):
if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH") and \
tools.os_info.detect_windows_subsystem() != "msys2":
self.build_requires("msys2/20190524")
if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"):
self.build_requires("msys2/20200517")
def source(self):
tools.get(**self.conan_data["sources"][self.version])
@@ -85,6 +110,8 @@ class NCursesConan(ConanFile):
"--with-pcre2" if self.options.with_pcre2 else "--without-pcre2",
"--with-cxx-binding" if self.options.with_cxx else "--without-cxx-binding",
"--with-progs" if self.options.with_progs else "--without-progs",
"--with-termlib" if self._with_tinfo else "--without-termlib",
"--with-ticlib" if self._with_ticlib else "--without-ticlib",
"--without-libtool",
"--without-ada",
"--without-manpages",
@@ -113,6 +140,7 @@ class NCursesConan(ConanFile):
if self.settings.compiler == "Visual Studio":
conf_args.extend([
"ac_cv_func_getopt=yes",
"ac_cv_func_setvbuf_reversed=no",
])
build = host = "{}-w64-mingw32-msvc7".format(self.settings.arch)
self._autotools.flags.append("-FS")
@@ -183,21 +211,57 @@ class NCursesConan(ConanFile):
res += ".dll.a"
return res
@property
def _libs(self):
libs = []
if self.options.with_cxx:
libs.append("ncurses++")
libs.extend(["form", "menu", "panel", "ncurses"])
return list(l+self._lib_suffix for l in libs)
def package_id(self):
self.info.options.with_ticlib = self._with_ticlib
self.info.options.with_tinfo = self._with_tinfo
def package_info(self):
self.cpp_info.includedirs.append(os.path.join("include", "ncurses" + self._suffix))
self.cpp_info.libs = self._libs
if self._with_tinfo:
self.cpp_info.components["tinfo"].libs = ["tinfo" + self._lib_suffix]
self.cpp_info.components["tinfo"].names["pkg_config"] = "tinfo" + self._lib_suffix
self.cpp_info.components["tinfo"].includedirs.append(os.path.join("include", "ncurses" + self._suffix))
self.cpp_info.components["libcurses"].libs = ["ncurses" + self._lib_suffix]
self.cpp_info.components["libcurses"].names["pkg_config"] = "ncurses" + self._lib_suffix
self.cpp_info.components["libcurses"].includedirs.append(os.path.join("include", "ncurses" + self._suffix))
if not self.options.shared:
self.cpp_info.defines = ["NCURSES_STATIC"]
self.cpp_info.components["libcurses"].defines = ["NCURSES_STATIC"]
if self.settings.os == "Linux":
self.cpp_info.system_libs = ["dl", "m"]
self.cpp_info.components["libcurses"].system_libs = ["dl", "m"]
if self._with_tinfo:
self.cpp_info.components["libcurses"].requires.append("tinfo")
if self.settings.compiler == "Visual Studio":
self.cpp_info.components["libcurses"].requires.extend([
"getopt-for-visual-studio::getopt-for-visual-studio",
"dirent::dirent",
])
if self.options.get_safe("with_extended_colors", False):
self.cpp_info.components["libcurses"].requires.append("naive-tsearch::naive-tsearch")
self.cpp_info.components["panel"].libs = ["panel" + self._lib_suffix]
self.cpp_info.components["panel"].names["pkg_config"] = "panel" + self._lib_suffix
self.cpp_info.components["panel"].requires = ["libcurses"]
self.cpp_info.components["menu"].libs = ["menu" + self._lib_suffix]
self.cpp_info.components["menu"].names["pkg_config"] = "menu" + self._lib_suffix
self.cpp_info.components["menu"].requires = ["libcurses"]
self.cpp_info.components["form"].libs = ["form" + self._lib_suffix]
self.cpp_info.components["form"].names["pkg_config"] = "form" + self._lib_suffix
self.cpp_info.components["form"].requires = ["libcurses"]
if self.options.with_pcre2:
self.cpp_info.components["form"].requires.append("pcre2::pcre2")
if self.options.with_cxx:
self.cpp_info.components["curses++"].libs = ["ncurses++" + self._lib_suffix]
self.cpp_info.components["curses++"].names["pkg_config"] = "ncurses++" + self._lib_suffix
self.cpp_info.components["curses++"].requires = ["libcurses"]
if self._with_ticlib:
self.cpp_info.components["ticlib"].libs = ["tic" + self._lib_suffix]
self.cpp_info.components["ticlib"].names["pkg_config"] = "tic" + self._lib_suffix
self.cpp_info.components["ticlib"].requires = ["libcurses"]
if self.options.with_progs:
bin_path = os.path.join(self.package_folder, "bin")
@@ -207,3 +271,5 @@ class NCursesConan(ConanFile):
terminfo = os.path.join(self.package_folder, "bin", "share", "terminfo")
self.output.info("Setting TERMINFO environment variable: {}".format(terminfo))
self.env_info.TERMINFO = terminfo
self.user_info.lib_suffix = self._lib_suffix