mirror of
https://github.com/jetzig-framework/jetzig.git
synced 2025-05-14 22:16:08 +00:00
WIP
This commit is contained in:
parent
b07f5adb8c
commit
72a704b8cb
24
build.zig
24
build.zig
@ -210,14 +210,21 @@ pub fn jetzigInit(b: *std.Build, exe: *std.Build.Step.Compile, options: JetzigIn
|
||||
exe_static_routes.root_module.addImport("jetzig", jetzig_module);
|
||||
exe_static_routes.root_module.addImport("zmpl", zmpl_module);
|
||||
exe_static_routes.root_module.addImport("main", main_module);
|
||||
// TODO: Prevent failure if schema file not present.
|
||||
const schema_module = b.createModule(.{ .root_source_file = b.path("src/app/database/Schema.zig") });
|
||||
|
||||
const schema_module = if (try isSourceFile(b, "src/app/database/Schema.zig"))
|
||||
b.createModule(.{ .root_source_file = b.path("src/app/database/Schema.zig") })
|
||||
else
|
||||
jetzig_dep.builder.createModule(
|
||||
.{ .root_source_file = jetzig_dep.builder.path("src/jetzig/DefaultSchema.zig") },
|
||||
);
|
||||
exe_static_routes.root_module.addImport("Schema", schema_module);
|
||||
exe.root_module.addImport("Schema", schema_module);
|
||||
|
||||
schema_module.addImport("jetzig", jetzig_module);
|
||||
|
||||
exe_static_routes.root_module.addImport("routes", routes_module);
|
||||
exe_static_routes.root_module.addImport("jetzig", jetzig_module);
|
||||
exe_static_routes.root_module.addImport("zmpl", zmpl_module);
|
||||
exe_static_routes.root_module.addImport("Schema", schema_module);
|
||||
|
||||
const markdown_fragments_write_files = b.addWriteFiles();
|
||||
const path = markdown_fragments_write_files.add("markdown_fragments.zig", try generateMarkdownFragments(b));
|
||||
@ -349,3 +356,14 @@ fn getMarkdownFragmentsSource(allocator: std.mem.Allocator, source: [:0]const u8
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
fn isSourceFile(b: *std.Build, path: []const u8) !bool {
|
||||
const dir = try std.fs.openDirAbsolute(b.build_root.path.?, .{});
|
||||
const stat = dir.statFile(path) catch |err| {
|
||||
switch (err) {
|
||||
error.FileNotFound => return false,
|
||||
else => return err,
|
||||
}
|
||||
};
|
||||
return stat.kind == .file;
|
||||
}
|
||||
|
1
src/jetzig/DefaultSchema.zig
Normal file
1
src/jetzig/DefaultSchema.zig
Normal file
@ -0,0 +1 @@
|
||||
// An empty schema imported when no `src/app/database/Schema.zig` is present.
|
@ -114,6 +114,7 @@ pub fn request(
|
||||
.cache = self.cache,
|
||||
.job_queue = self.job_queue,
|
||||
.global = undefined,
|
||||
.repo = undefined, // TODO - database test helpers
|
||||
};
|
||||
|
||||
try server.decodeStaticParams();
|
||||
|
Loading…
x
Reference in New Issue
Block a user