Comments (17)
I like the idea of compiling a single binary that works with multiple system configurations! I'm not sure how I feel about this being the default behavior, but it would be easy to implement in the form of a feature. Maybe after I play around with it a bit, I'll change my mind and just make it the default anyway. Would it be sufficient to just search /usr/lib
and /usr/local/lib
for the needed libraries?
from x11-rs.
We can use dylib until std::dynamic_lib
is stable.
from x11-rs.
I was thinking of using the shared_library
library I wrote.
It provides a macro named shared_library!
which is similar to export {}
blocks and makes the transition easier (it would also make it easier to revert the changes if wanted).
Example here: https://github.com/tomaka/glutin/blob/master/src/api/caca/ffi.rs
from x11-rs.
I can get started on this as soon as I get home.
from x11-rs.
I thought about working on it myself, but if you do it that would be awesome!
Note that you probably need to add an attribute like #![recursion_limit="200"]
, or you will reach the recursion limit.
from x11-rs.
I've run into a problem. The shared_library
macro doesn't seem to like variadic C functions like XCreateIC
. I would comment them out until finding a workaround, but IIRC, glutin uses this function in particular.
from x11-rs.
Arg. I'm aware of this limitation, but I thought that X11 didn't have any variadic function.
from x11-rs.
I may have found a solution, but it's not quite as pretty as I had hoped. I wrote a macro with two patterns: one that takes the usual list of functions, and one that takes a list of functions followed by variadic:
and a list of variadic functions, omitting the ellipses in the pattern to make the compiler happy.
pub fn XWriteBitmapFile (_7: *mut Display, _6: *const c_char, _5: c_ulong, _4: c_uint, _3: c_uint, _2: c_int, _1: c_int) -> c_int,
pub fn XXorRegion (_3: Region, _2: Region, _1: Region) -> c_int,
variadic:
pub fn XCreateIC (_1: XIM) -> XIC,
pub fn XCreateOC (_1: XOM) -> XFontSet,
I'm still working out a bug that's preventing it from compiling, but I should have a test working soon. Should I apply this to shared_library
and submit a pull request?
from x11-rs.
Should I apply this to shared_library and submit a pull request?
That would be nice!
from x11-rs.
x11-rs now supports dynamic linking with a temporary macro when the dynamic
feature is enabled. This temporary macro will be updated once I can wrap my head around the recursiveness of shared_library!
.
from x11-rs.
Example usage:
use x11::xlib::Xlib;
fn do_something_but_not_anything_useful_just_as_an_example () {
let xlib = Xlib::open().unwrap();
let display = (xlib.XOpenDisplay)(null());
(xlib.XCloseDisplay)(display);
}
from x11-rs.
Note that this is a bad usage of Cargo features.
Cargo features are not flags. If a code depends on x11 without dynamic, then adds a dependency on glutin, then x11 will get compiled with the dynamic feature and break the code.
from x11-rs.
Fixed so extern
blocks are not removed. The compiler only tries to link the functions if they are actually called, so this shouldn't cause problems. If this turns out to be wrong, another possible solution is to split the dynamic interface into another crate (but still in to same repo and from mostly the same sources).
from x11-rs.
The compiler only tries to link the functions if they are actually called, so this shouldn't cause problems.
Are you sure that it doesn't pass -lx11
to the linker?
from x11-rs.
The build script uses pkg-config, so it might still pass -lX11
if x11-rs was compiled on a system where pkg-config detected Xlib. Because of this, it might not work to have the old API and the dynamic API coexist in one crate unless I'm forgetting another option. I can't remove the old API because it appears that it will soon be used by servo. If you're okay with it, I'll add another crate for the dynamic API. They'll exist in the same repo and use the same sources for bindings, but different sources for internals (such as the x11_link
macro).
from x11-rs.
I have the split working in a separate branch (dl_split). If you're okay with the changes, I'll submit a pull request to glutin. The only usage change would be using crate x11_dl
instead of x11
.
from x11-rs.
Sure, as long as you publish it on crates.io
from x11-rs.
Related Issues (20)
- Missing git tags for releases HOT 1
- modifier remappings via xmodmap are not read with '=XmodifierMap HOT 1
- XRRScreenResources not giving more than one HOT 1
- SHM-MIT extension
- x11 vs x11-dl? HOT 3
- undefined reference to `XOpenDisplay' HOT 1
- Debug implementation for XEvent is unsound
- XCreateIC returns null incorrectly but only if another crate (tempfile) is present HOT 1
- XshmSegmentInfo can't be created and its fields should be public
- unify x11/x11-dl crates with dlib HOT 2
- Can't run test_x11 test of my lib-crate even with xlib feature enabled HOT 6
- X11 build dependency failed. HOT 3
- Xcomposite extension HOT 1
- Xdamage extension HOT 1
- How to use the Xfixes extension? HOT 7
- MacOS Support HOT 3
- I don't know how to use this struct HOT 3
- Can't load shared library on NetBSD
- Missing constant `None`? HOT 3
- Xlib::open takes up a significant amount of the binary HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from x11-rs.