Skip to content

Commit

Permalink
(#4187) [pdcurses] fix hooks and conventions, add FreeBSD support
Browse files Browse the repository at this point in the history
* [pdcurses] fix hooks and conventions

* pdcurses: don't add runtime when linking

* pdcurses: use xorg/system + add FreeBSD

Co-authored-by: Anonymous Maarten <[email protected]>
  • Loading branch information
mathbunnyru and madebr authored Jan 11, 2021
1 parent 39698b6 commit 85f47df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
32 changes: 13 additions & 19 deletions recipes/pdcurses/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class PDCursesConan(ConanFile):
name = "pdcurses"
description = "PDCurses - a curses library for environments that don't fit the termcap/terminfo model"
topics = "conan", "pdcurses", "curses", "ncurses"
topics = ("conan", "pdcurses", "curses", "ncurses")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://pdcurses.org/"
license = "Public Domain", "MITX"
Expand Down Expand Up @@ -39,26 +39,26 @@ def _build_subfolder(self):
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if self.settings.os != "Linux":
if self.settings.os not in ("FreeBSD", "Linux"):
del self.options.enable_widec

def configure(self):
if self.settings.os == "Macos":
raise ConanInvalidConfiguration("pdcurses does not support Macos")
if self.settings.os == "Linux":
if not tools.get_env("PDCURSES_OVERRIDE_X11", False):
raise ConanInvalidConfiguration("conan-center-index has no packages for X11 (yet)")
if tools.is_apple_os(self.settings.os):
raise ConanInvalidConfiguration("pdcurses does not support Apple")
if self.options.with_sdl:
raise ConanInvalidConfiguration("conan-center-index has no packages for sdl2 (yet)")
raise ConanInvalidConfiguration("conan-center-index has no packages for sdl (yet)")
if self.options.shared:
del self.options.fPIC
del self.settings.compiler.cppstd
del self.settings.compiler.libcxx

def requirements(self):
if self.settings.os in ("FreeBSD", "Linux"):
self.requires("xorg/system")

def build_requirements(self):
if self.settings.compiler != "Visual Studio":
if not tools.which("make"):
self.build_requires("make/4.2.1")
self.build_requires("make/4.2.1")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
Expand All @@ -82,7 +82,7 @@ def _build_windows(self):
args.append("DLL=Y")
args = " ".join(args)
if self.settings.compiler == "Visual Studio":
with tools.vcvars(self.settings):
with tools.vcvars(self):
self.run("nmake -f Makefile.vc {}".format(args))
else:
self.run("{} libs {}".format(os.environ["CONAN_MAKE_PROGRAM"], args))
Expand All @@ -92,9 +92,6 @@ def _patch_sources(self):
tools.replace_in_file(os.path.join(self._source_subfolder, "wincon", "Makefile.vc"),
"$(CFLAGS)",
"$(CFLAGS) -{}".format(self.settings.compiler.runtime))
tools.replace_in_file(os.path.join(self._source_subfolder, "wincon", "Makefile.vc"),
"$(LDFLAGS)",
"$(LDFLAGS) -{}".format(self.settings.compiler.runtime))
tools.replace_in_file(os.path.join(self._source_subfolder, "x11", "Makefile.in"),
"$(INSTALL) -c -m 644 $(osdir)/libXCurses.a $(libdir)/libXCurses.a",
"-$(INSTALL) -c -m 644 $(osdir)/libXCurses.a $(libdir)/libXCurses.a")
Expand All @@ -120,7 +117,7 @@ def _subsystem_folder(self):
@property
def _license_text(self):
readme = tools.load(os.path.join(self._source_subfolder, self._subsystem_folder, "README.md"))
match = re.search("Distribution Status\n[\\-]+(?:[\r\n])+((?:[0-9a-z .,;*]+[\r\n])+)", readme,
match = re.search(r"Distribution Status\n[\-]+(?:[\r\n])+((?:[0-9a-z .,;*]+[\r\n])+)", readme,
re.IGNORECASE | re.MULTILINE)
if not match:
raise ConanException("Cannot extract distribution status")
Expand All @@ -147,9 +144,6 @@ def package(self):
def package_info(self):
if self.settings.os == "Windows":
self.cpp_info.libs = ["pdcurses"]
else:
elif self.settings.os in ("FreeBSD", "Linux"):
self.cpp_info.includedirs.append(os.path.join("include", "xcurses"))
self.cpp_info.libs = ["XCurses"]
if not self.options.shared:
if self.settings.os == "Linux":
self.cpp_info.system_libs = ["Xaw", "Xmu", "Xt", "X11", "Xpm", "SM", "ICE", "Xext", "xcb", "Xau"]
2 changes: 1 addition & 1 deletion recipes/pdcurses/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.11)
cmake_minimum_required(VERSION 3.1)
project(test_package C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
Expand Down

0 comments on commit 85f47df

Please sign in to comment.