Skip to content

Commit

Permalink
attempt at zig
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarrier committed Feb 2, 2025
1 parent c3bbf2d commit 1a9424c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cli/.gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
_deps/
.ninja_*
.vscode/
.zig-cache/
*.cmake
*.exe
*.ninja
*.pdb
build/
CMakeCache.txt
CMakeFiles/
CMakeFiles/
33 changes: 33 additions & 0 deletions cli/build.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const std = @import("std");

const targets: []const std.Target.Query = &.{
.{ .cpu_arch = .aarch64, .os_tag = .macos },
.{ .cpu_arch = .aarch64, .os_tag = .windows },
.{ .cpu_arch = .x86_64, .os_tag = .windows },
.{ .cpu_arch = .aarch64, .os_tag = .linux, .abi = .gnu },
.{ .cpu_arch = .aarch64, .os_tag = .linux, .abi = .musl },
.{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .gnu },
.{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .musl },
};

pub fn build(b: *std.Build) !void {
for (targets) |t| {
const exe = b.addExecutable(.{
.name = "identme",
.target = b.resolveTargetQuery(t),
});
exe.addCSourceFile(.{
.file = b.path("main.cpp"),
.flags = &.{ "-std=c++17", "-Os" },
});
if (t.os_tag == .windows) {
exe.linkSystemLibrary("winhttp");
} else {
exe.linkSystemLibrary("curl");
}
const output = b.addInstallArtifact(exe, .{ .dest_dir = .{ .override = .{
.custom = try t.zigTriple(b.allocator),
} } });
b.getInstallStep().dependOn(&output.step);
}
}

0 comments on commit 1a9424c

Please sign in to comment.