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

Add efsw #25448

Merged
merged 14 commits into from
Nov 4, 2024
5 changes: 5 additions & 0 deletions recipes/efsw/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sources:
# Newer versions at the top
"1.4.0":
url: "https://github.com/SpartanJ/efsw/archive/refs/tags/1.4.0.tar.gz"
sha256: "9eed5fc8471767faa44134f5379d4de02825e3756007dafa482fd1656e42bc4a"
80 changes: 80 additions & 0 deletions recipes/efsw/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, rm, rmdir
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime
import os


required_conan_version = ">=1.53.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
required_conan_version = ">=1.53.0"
required_conan_version = ">=2.1"

Implements is available since 2.0.9



class EfswConan(ConanFile):
name = "efsw"
description = "efsw is a C++ cross-platform file system watcher and notifier."
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/SpartanJ/efsw"
topics = ("file system", "watch", "cross-platform")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
Comment on lines +29 to +36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
implements = ["auto_shared_fpic"]

Simplify using implements: https://docs.conan.io/2/reference/conanfile/attributes.html#implements

def validate(self):
if self.settings.get_safe("compiler.cppstd"):
check_min_cppstd(self, 11)
Comment on lines +39 to +40
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if self.settings.get_safe("compiler.cppstd"):
check_min_cppstd(self, 11)
check_min_cppstd(self, 11)

For Conan 2.x, it's expected cppstd always.


Julianiolo marked this conversation as resolved.
Show resolved Hide resolved
def layout(self):
cmake_layout(self, src_folder="src")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
if is_msvc(self):
tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self)
tc.variables["BUILD_TEST_APP"] = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tc.variables["BUILD_TEST_APP"] = False
tc.variables["BUILD_TEST_APP"] = False
tc.variables["BUILD_STATIC_LIBS"] = False

Avoid building repeated static library "efsw-static.a"

tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()

# some files extensions and folders are not allowed. Please, read the FAQs to get informed.
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "share"))
rm(self, "*.la", os.path.join(self.package_folder, "lib"))
rm(self, "*.pdb", os.path.join(self.package_folder, "lib"))
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))

def package_info(self):
self.cpp_info.libs = ["efsw"]

# If they are needed on Linux, m, pthread and dl are usually needed on FreeBSD too
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("m", "pthread")
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved

if self.settings.os == "Macos":
self.cpp_info.frameworks = ["Cocoa", "CoreFoundation", "CoreServices"]
11 changes: 11 additions & 0 deletions recipes/efsw/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.15)

project(test_package LANGUAGES CXX) # if the project uses c++

find_package(efsw REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
# don't link to ${CONAN_LIBS} or CONAN_PKG::package
target_link_libraries(${PROJECT_NAME} PRIVATE efsw::efsw)
# In case the target project need a specific C++ standard
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
27 changes: 27 additions & 0 deletions recipes/efsw/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os


# It will become the standard on Conan 2.x
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")
13 changes: 13 additions & 0 deletions recipes/efsw/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <iostream>
#include "efsw/efsw.hpp"

int main(void) {

efsw::FileWatcher* fileWatcher = new efsw::FileWatcher();

std::cout << "Follows symlinks?: " << fileWatcher->followSymlinks() << std::endl;

delete fileWatcher;

return EXIT_SUCCESS;
}
4 changes: 4 additions & 0 deletions recipes/efsw/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
versions:
# Newer versions at the top
"1.4.0":
folder: all