82 lines
2.9 KiB
Zig
82 lines
2.9 KiB
Zig
const std = @import("std");
|
|
const lambda_zig = @import("lambda_zig");
|
|
|
|
pub fn build(b: *std.Build) !void {
|
|
// Default to aarch64-linux for Lambda Graviton deployment
|
|
const target = b.standardTargetOptions(.{
|
|
.default_target = .{
|
|
.cpu_arch = .aarch64,
|
|
.os_tag = .linux,
|
|
},
|
|
});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
// Get lambda-zig dependency
|
|
const lambda_zig_dep = b.dependency("lambda_zig", .{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
|
|
// Get controlr dependency for rinnai module
|
|
const controlr_dep = b.dependency("controlr", .{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
|
|
// Create the main module
|
|
const main_module = b.createModule(.{
|
|
.root_source_file = b.path("src/main.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
|
|
// Add lambda_runtime import
|
|
main_module.addImport("lambda_runtime", lambda_zig_dep.module("lambda_runtime"));
|
|
// Add rinnai import from controlr
|
|
main_module.addImport("rinnai", controlr_dep.module("rinnai"));
|
|
|
|
// Create executable
|
|
const exe = b.addExecutable(.{
|
|
.name = "bootstrap", // Lambda requires the executable to be named "bootstrap"
|
|
.root_module = main_module,
|
|
});
|
|
|
|
b.installArtifact(exe);
|
|
|
|
// Configure Lambda build steps (awslambda_package, awslambda_deploy, etc.)
|
|
try lambda_zig.configureBuild(b, lambda_zig_dep, exe);
|
|
|
|
// ASK CLI deploy step for Alexa skill metadata
|
|
const ask_deploy_cmd = b.addSystemCommand(&.{
|
|
"bun", "x", "ask", "deploy", "--target", "skill-metadata",
|
|
});
|
|
const ask_deploy_step = b.step("ask_deploy", "Deploy Alexa skill metadata via ASK CLI");
|
|
ask_deploy_step.dependOn(&ask_deploy_cmd.step);
|
|
|
|
// Full deploy step - deploys both Lambda function and Alexa skill
|
|
const full_deploy_step = b.step("deploy", "Deploy Lambda function and Alexa skill");
|
|
// Lambda deploy (awslambda_deploy) is added by lambda_zig.configureBuild
|
|
// We need to get a reference to it - it's registered as "awslambda_deploy"
|
|
if (b.top_level_steps.get("awslambda_deploy")) |lambda_deploy| {
|
|
full_deploy_step.dependOn(&lambda_deploy.step);
|
|
}
|
|
full_deploy_step.dependOn(&ask_deploy_cmd.step);
|
|
|
|
// Test step - reuses the same target query, tests run via emulation or on native arm64
|
|
const test_module = b.createModule(.{
|
|
.root_source_file = b.path("src/main.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
test_module.addImport("lambda_runtime", lambda_zig_dep.module("lambda_runtime"));
|
|
test_module.addImport("rinnai", controlr_dep.module("rinnai"));
|
|
|
|
const main_tests = b.addTest(.{
|
|
.name = "test",
|
|
.root_module = test_module,
|
|
});
|
|
|
|
const run_main_tests = b.addRunArtifact(main_tests);
|
|
const test_step = b.step("test", "Run unit tests");
|
|
test_step.dependOn(&run_main_tests.step);
|
|
}
|