Zig bindings for MSCL by HBK-MicroStrain
This package sbuild MSCL by Zig. The MSCL used by this package is not MSCL upstream, but a fork to ensure it is buildable by zig.
Supported functionality:
- MSCL/Wireless (bindings development in progress)
Tested environment:
- OS
x86_64-windows-gnux86_64-linux-gnu
- Device
- WSDA-200-USB
Untested options (not recommended to use):
-Dwith_ssl-Dwith_websockets
- zig 0.17.0
zig build -Doptimize=<debug|safe|fast|small> \
-Dmscl_optimize=<debug|safe|fast|small> \
-Dshared \
-Dlink_static_deps \
-Dwith_ssl \
-Dwith_websockets \This package builds MSCL and its dependency (boost) with small optimize mode by default due to too big size in other mode. This default behavior assumes nothing goes wrong with MSCL upstream. To change it, pass -Dmscl_optimize with desired optimize mode.
Project-Specific Options:
-Dtarget=[string] The CPU architecture, OS, and ABI to build for
-Dcpu=[string] Target CPU features to add or subtract
-Dofmt=[string] Target object format
-Ddynamic-linker=[string] Path to interpreter on the target system
-Doptimize=[enum] Prioritize performance, safety, or binary size
Supported Values:
debug
safe
fast
small
-Dshared=[bool] Build MSCL as a shared library (default: false)
-Dlink_static_deps=[bool] Link MSCL's dependencies statically; always on when MSCL is static (default: true)
-Dwith_ssl=[bool] Compile MSCL with SSL support, using the system's OpenSSL (default: false)
-Dwith_websockets=[bool] Compile MSCL with WebSocket support (default: false)zig fetch --save=mscl_zig git+https://github.com/premorobotics/mscl-zigconst std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const mscl_zig = b.dependency("mscl_zig", .{
.target = target,
.optimize = optimize,
});
const exe = b.addExecutable(.{
.name = "executable_name",
.root_module = b.createModule(.{
.root_source_file = b.path("executable_main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "mscl_zig", .module = mscl_zig.module("mscl_zig") },
},
}),
});
b.installArtifact(exe);
const run_step = b.step("run", "Execute the executable");
run_step.dependOn(&b.addRunArtifact(exe).step);
}- MSCL fork --> Minor change to allow zig build MSCL
- boost-libraries-zig --> Support zig 0.17.0 and add lambda package (required by MSCL)
- translate-c
Claude is heavily used in making the C wrapper so that Zig user can use translate-C from this wrapper. The C wrapper mostly calls C++ API provided by MSCL.
All zig source code structure decision is made by human, but the code is generated by AI (some still by human though). Thus, the zig bindings is human defined with AI assistance to accelerate the development.
All examples are completely written by AI (currently) as a way to test the source code with actual device.