Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libev: msvc support #14138

Merged
merged 8 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions recipes/libev/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.14)
project(ev C)

set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

set(LIBEV_PUBLIC_HEADERS
ev.h
config.h)
add_library(ev ev.c ${LIBEV_PUBLIC_HEADERS})
xakod marked this conversation as resolved.
Show resolved Hide resolved
target_link_libraries(ev PUBLIC ws2_32)
target_compile_definitions(ev PRIVATE HAVE_CONFIG_H=1)
target_include_directories(ev PUBLIC ${PROJECT_SOURCE_DIR})

set_target_properties(ev PROPERTIES PUBLIC_HEADER "${LIBEV_PUBLIC_HEADERS}")
include(GNUInstallDirs)

install(TARGETS ev
EXPORT ${EXPORT_NAME}Targets DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT devel
xakod marked this conversation as resolved.
Show resolved Hide resolved
)
7 changes: 7 additions & 0 deletions recipes/libev/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ sources:
"4.25":
sha256: 78757e1c27778d2f3795251d9fe09715d51ce0422416da4abb34af3929c02589
url: http://dist.schmorp.de/libev/Attic/libev-4.25.tar.gz
patches:
"4.33":
- patch_file: "patches/0001-config-for-windows.patch"
"4.27":
- patch_file: "patches/0001-config-for-windows.patch"
"4.25":
- patch_file: "patches/0001-config-for-windows.patch"
45 changes: 32 additions & 13 deletions recipes/libev/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import copy, get, rm, rmdir
from conan.tools.files import apply_conandata_patches, export_conandata_patches, copy, get, rm, rmdir
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
xakod marked this conversation as resolved.
Show resolved Hide resolved
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc, unix_path
import os
Expand Down Expand Up @@ -33,6 +34,10 @@ class LibevConan(ConanFile):
def _settings_build(self):
return getattr(self, "settings_build", self.settings)

def export_sources(self):
copy(self, "CMakeLists.txt", self.recipe_folder, os.path.join(self.export_sources_folder, "src"))
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
Expand All @@ -47,14 +52,12 @@ def layout(self):
basic_layout(self, src_folder="src")

def validate(self):
if is_msvc(self):
raise ConanInvalidConfiguration(f"{self.ref} is not supported by Visual Studio")
if self.info.settings.os == "Windows" and self.info.options.shared:
# libtool: error: can't build i686-pc-mingw32 shared library unless -no-undefined is specified
raise ConanInvalidConfiguration(f"{self.ref} can't be built as shared on Windows")

def build_requirements(self):
if self._settings_build.os == "Windows":
if self._settings_build.os == "Windows" and not is_msvc(self):
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
self.tool_requires("msys2/cci.latest")
Expand All @@ -64,21 +67,37 @@ def source(self):
destination=self.source_folder, strip_root=True)

def generate(self):
env = VirtualBuildEnv(self)
env.generate()
tc = AutotoolsToolchain(self)
tc.generate()
if is_msvc(self):
tc = CMakeToolchain(self)
tc.generate()
tc = CMakeDeps(self)
tc.generate()
xakod marked this conversation as resolved.
Show resolved Hide resolved
else:
env = VirtualBuildEnv(self)
env.generate()
tc = AutotoolsToolchain(self)
tc.generate()

def build(self):
autotools = Autotools(self)
autotools.configure()
autotools.make()
if is_msvc(self):
apply_conandata_patches(self)
xakod marked this conversation as resolved.
Show resolved Hide resolved
xakod marked this conversation as resolved.
Show resolved Hide resolved
cmake = CMake(self)
cmake.configure()
cmake.build()
else:
autotools = Autotools(self)
autotools.configure()
autotools.make()

def package(self):
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
autotools = Autotools(self)
# TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed
xakod marked this conversation as resolved.
Show resolved Hide resolved
autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"])
if is_msvc(self):
cmake = CMake(self)
cmake.install()
else:
autotools = Autotools(self)
autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"])
rmdir(self, os.path.join(self.package_folder, "share"))
rm(self, "*.la", os.path.join(self.package_folder, "lib"))
fix_apple_shared_install_name(self)
Expand Down
145 changes: 145 additions & 0 deletions recipes/libev/all/patches/0001-config-for-windows.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
From 69f8a65f201e132f8afd99a16ed2254bc31930a6 Mon Sep 17 00:00:00 2001
From: Jihadist <tomasiche@gmail.com>
Date: Sat, 31 Dec 2022 15:09:20 +0300
Subject: [PATCH] * config for windows

---
config.h | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 128 insertions(+)
create mode 100644 config.h

diff --git a/config.h b/config.h
new file mode 100644
index 0000000..0832712
--- /dev/null
+++ b/config.h
xakod marked this conversation as resolved.
Show resolved Hide resolved
@@ -0,0 +1,128 @@
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if you have the `clock_gettime' function. */
+#undef HAVE_CLOCK_GETTIME
+
+/* Define to 1 to use the syscall interface for clock_gettime */
+#undef HAVE_CLOCK_SYSCALL
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the `epoll_ctl' function. */
+#undef HAVE_EPOLL_CTL
+
+/* Define to 1 if you have the `eventfd' function. */
+#undef HAVE_EVENTFD
+
+/* Define to 1 if the floor function is available */
+#undef HAVE_FLOOR
+
+/* Define to 1 if you have the `inotify_init' function. */
+#undef HAVE_INOTIFY_INIT
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `kqueue' function. */
+#undef HAVE_KQUEUE
+
+/* Define to 1 if you have the `rt' library (-lrt). */
+#undef HAVE_LIBRT
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `nanosleep' function. */
+#undef HAVE_NANOSLEEP
+
+/* Define to 1 if you have the `poll' function. */
+#undef HAVE_POLL
+
+/* Define to 1 if you have the <poll.h> header file. */
+#undef HAVE_POLL_H
+
+/* Define to 1 if you have the `port_create' function. */
+#undef HAVE_PORT_CREATE
+
+/* Define to 1 if you have the <port.h> header file. */
+#undef HAVE_PORT_H
+
+/* Define to 1 if you have the `select' function. */
+#undef HAVE_SELECT
+
+/* Define to 1 if you have the `signalfd' function. */
+#undef HAVE_SIGNALFD
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/epoll.h> header file. */
+#undef HAVE_SYS_EPOLL_H
+
+/* Define to 1 if you have the <sys/eventfd.h> header file. */
+#undef HAVE_SYS_EVENTFD_H
+
+/* Define to 1 if you have the <sys/event.h> header file. */
+#undef HAVE_SYS_EVENT_H
+
+/* Define to 1 if you have the <sys/inotify.h> header file. */
+#undef HAVE_SYS_INOTIFY_H
+
+/* Define to 1 if you have the <sys/select.h> header file. */
+#undef HAVE_SYS_SELECT_H
+
+/* Define to 1 if you have the <sys/signalfd.h> header file. */
+#undef HAVE_SYS_SIGNALFD_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#undef LT_OBJDIR
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Version number of package */
+#undef VERSION
+
+#define HAVE_SELECT 1
+#define HAVE_SYS_SELECT_H 1
--