-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbb3c7a
commit d4a69f3
Showing
6 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"238": | ||
url: "https://download.gnome.org/sources/libgudev/238/libgudev-238.tar.xz" | ||
sha256: "61266ab1afc9d73dbc60a8b2af73e99d2fdff47d99544d085760e4fa667b5dd1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.env import VirtualBuildEnv | ||
from conan.tools.files import copy, get, rmdir | ||
from conan.tools.gnu import PkgConfigDeps | ||
from conan.tools.layout import basic_layout | ||
from conan.tools.meson import Meson, MesonToolchain | ||
import os | ||
|
||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
|
||
class LibgudevConan(ConanFile): | ||
name = "libgudev" | ||
description = "This is libgudev, a library providing GObject bindings for libudev." | ||
license = "LGPL-2.0-or-later" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://gitlab.gnome.org/GNOME/libgudev/" | ||
topics = ("device", "gobject", "udev") | ||
package_type = "library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
"introspection": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
"introspection": True, | ||
} | ||
def configure(self): | ||
if self.options.shared: | ||
self.options.rm_safe("fPIC") | ||
self.settings.rm_safe("compiler.cppstd") | ||
self.settings.rm_safe("compiler.libcxx") | ||
|
||
def layout(self): | ||
basic_layout(self, src_folder="src") | ||
|
||
def requirements(self): | ||
self.requires("libsystemd/253.10") | ||
self.requires("glib/2.78.0") | ||
|
||
def validate(self): | ||
if not self.settings.os in ["FreeBSD", "Linux"]: | ||
raise ConanInvalidConfiguration(f"{self.ref} does not support {self.settings.os}.") | ||
|
||
def build_requirements(self): | ||
self.tool_requires("meson/1.2.2") | ||
if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): | ||
self.tool_requires("pkgconf/2.0.3") | ||
self.tool_requires("glib/<host_version>") | ||
if self.options.introspection: | ||
self.tool_requires("gobject-introspection/1.72.0") | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
tc = MesonToolchain(self) | ||
tc.project_options["gtk_doc"] = False | ||
tc.project_options["introspection"] = "enabled" if self.options.introspection else "disabled" | ||
tc.project_options["tests"] = "disabled" | ||
tc.project_options["vapi"] = "disabled" | ||
tc.generate() | ||
tc = PkgConfigDeps(self) | ||
tc.generate() | ||
tc = VirtualBuildEnv(self) | ||
tc.generate() | ||
|
||
def build(self): | ||
meson = Meson(self) | ||
meson.configure() | ||
meson.build() | ||
|
||
def package(self): | ||
copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) | ||
meson = Meson(self) | ||
meson.install() | ||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["gudev-1.0"] | ||
self.cpp_info.requires = ["libsystemd::libudev", "glib::glib-2.0", "glib::gobject-2.0"] | ||
self.cpp_info.includedirs = [os.path.join(self.package_folder, "include", "gudev-1.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.layout import basic_layout | ||
from conan.tools.meson import Meson | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "PkgConfigDeps", "MesonToolchain", "VirtualRunEnv", "VirtualBuildEnv" | ||
test_type = "explicit" | ||
|
||
def layout(self): | ||
basic_layout(self) | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def build_requirements(self): | ||
self.tool_requires("meson/1.2.2") | ||
if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): | ||
self.tool_requires("pkgconf/2.0.3") | ||
|
||
def build(self): | ||
meson = Meson(self) | ||
meson.configure() | ||
meson.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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
project('test_package', 'c') | ||
package_dep = dependency('libgudev') | ||
executable('test_package', | ||
sources : ['test_package.c'], | ||
dependencies : [package_dep]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <stdlib.h> | ||
|
||
#include <gudev/gudev.h> | ||
|
||
|
||
int main(void) { | ||
GUdevClient * test = g_udev_client_new(NULL); | ||
if (!test) { | ||
return EXIT_FAILURE; | ||
} | ||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"238": | ||
folder: all |