Initial Commit
This commit is contained in:
commit
d286a5afdd
10 changed files with 168 additions and 0 deletions
9
.editorconfig
Normal file
9
.editorconfig
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
max_line_length = 90
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
**/.zig-cache/
|
||||||
|
zig-out/
|
27
build.zig
Normal file
27
build.zig
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
const client_b = @import("client/build.zig");
|
||||||
|
const common_b = @import("common/build.zig");
|
||||||
|
const server_b = @import("server/build.zig");
|
||||||
|
|
||||||
|
pub fn build(b: *std.Build) void {
|
||||||
|
const Modules = enum { Client, Server, Both };
|
||||||
|
const modules = b.option(Modules, "modules", "Choose whether to build the client, the server, or both.") orelse .Both;
|
||||||
|
|
||||||
|
const target = b.standardTargetOptions(.{});
|
||||||
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
|
const common = common_b.build(b, target, optimize);
|
||||||
|
|
||||||
|
if (modules != Modules.Server) {
|
||||||
|
const client = client_b.build(b, target, optimize);
|
||||||
|
client.root_module.addImport("common", common.root_module);
|
||||||
|
b.installArtifact(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modules != Modules.Client) {
|
||||||
|
const server = server_b.build(b, target, optimize);
|
||||||
|
server.root_module.addImport("common", common.root_module);
|
||||||
|
b.installArtifact(server);
|
||||||
|
}
|
||||||
|
}
|
20
build.zig.zon
Normal file
20
build.zig.zon
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
.{
|
||||||
|
.name = .chat,
|
||||||
|
.version = "0.0.1",
|
||||||
|
.fingerprint = 0x659df2aa32a4b33f, // Changing this has security and trust implications.
|
||||||
|
.minimum_zig_version = "0.14.1",
|
||||||
|
.dependencies = .{
|
||||||
|
.libqt6zig = .{
|
||||||
|
.url = "git+https://github.com/rcalixte/libqt6zig#8d1561a2a1e34f6818e4afdb6028ddfe1dcee4d4",
|
||||||
|
.hash = "libqt6zig-6.4.2-OSXtXCItfQgnNBvZOhUDSl9QEqLIsmpGn2vf5ZjBFDdw",
|
||||||
|
.lazy = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.paths = .{
|
||||||
|
"build.zig",
|
||||||
|
"build.zig.zon",
|
||||||
|
"client",
|
||||||
|
"common",
|
||||||
|
"server",
|
||||||
|
},
|
||||||
|
}
|
43
client/build.zig
Normal file
43
client/build.zig
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
pub fn build(
|
||||||
|
b: *std.Build,
|
||||||
|
target: std.Build.ResolvedTarget,
|
||||||
|
optimize: std.builtin.OptimizeMode,
|
||||||
|
) *std.Build.Step.Compile {
|
||||||
|
const qt6zig_ = b.lazyDependency("libqt6zig", .{
|
||||||
|
.target = target,
|
||||||
|
.optimize = .ReleaseFast,
|
||||||
|
});
|
||||||
|
|
||||||
|
const mod = b.createModule(.{
|
||||||
|
.root_source_file = b.path("client/src/main.zig"),
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
|
||||||
|
const step = b.addExecutable(.{
|
||||||
|
.name = "chat.client",
|
||||||
|
.root_module = mod,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (qt6zig_) |qt6zig| {
|
||||||
|
step.root_module.addImport("libqt6zig", qt6zig.module("libqt6zig"));
|
||||||
|
step.root_module.linkLibrary(qt6zig.artifact("qapplication"));
|
||||||
|
step.root_module.linkLibrary(qt6zig.artifact("qwidget"));
|
||||||
|
step.root_module.linkSystemLibrary("Qt6Core", .{});
|
||||||
|
step.root_module.linkSystemLibrary("Qt6Gui", .{});
|
||||||
|
step.root_module.linkSystemLibrary("Qt6Widgets", .{});
|
||||||
|
}
|
||||||
|
|
||||||
|
const cmd = b.addRunArtifact(step);
|
||||||
|
cmd.step.dependOn(b.getInstallStep());
|
||||||
|
if (b.args) |args| {
|
||||||
|
cmd.addArgs(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
const run = b.step("run-client", "Run the chat client");
|
||||||
|
run.dependOn(&cmd.step);
|
||||||
|
|
||||||
|
return step;
|
||||||
|
}
|
6
client/src/main.zig
Normal file
6
client/src/main.zig
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
const std = @import("std");
|
||||||
|
const common = @import("common");
|
||||||
|
|
||||||
|
pub fn main() void {
|
||||||
|
common.print_test("client");
|
||||||
|
}
|
21
common/build.zig
Normal file
21
common/build.zig
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
pub fn build(
|
||||||
|
b: *std.Build,
|
||||||
|
target: std.Build.ResolvedTarget,
|
||||||
|
optimize: std.builtin.OptimizeMode,
|
||||||
|
) *std.Build.Step.Compile {
|
||||||
|
const mod = b.createModule(.{
|
||||||
|
.root_source_file = b.path("common/src/root.zig"),
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
|
||||||
|
const step = b.addLibrary(.{
|
||||||
|
.linkage = .static,
|
||||||
|
.name = "chat.common",
|
||||||
|
.root_module = mod,
|
||||||
|
});
|
||||||
|
|
||||||
|
return step;
|
||||||
|
}
|
5
common/src/root.zig
Normal file
5
common/src/root.zig
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
pub fn print_test(sender: []const u8) void {
|
||||||
|
std.log.debug("Message from {s}", .{ sender });
|
||||||
|
}
|
29
server/build.zig
Normal file
29
server/build.zig
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
pub fn build(
|
||||||
|
b: *std.Build,
|
||||||
|
target: std.Build.ResolvedTarget,
|
||||||
|
optimize: std.builtin.OptimizeMode,
|
||||||
|
) *std.Build.Step.Compile {
|
||||||
|
const mod = b.createModule(.{
|
||||||
|
.root_source_file = b.path("server/src/main.zig"),
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
|
||||||
|
const step = b.addExecutable(.{
|
||||||
|
.name = "chat.server",
|
||||||
|
.root_module = mod,
|
||||||
|
});
|
||||||
|
|
||||||
|
const cmd = b.addRunArtifact(step);
|
||||||
|
cmd.step.dependOn(b.getInstallStep());
|
||||||
|
if (b.args) |args| {
|
||||||
|
cmd.addArgs(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
const run = b.step("run-server", "Run the chat server");
|
||||||
|
run.dependOn(&cmd.step);
|
||||||
|
|
||||||
|
return step;
|
||||||
|
}
|
6
server/src/main.zig
Normal file
6
server/src/main.zig
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
const std = @import("std");
|
||||||
|
const common = @import("common");
|
||||||
|
|
||||||
|
pub fn main() void {
|
||||||
|
common.print_test("server");
|
||||||
|
}
|
Loading…
Reference in a new issue