-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 proxy package for libx11 #678
Changes from all commits
4882f72
b1922b6
017960b
03f7664
f025587
b033ddd
60799e7
a5ffff0
ad739aa
c26396a
5397b15
1a45ae3
29d1fe6
4c30978
8996cdb
e51e786
878b564
823e364
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
import subprocess | ||
import shlex | ||
|
||
from conans import ConanFile, CMake, tools | ||
from conans.errors import ConanInvalidConfiguration | ||
|
||
def remove_prefix(s, prefix): | ||
return s[len(prefix):] if s.startswith(prefix) else s | ||
|
||
|
||
class LibX11Conan(ConanFile): | ||
name = "libx11" | ||
license = "X11" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://www.x.org/wiki/" | ||
description = "Client interface to the X Window System, otherwise known as \'Xlib\'", | ||
settings = "os", "compiler", "build_type", "arch" | ||
_required_system_package = "libx11-dev" | ||
|
||
def system_requirements(self): | ||
installer = tools.SystemPackageTool() | ||
if not installer.installed(self._required_system_package): | ||
raise ConanInvalidConfiguration( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the plan to have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, they should be installed in CCI, if not all these kinds of recipes would be useless as you say. |
||
"{0} system library missing. Install {0} in your system with something like: "\ | ||
"sudo apt-get install {0}" | ||
.format(self._required_system_package)) | ||
|
||
def configure(self): | ||
if self.settings.os != "Linux": | ||
raise ConanInvalidConfiguration( | ||
"This library is only compatible with Linux") | ||
del self.settings.compiler.libcxx | ||
del self.settings.compiler.cppstd | ||
|
||
def package(self): | ||
tools.download("https://gitlab.freedesktop.org/xorg/lib/libx11/raw/master/COPYING", filename="COPYING") | ||
czoido marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.copy("COPYING", dst="licenses") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it really useful to have a license file when you don't distribute anything ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree, it's pointless |
||
|
||
|
||
def package_info(self): | ||
if tools.which("pkg-config"): | ||
pkg = tools.PkgConfig("x11") | ||
self.cpp_info.includedirs = [remove_prefix(x,'-I') for x in pkg.cflags_only_I] | ||
self.cpp_info.libdirs = [remove_prefix(x,'-L') for x in pkg.libs_only_L] | ||
self.cpp_info.libs = [remove_prefix(x,'-l') for x in pkg.libs_only_l] | ||
self.cpp_info.defines = [remove_prefix(x,'-D') for x in pkg.cflags_only_other if x.startswith('-D')] | ||
self.cpp_info.cflags = [x for x in pkg.cflags_only_other if not x.startswith('-D')] | ||
self.cpp_info.cppflags = [x for x in pkg.cflags_only_other if not x.startswith('-D')] | ||
self.cpp_info.sharedlinkflags = pkg.libs_only_other | ||
self.cpp_info.exelinkflags = pkg.libs_only_other | ||
else: | ||
self.cpp_info.libs.append("X11") | ||
|
||
def package_id(self): | ||
self.info.header_only() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required(VERSION 2.8.11) | ||
|
||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_executable(${CMAKE_PROJECT_NAME} example.cpp) | ||
target_link_libraries(${CMAKE_PROJECT_NAME} ${CONAN_LIBS}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os.path | ||
|
||
from conans import ConanFile, CMake | ||
|
||
|
||
class LibX11TestConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <X11/Xlib.h> | ||
#include <X11/Xutil.h> | ||
|
||
int main() | ||
{ | ||
Display *mydisplay; | ||
mydisplay = XOpenDisplay(""); | ||
XCloseDisplay(mydisplay); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"system": | ||
folder: all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be much better to use pkg-config to check package availability, so it would be completely distro agnostic