-
Notifications
You must be signed in to change notification settings - Fork 525
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
New binding language: Zig #2258
base: master
Are you sure you want to change the base?
Conversation
zig binding test (need zig version: 0.11)
Replace cmake/autoconf to zig build. This build example need libzmq only
Currently the has only been tested on Linux (wsl2). The purpose to use version 0.11 because of initial support for zig pkg manager. TODO: add libzmq module to build all deps, on single build (ref.: ziglang/zig#14307)
create a new class in https://github.com/zeromq/zproject please |
[WIP] 😅 Although I briefly used zeroMQ, I never used zproject. So, I'm making some tests to better adapt zig. |
Apparently the zig package manager needs to detect in the build.zig and zon dependencies and then manually generate the multihash of each dep (e.g. sha2-256). The libzmq was detected and built, but czmq requires the libzmq headers ( Update: all files (libzmq) has extracted on user global cache (Linux e.g.: # local cache (project folder)
$> tree zig-cache/
zig-cache/
[...]
├── o
│ ├── 85e23b1f3f84cb9cce35d523ffcab725
│ │ └── dependencies.zig
│ ├── fcb53a609b902f91e32497a436feaa8e
│ │ ├── libzmq.so -> libzmq.so.4
│ │ ├── libzmq.so.4 -> libzmq.so.4.3.5
│ │ ├── libzmq.so.4.3.5
│ │ └── lld.id -> 9cb6dff55fdda61620c10687321419e0
│ ├── fd7a3ca3b826d6e15d5b1601c8057f2f
│ │ └── raw_decoder.o
│ └── fe4274462516bd2dd182c8d86ed329b3
│ └── mailbox_safe.o
[...]
90 directories, 197 files Output: $> /zig build
error(compilation): clang failed with stderr: In file included from /home/kassane/czmq/src/zgossip_msg.c:32:
In file included from /home/kassane/czmq/src/czmq_classes.h:35:
In file included from /home/kassane/czmq/src/../include/czmq.h:37:
In file included from /home/kassane/czmq/include/czmq_library.h:23:
/home/kassane/czmq/include/czmq_prelude.h:217:10: fatal error: 'zmq.h' file not found
error(compilation): clang failed with stderr: In file included from /home/kassane/czmq/src/zarmour.c:39:
In file included from /home/kassane/czmq/src/czmq_classes.h:35:
In file included from /home/kassane/czmq/src/../include/czmq.h:37:
In file included from /home/kassane/czmq/include/czmq_library.h:23:
/home/kassane/czmq/include/czmq_prelude.h:217:10: fatal error: 'zmq.h' file not found |
Fixed: Missing ResultSize: Output: $> tree zig-out/
zig-out/
├── include
│ ├── Makefile.am
│ ├── czmq.h
│ ├── czmq_library.h
│ ├── czmq_prelude.h
│ ├── test_zgossip.h
│ ├── zactor.h
│ ├── zargs.h
│ ├── zarmour.h
│ ├── zauth.h
│ ├── zbeacon.h
│ ├── zcert.h
│ ├── zcertstore.h
│ ├── zchunk.h
│ ├── zclock.h
│ ├── zconfig.h
│ ├── zdigest.h
│ ├── zdir.h
│ ├── zdir_patch.h
│ ├── zfile.h
│ ├── zframe.h
│ ├── zgossip.h
│ ├── zhash.h
│ ├── zhashx.h
│ ├── zhttp_client.h
│ ├── zhttp_request.h
│ ├── zhttp_response.h
│ ├── zhttp_server.h
│ ├── zhttp_server_options.h
│ ├── ziflist.h
│ ├── zlist.h
│ ├── zlistx.h
│ ├── zloop.h
│ ├── zmonitor.h
│ ├── zmq.h <-- libzmq (dep) header
│ ├── zmq_utils.h <-- libzmq (dep) header
│ ├── zmsg.h
│ ├── zosc.h
│ ├── zpoller.h
│ ├── zproc.h
│ ├── zproxy.h
│ ├── zrex.h
│ ├── zsock.h
│ ├── zstr.h
│ ├── zsys.h
│ ├── ztimerset.h
│ ├── ztrie.h
│ └── zuuid.h
└── lib
├── libzig_czmq.so -> libzig_czmq.so.4
├── libzig_czmq.so.4 -> libzig_czmq.so.4.2.2
└── libzig_czmq.so.4.2.2
2 directories, 50 files |
@bluca, a doubt: Have you ever thought about using a package manager in the project? Type there is already support for CMake but an old minimal version instead of trying to use |
No, this library is provided by distributions |
It is now possible to use zig-binding to compile even C projects listed in |
Is there any update to this? Zig bindings would be nice to have! |
Currently the has only been tested on Linux (wsl2).
The purpose to use version 0.11 because of initial support for zig pkg manager.
TODO: add libzmq module to build all deps, on single build.
Current test
czmq/bindings/zig/src/czmq.zig
Lines 15 to 21 in 6c3217e
Steps
Note: This contribution is not intended to rewrite or deconstruct the main project. It only seeks to expand the working tooling for better use and build alternative.
References