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 5 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)
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
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
47 changes: 33 additions & 14 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
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,11 @@ 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"))
copy(self, "config.h", self.recipe_folder, os.path.join(self.export_sources_folder, "src"))
xakod marked this conversation as resolved.
Show resolved Hide resolved
xakod marked this conversation as resolved.
Show resolved Hide resolved
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
Expand All @@ -47,38 +53,51 @@ 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")

def source(self):
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)
if not is_msvc(self):
rm(self, "config.h", os.path.join(self.export_sources_folder, "src"))
xakod marked this conversation as resolved.
Show resolved Hide resolved

def generate(self):
env = VirtualBuildEnv(self)
env.generate()
tc = AutotoolsToolchain(self)
tc.generate()
if is_msvc(self):
tc = CMakeToolchain(self)
tc.generate()
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
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
128 changes: 128 additions & 0 deletions recipes/libev/all/config.h
Original file line number Diff line number Diff line change
@@ -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