Closed emoon closed 2 years ago
The command cargo tree
gives me
minifb v0.19.3 (/.../rust_minifb)
├── raw-window-handle v0.3.3
│ └── libc v0.2.95
├── tempfile v3.2.0
│ ├── cfg-if v1.0.0
│ ├── libc v0.2.95
│ ├── rand v0.8.3
│ │ ├── libc v0.2.95
│ │ ├── rand_chacha v0.3.0
│ │ │ ├── ppv-lite86 v0.2.10
│ │ │ └── rand_core v0.6.2
│ │ │ └── getrandom v0.2.3
│ │ │ ├── cfg-if v1.0.0
│ │ │ └── libc v0.2.95
│ │ └── rand_core v0.6.2 (*)
│ └── remove_dir_all v0.5.3
├── wayland-client v0.28.5
│ ├── bitflags v1.2.1
│ ├── downcast-rs v1.2.0
│ ├── libc v0.2.95
│ ├── nix v0.20.0
│ │ ├── bitflags v1.2.1
│ │ ├── cfg-if v1.0.0
│ │ └── libc v0.2.95
│ ├── wayland-commons v0.28.5
│ │ ├── nix v0.20.0 (*)
│ │ ├── once_cell v1.7.2
│ │ ├── smallvec v1.6.1
│ │ └── wayland-sys v0.28.5
│ │ [build-dependencies]
│ │ └── pkg-config v0.3.19
│ └── wayland-sys v0.28.5 (*)
│ [build-dependencies]
│ └── wayland-scanner v0.28.5
│ ├── proc-macro2 v1.0.27
│ │ └── unicode-xid v0.2.2
│ ├── quote v1.0.9
│ │ └── proc-macro2 v1.0.27 (*)
│ └── xml-rs v0.8.3
├── wayland-cursor v0.28.5
│ ├── nix v0.20.0 (*)
│ ├── wayland-client v0.28.5 (*)
│ └── xcursor v0.3.3
│ └── nom v6.1.2
│ └── memchr v2.4.0
│ [build-dependencies]
│ └── version_check v0.9.3
├── wayland-protocols v0.28.5
│ ├── bitflags v1.2.1
│ ├── wayland-client v0.28.5 (*)
│ └── wayland-commons v0.28.5 (*)
│ [build-dependencies]
│ └── wayland-scanner v0.28.5 (*)
├── x11-dl v2.18.5
│ ├── lazy_static v1.4.0
│ ├── libc v0.2.95
│ └── maybe-uninit v2.0.0
│ [build-dependencies]
│ └── pkg-config v0.3.19
├── xkb v0.2.1
│ ├── bitflags v1.2.1
│ ├── libc v0.2.95
│ └── xkbcommon-sys v0.7.5
│ └── libc v0.2.95
│ [build-dependencies]
│ ├── bindgen v0.56.0
│ │ ├── bitflags v1.2.1
│ │ ├── cexpr v0.4.0
│ │ │ └── nom v5.1.2
│ │ │ └── memchr v2.4.0
│ │ │ [build-dependencies]
│ │ │ └── version_check v0.9.3
│ │ ├── clang-sys v1.2.0
│ │ │ ├── glob v0.3.0
│ │ │ ├── libc v0.2.95
│ │ │ └── libloading v0.7.0
│ │ │ └── cfg-if v1.0.0
│ │ │ [build-dependencies]
│ │ │ └── glob v0.3.0
│ │ ├── clap v2.33.3
│ │ │ ├── ansi_term v0.11.0
│ │ │ ├── atty v0.2.14
│ │ │ │ └── libc v0.2.95
│ │ │ ├── bitflags v1.2.1
│ │ │ ├── strsim v0.8.0
│ │ │ ├── textwrap v0.11.0
│ │ │ │ └── unicode-width v0.1.8
│ │ │ ├── unicode-width v0.1.8
│ │ │ └── vec_map v0.8.2
│ │ ├── env_logger v0.8.3
│ │ │ ├── atty v0.2.14 (*)
│ │ │ ├── humantime v2.1.0
│ │ │ ├── log v0.4.14
│ │ │ │ └── cfg-if v1.0.0
│ │ │ ├── regex v1.5.4
│ │ │ │ ├── aho-corasick v0.7.18
│ │ │ │ │ └── memchr v2.4.0
│ │ │ │ ├── memchr v2.4.0
│ │ │ │ └── regex-syntax v0.6.25
│ │ │ └── termcolor v1.1.2
│ │ ├── lazy_static v1.4.0
│ │ ├── lazycell v1.3.0
│ │ ├── log v0.4.14 (*)
│ │ ├── peeking_take_while v0.1.2
│ │ ├── proc-macro2 v1.0.27 (*)
│ │ ├── quote v1.0.9 (*)
│ │ ├── regex v1.5.4 (*)
│ │ ├── rustc-hash v1.1.0
│ │ ├── shlex v0.1.1
│ │ └── which v3.1.1
│ │ └── libc v0.2.95
│ └── pkg-config v0.3.19
└── xkbcommon-sys v0.7.5 (*)
[build-dependencies]
└── cc v1.0.68
[dev-dependencies]
└── png v0.16.8
├── bitflags v1.2.1
├── crc32fast v1.2.1
│ └── cfg-if v1.0.0
├── deflate v0.8.6
│ ├── adler32 v1.2.0
│ └── byteorder v1.4.3
└── miniz_oxide v0.3.7
└── adler32 v1.2.0
from which I'd infer that the dependency on the crate xkb
is a large culprit.
Yeah that looks to be the case. I think many of these extra dependencies were due to Wayland support.
Would be good to investigae what is actually needed in the xkb crate and see if perhaps it can be moved out or so
I took a brief look yesterday at the x11
code. The only usage under that feature flag is to convert a key to a unicode representation here:
https://github.com/emoon/rust_minifb/blob/1a12653fc216875f2b8044e80978061ed792f8de/src/os/posix/x11.rs#L1018
I didn't look carefully but I believe its a bit more involved with wayland.
Yeah. I think wayland is the biggest one here. I haven't really done any of the work on wayland so I'm not sure exactly what is required there.
Maybe @nifker has any idea about xkb
Im pretty sure you can use the xkb stuff from x11 but I dont its a good idea to rely on x11 stuff for wayland
I investigated a bit more and it's a bit weird xkbcommon-sys v0.7.5
isn't pushed to github and it seem the bindgen
dependency was added in that version (the current version on github is 0.7.4) and the author doesn't seem to respond :(
Indeed - I think getting rid of bindgen in particular would reduce the load somewhat (I also often see intermediates being recompiled in my project which I think is due to bindgen rerunning).
For sure, wayland is going to be the bigger pain, but I took a look at x11 code and it seems that the call is simply to exactly the functionality removed by #184 in key_mapping.rs
(i.e. key_mapping.rs
contained a rust version of the function called by the c library xkb). A hacky solution for x11 is to reinstate that.
However, this is perhaps a loss of generality and doesn't help with wayland, which I think is more complicated.
I would be fine with some code duplication inside the crate to reduce the dependencies a bit.
Looking at the list above getting rid of xkb
and replacing it with an alternative crate / dupe code would get rid of the larges chunk. The other dependencies looks quite reasonable except I'm not sure about tempfile
and what that is being used for.
I also don't know about the wayland ones, but it seems pretty reasonable to me at least.
I'm still thinking about this in the back of my head and it is on my long list of todo's. Here's a graphic to show what the current state of affairs looks like:
Great! Yeah, it would be great to clean this up.
Cool tool. In that case it seems that the majority of dependencies comes from orbclient
xkb
and xkbcommon-sys
crates have been removed as dependency and replaced by a manual ffi without use of bindgen
We discussed replacing our use of xkb with rust code but that turns out to a very deep rabbit hole.
The worst offender(s) are gone now so closing
Currently when building for Linux one get a dependency list like this
Which is WAY too much stuff being dragged in... like
clang-sys
This needs to be fixed