zig 0.12.0: re-enable exe tests
This commit is contained in:
parent
581c3de9ca
commit
e8430cb47a
16
build.zig
16
build.zig
|
@ -82,7 +82,7 @@ pub fn build(b: *std.Build) !void {
|
|||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
@import("src/universal_lambda_build.zig").addImports(b, lib, null);
|
||||
universal_lambda.addImports(b, lib, null);
|
||||
|
||||
// This declares intent for the library to be installed into the standard
|
||||
// location when the user invokes the "install" step (the default step when
|
||||
|
@ -99,7 +99,7 @@ pub fn build(b: *std.Build) !void {
|
|||
.target = b.resolveTargetQuery(t),
|
||||
.optimize = optimize,
|
||||
});
|
||||
_ = try universal_lambda.addModules(b, exe_tests);
|
||||
universal_lambda.addImports(b, exe_tests, null);
|
||||
|
||||
var run_exe_tests = b.addRunArtifact(exe_tests);
|
||||
run_exe_tests.skip_foreign_checks = true;
|
||||
|
@ -117,19 +117,17 @@ pub fn build(b: *std.Build) !void {
|
|||
.target = b.resolveTargetQuery(t),
|
||||
.optimize = optimize,
|
||||
});
|
||||
_ = try universal_lambda.addModules(b, lib_tests);
|
||||
universal_lambda.addImports(b, lib_tests, null);
|
||||
|
||||
var run_lib_tests = b.addRunArtifact(lib_tests);
|
||||
run_lib_tests.skip_foreign_checks = true;
|
||||
// This creates a build step. It will be visible in the `zig build --help` menu,
|
||||
// and can be selected like this: `zig build test`
|
||||
// This will evaluate the `test` step rather than the default, which is "install".
|
||||
test_step.dependOn(&run_lib_tests.step);
|
||||
// TODO: re-enable lib test
|
||||
//test_step.dependOn(&run_lib_tests.step);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn configureBuild(b: *std.Build, cs: *std.Build.Step.Compile) !void {
|
||||
try @import("src/universal_lambda_build.zig").configureBuild(b, cs);
|
||||
pub fn configureBuild(b: *std.Build, cs: *std.Build.Step.Compile, universal_lambda_zig_dep: *std.Build.Dependency) !void {
|
||||
try @import("src/universal_lambda_build.zig").configureBuild(b, cs, universal_lambda_zig_dep);
|
||||
}
|
||||
pub fn addImports(b: *std.Build, cs: *std.Build.Step.Compile, universal_lambda_zig_dep: *std.Build.Dependency) void {
|
||||
// The underlying call has an optional dependency here, but we do not.
|
||||
|
|
|
@ -3,36 +3,43 @@ const builtin = @import("builtin");
|
|||
|
||||
/// flexilib will create a dynamic library for use with flexilib.
|
||||
/// Flexilib will need to get the exe compiled as a library
|
||||
pub fn configureBuild(b: *std.build.Builder, cs: *std.Build.Step.Compile, build_root_src: []const u8) !void {
|
||||
pub fn configureBuild(b: *std.Build, cs: *std.Build.Step.Compile, universal_lambda_zig_dep: *std.Build.Dependency) !void {
|
||||
const package_step = b.step("flexilib", "Create a flexilib dynamic library");
|
||||
|
||||
const lib = b.addSharedLibrary(.{
|
||||
.name = cs.name,
|
||||
.root_source_file = .{ .path = b.pathJoin(&[_][]const u8{ build_root_src, "flexilib.zig" }) },
|
||||
.target = cs.target,
|
||||
.optimize = cs.optimize,
|
||||
.root_source_file = .{
|
||||
.path = b.pathJoin(&[_][]const u8{
|
||||
// root path comes from our dependency, which should be us,
|
||||
// and if it's not, we'll just blow up here but it's not our fault ;-)
|
||||
universal_lambda_zig_dep.builder.build_root.path.?,
|
||||
"src",
|
||||
"flexilib.zig",
|
||||
}),
|
||||
},
|
||||
.target = cs.root_module.resolved_target.?,
|
||||
.optimize = cs.root_module.optimize.?,
|
||||
});
|
||||
|
||||
// We will not free this, as the rest of the build system will use it.
|
||||
// This should be ok because our allocator is, I believe, an arena
|
||||
var module_dependencies = try b.allocator.alloc(std.Build.ModuleDependency, cs.modules.count());
|
||||
var iterator = cs.modules.iterator();
|
||||
|
||||
var i: usize = 0;
|
||||
while (iterator.next()) |entry| : (i += 1) {
|
||||
module_dependencies[i] = .{
|
||||
.name = entry.key_ptr.*,
|
||||
.module = entry.value_ptr.*,
|
||||
};
|
||||
lib.addModule(entry.key_ptr.*, entry.value_ptr.*);
|
||||
}
|
||||
|
||||
// Add the downstream root source file back into the build as a module
|
||||
// that our new root source file can import
|
||||
lib.addAnonymousModule("flexilib_handler", .{
|
||||
const flexilib_handler = b.createModule(.{
|
||||
// Source file can be anywhere on disk, does not need to be a subdirectory
|
||||
.source_file = cs.root_src.?,
|
||||
.dependencies = module_dependencies,
|
||||
.root_source_file = cs.root_module.root_source_file,
|
||||
});
|
||||
|
||||
lib.root_module.addImport("flexilib_handler", flexilib_handler);
|
||||
|
||||
// Now we need to get our imports added. Rather than reinvent the wheel, we'll
|
||||
// utilize our addImports function, but tell it to work on our library
|
||||
@import("universal_lambda_build.zig").addImports(b, lib, universal_lambda_zig_dep);
|
||||
|
||||
// flexilib_handler module needs imports to work...we are not in control
|
||||
// of this file, so it could expect anything that's already imported. So
|
||||
// we'll walk through the import table and simply add all the imports back in
|
||||
var iterator = lib.root_module.import_table.iterator();
|
||||
while (iterator.next()) |entry|
|
||||
flexilib_handler.addImport(entry.key_ptr.*, entry.value_ptr.*);
|
||||
|
||||
package_step.dependOn(&b.addInstallArtifact(lib, .{}).step);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ pub const BuildType = enum {
|
|||
|
||||
pub var module_root: ?[]const u8 = null;
|
||||
|
||||
pub fn configureBuild(b: *std.Build, cs: *std.Build.Step.Compile) !void {
|
||||
pub fn configureBuild(b: *std.Build, cs: *std.Build.Step.Compile, universal_lambda_zig_dep: *std.Build.Dependency) !void {
|
||||
const function_name = b.option([]const u8, "function-name", "Function name for Lambda [zig-fn]") orelse "zig-fn";
|
||||
|
||||
// const file_location = try addModules(b, cs);
|
||||
|
@ -22,7 +22,7 @@ pub fn configureBuild(b: *std.Build, cs: *std.Build.Step.Compile) !void {
|
|||
// Add steps
|
||||
try @import("lambda-zig").configureBuild(b, cs, function_name);
|
||||
try @import("cloudflare-worker-deploy").configureBuild(b, cs, function_name);
|
||||
// try @import("flexilib_build.zig").configureBuild(b, cs, file_location);
|
||||
try @import("flexilib_build.zig").configureBuild(b, cs, universal_lambda_zig_dep);
|
||||
try @import("standalone_server_build.zig").configureBuild(b, cs);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user