diff options
| author | aura <nw@moneybot.cc> | 2026-02-17 22:39:42 +0100 |
|---|---|---|
| committer | aura <nw@moneybot.cc> | 2026-02-17 22:39:42 +0100 |
| commit | 636b0323075225c584b62719ed51e75521bb7ffb (patch) | |
| tree | 61b02271b6d0695a4beffc23fb6eb062a7da22c3 /backend/api/build.zig | |
push source
Diffstat (limited to 'backend/api/build.zig')
| -rw-r--r-- | backend/api/build.zig | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/backend/api/build.zig b/backend/api/build.zig new file mode 100644 index 0000000..986c83f --- /dev/null +++ b/backend/api/build.zig @@ -0,0 +1,66 @@ +const std = @import("std"); + +pub fn build( b: *std.Build ) void { + const target = b.standardTargetOptions( .{} ); + const optimize = b.standardOptimizeOption( .{} ); + + const opts = .{ .target = target, .optimize = optimize }; + + const exe = b.addExecutable(.{ + .name = "axonbox-backend", + .root_source_file = b.path( "src/main.zig" ), + .target = target, + .optimize = optimize, + }); + + const zap = b.dependency("zap", .{ + .target = target, + .optimize = optimize, + .openssl = true, // set to true to enable TLS support + } ); + + const jwt = b.dependency( "jwt", opts ); + const json = b.dependency( "json", opts ); + const uuid = b.dependency( "uuid", opts ); + const getty = b.dependency( "getty", opts ); + const tls12 = b.dependency( "tls12", opts ); + const sqlite = b.dependency( "sqlite", opts ); + const smtp = b.dependency( "smtp_client", opts ); + const websocket = b.dependency( "websocket", opts ); + + exe.root_module.addImport( "zap", zap.module( "zap" ) ); + exe.root_module.addImport( "jwt", jwt.module( "jwt" ) ); + exe.root_module.addImport( "json", json.module( "json" ) ); + exe.root_module.addImport( "uuid", uuid.module( "uuid" ) ); + exe.root_module.addImport( "getty", getty.module( "getty" ) ); + exe.root_module.addImport( "tls12", tls12.module( "zig-tls12" ) ); + exe.root_module.addImport( "sqlite", sqlite.module( "sqlite" ) ); + exe.root_module.addImport( "smtp_client", smtp.module( "smtp_client" ) ); + exe.root_module.addImport( "websocket", websocket.module( "websocket" ) ); + + //zls stuff + const check_exe = b.addExecutable(.{ + .name = "axonbox-backend", + .root_source_file = b.path( "src/main.zig" ), + .target = target, + .optimize = optimize, + }); + + for( exe.root_module.import_table.keys() ) |key| + check_exe.root_module.addImport( key, exe.root_module.import_table.get( key ) orelse unreachable ); + check_exe.linkLibrary( sqlite.artifact( "sqlite" ) ); + + const check = b.step( "check", "check compile result" ); + check.dependOn( &check_exe.step ); + + exe.linkLibrary( sqlite.artifact( "sqlite" ) ); + b.installArtifact( exe ); + const run_cmd = b.addRunArtifact( exe ); + run_cmd.step.dependOn( b.getInstallStep() ); + if( b.args ) |args| { + run_cmd.addArgs( args ); + } + + const run_step = b.step( "run", "Run the app" ); + run_step.dependOn( &run_cmd.step ); +} |
