Compare commits
No commits in common. "fc71bbfaca3e014da4ab609148a072447e4d4fc8" and "3b14df88d517db42cdc725d02022d25eaca2f427" have entirely different histories.
fc71bbfaca
...
3b14df88d5
42
build.zig
42
build.zig
|
@ -9,16 +9,16 @@ pub fn build(b: *std.build.Builder) !void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
var exe = b.addExecutable(.{
|
var exe = b.addExecutable(.{
|
||||||
.name = "custom",
|
.name = "bootstrap",
|
||||||
.root_source_file = .{ .path = "src/main.zig" },
|
.root_source_file = .{ .path = "src/main.zig" },
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
|
||||||
b.installArtifact(exe);
|
|
||||||
|
|
||||||
try lambdaBuildOptions(b, exe);
|
try lambdaBuildOptions(b, exe);
|
||||||
|
|
||||||
|
b.installArtifact(exe);
|
||||||
|
|
||||||
// TODO: We can cross-compile of course, but stripping and zip commands
|
// TODO: We can cross-compile of course, but stripping and zip commands
|
||||||
// may vary
|
// may vary
|
||||||
// TODO: Add test
|
// TODO: Add test
|
||||||
|
@ -52,6 +52,14 @@ fn addArgs(allocator: std.mem.Allocator, original: []const u8, args: [][]const u
|
||||||
/// deploy depends on iam and package
|
/// deploy depends on iam and package
|
||||||
///
|
///
|
||||||
/// iam and package do not have any dependencies
|
/// iam and package do not have any dependencies
|
||||||
|
///
|
||||||
|
/// At the moment, there I do not see a way utilize the zig package manager to
|
||||||
|
/// add modules for build.zig itself. There is some thinking in this area:
|
||||||
|
/// https://github.com/ziglang/zig/issues/8070
|
||||||
|
///
|
||||||
|
/// But for now I think this is a copy/paste job
|
||||||
|
/// TODO: Move this code into another file (temporary)
|
||||||
|
/// TODO: Determine a way to use packages within build.zig (permanent)
|
||||||
pub fn lambdaBuildOptions(b: *std.build.Builder, exe: *std.Build.Step.Compile) !void {
|
pub fn lambdaBuildOptions(b: *std.build.Builder, exe: *std.Build.Step.Compile) !void {
|
||||||
// The rest of this function is currently reliant on the use of Linux
|
// The rest of this function is currently reliant on the use of Linux
|
||||||
// system being used to build the lambda function
|
// system being used to build the lambda function
|
||||||
|
@ -64,36 +72,16 @@ pub fn lambdaBuildOptions(b: *std.build.Builder, exe: *std.Build.Step.Compile) !
|
||||||
|
|
||||||
// Package step
|
// Package step
|
||||||
const package_step = b.step("package", "Package the function");
|
const package_step = b.step("package", "Package the function");
|
||||||
|
package_step.dependOn(b.getInstallStep());
|
||||||
|
// const function_zip = b.getInstallPath(exe.installed_path.?, "function.zip");
|
||||||
const function_zip = b.getInstallPath(.bin, "function.zip");
|
const function_zip = b.getInstallPath(.bin, "function.zip");
|
||||||
|
|
||||||
// TODO: allow use of user-specified exe names
|
// TODO: allow use of user-specified exe names
|
||||||
// TODO: Avoid use of system-installed zip, maybe using something like
|
// TODO: Avoid use of system-installed zip, maybe using something like
|
||||||
// https://github.com/hdorio/hwzip.zig/blob/master/src/hwzip.zig
|
// https://github.com/hdorio/hwzip.zig/blob/master/src/hwzip.zig
|
||||||
const zip = if (std.mem.eql(u8, "bootstrap", exe.out_filename))
|
const zip = try std.fmt.allocPrint(b.allocator, "zip -qj9 {s} {s}", .{ function_zip, b.getInstallPath(.bin, exe.out_filename) });
|
||||||
try std.fmt.allocPrint(b.allocator,
|
|
||||||
\\zip -qj9 {s} {s}
|
|
||||||
, .{
|
|
||||||
function_zip,
|
|
||||||
b.getInstallPath(.bin, "bootstrap"),
|
|
||||||
})
|
|
||||||
else
|
|
||||||
// We need to copy stuff around
|
|
||||||
try std.fmt.allocPrint(b.allocator,
|
|
||||||
\\cp {s} {s} && \
|
|
||||||
\\zip -qj9 {s} {s} && \
|
|
||||||
\\rm {s}
|
|
||||||
, .{
|
|
||||||
b.getInstallPath(.bin, exe.out_filename),
|
|
||||||
b.getInstallPath(.bin, "bootstrap"),
|
|
||||||
function_zip,
|
|
||||||
b.getInstallPath(.bin, "bootstrap"),
|
|
||||||
b.getInstallPath(.bin, "bootstrap"),
|
|
||||||
});
|
|
||||||
// std.debug.print("\nzip cmdline: {s}", .{zip});
|
|
||||||
defer b.allocator.free(zip);
|
defer b.allocator.free(zip);
|
||||||
var zip_cmd = b.addSystemCommand(&.{ "/bin/sh", "-c", zip });
|
package_step.dependOn(&b.addSystemCommand(&.{ "/bin/sh", "-c", zip }).step);
|
||||||
zip_cmd.step.dependOn(b.getInstallStep());
|
|
||||||
package_step.dependOn(&zip_cmd.step);
|
|
||||||
|
|
||||||
// Deployment
|
// Deployment
|
||||||
const deploy_step = b.step("deploy", "Deploy the function");
|
const deploy_step = b.step("deploy", "Deploy the function");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user