Moved config to libs
This commit is contained in:
parent
4f421f7977
commit
b075f8b89a
16
build.zig
16
build.zig
@ -1,7 +1,8 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
// Build part
|
||||
// Exe
|
||||
// -----------------------------------------------
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{ .preferred_optimize_mode = .ReleaseFast });
|
||||
|
||||
@ -15,13 +16,14 @@ pub fn build(b: *std.Build) void {
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
run_cmd.step.dependOn(b.getInstallStep());
|
||||
|
||||
// Import the dtype lib
|
||||
// Libs
|
||||
// -----------------------------------------------
|
||||
exe.root_module.addImport("dtype", b.createModule(.{ .root_source_file = b.path("lib/types/out.zig") }));
|
||||
|
||||
// Import ZipponData package
|
||||
exe.root_module.addImport("config", b.createModule(.{ .root_source_file = b.path("lib/config.zig") }));
|
||||
exe.root_module.addImport("ZipponData", b.createModule(.{ .root_source_file = b.path("lib/zid.zig") }));
|
||||
|
||||
// Run step
|
||||
// Run
|
||||
// -----------------------------------------------
|
||||
const run_step = b.step("run", "Run the app");
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
|
||||
@ -62,6 +64,7 @@ pub fn build(b: *std.Build) void {
|
||||
.name = "Schema tokenizer",
|
||||
.test_runner = b.path("test_runner.zig"),
|
||||
});
|
||||
tests4.root_module.addImport("config", b.createModule(.{ .root_source_file = b.path("lib/config.zig") }));
|
||||
tests4.root_module.addImport("dtype", b.createModule(.{ .root_source_file = b.path("lib/types/out.zig") }));
|
||||
const run_tests4 = b.addRunArtifact(tests4);
|
||||
|
||||
@ -73,6 +76,7 @@ pub fn build(b: *std.Build) void {
|
||||
.test_runner = b.path("test_runner.zig"),
|
||||
});
|
||||
tests5.root_module.addImport("dtype", b.createModule(.{ .root_source_file = b.path("lib/types/out.zig") }));
|
||||
tests5.root_module.addImport("config", b.createModule(.{ .root_source_file = b.path("lib/config.zig") }));
|
||||
tests5.root_module.addImport("ZipponData", b.createModule(.{ .root_source_file = b.path("lib/zid.zig") }));
|
||||
const run_tests5 = b.addRunArtifact(tests5);
|
||||
|
||||
@ -84,6 +88,7 @@ pub fn build(b: *std.Build) void {
|
||||
.test_runner = b.path("test_runner.zig"),
|
||||
});
|
||||
tests6.root_module.addImport("dtype", b.createModule(.{ .root_source_file = b.path("lib/types/out.zig") }));
|
||||
tests6.root_module.addImport("config", b.createModule(.{ .root_source_file = b.path("lib/config.zig") }));
|
||||
tests6.root_module.addImport("ZipponData", b.createModule(.{ .root_source_file = b.path("lib/zid.zig") }));
|
||||
const run_tests6 = b.addRunArtifact(tests6);
|
||||
|
||||
@ -104,6 +109,7 @@ pub fn build(b: *std.Build) void {
|
||||
.optimize = optimize,
|
||||
});
|
||||
benchmark.root_module.addImport("dtype", b.createModule(.{ .root_source_file = b.path("lib/types/out.zig") }));
|
||||
benchmark.root_module.addImport("config", b.createModule(.{ .root_source_file = b.path("lib/config.zig") }));
|
||||
benchmark.root_module.addImport("ZipponData", b.createModule(.{ .root_source_file = b.path("lib/zid.zig") }));
|
||||
b.installArtifact(benchmark);
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#### v0.4 - Usability
|
||||
- [ ] Server
|
||||
- [ ] Docker
|
||||
- [ ] Config file
|
||||
- [ ] YAML config file
|
||||
- [ ] Python interface
|
||||
- [ ] Go interface
|
||||
|
||||
|
@ -3,7 +3,7 @@ pub const MAX_FILE_SIZE = 1024 * 1024; // 1MB
|
||||
pub const CPU_CORE = 16;
|
||||
|
||||
// Testing
|
||||
pub const TEST_DATA_DIR = "data"; // Maybe put that directly in the build
|
||||
pub const TEST_DATA_DIR = "data";
|
||||
|
||||
// Debug
|
||||
pub const PRINT_STATE = false;
|
@ -24,7 +24,7 @@ const ConditionValue = @import("stuffs/filter.zig").ConditionValue;
|
||||
const ZipponError = @import("stuffs/errors.zig").ZipponError;
|
||||
const FileEngineError = @import("stuffs/errors.zig").FileEngineError;
|
||||
|
||||
const config = @import("config.zig");
|
||||
const config = @import("config");
|
||||
const BUFFER_SIZE = config.BUFFER_SIZE;
|
||||
const OUT_BUFFER_SIZE = config.OUT_BUFFER_SIZE;
|
||||
const MAX_FILE_SIZE = config.MAX_FILE_SIZE;
|
||||
|
@ -17,7 +17,7 @@ const ziqlParser = @import("ziqlParser.zig").Parser;
|
||||
|
||||
const ZipponError = @import("stuffs/errors.zig").ZipponError;
|
||||
|
||||
const config = @import("config.zig");
|
||||
const config = @import("config");
|
||||
const BUFFER_SIZE = config.BUFFER_SIZE;
|
||||
const CPU_CORE = config.CPU_CORE;
|
||||
const HELP_MESSAGE = config.HELP_MESSAGE;
|
||||
|
@ -16,7 +16,7 @@ const FileEngine = @import("fileEngine.zig").FileEngine;
|
||||
|
||||
// TODO: Create a schemaEngine directory and add this as core and the parser with it
|
||||
|
||||
const config = @import("config.zig");
|
||||
const config = @import("config");
|
||||
const BUFFER_SIZE = config.BUFFER_SIZE;
|
||||
|
||||
var schema_buffer: [BUFFER_SIZE]u8 = undefined;
|
||||
|
@ -1,5 +1,6 @@
|
||||
const std = @import("std");
|
||||
const ZipponError = @import("errors.zig").ZipponError;
|
||||
const config = @import("config");
|
||||
|
||||
const log = std.log.scoped(.utils);
|
||||
|
||||
@ -45,7 +46,7 @@ const stdout = std.io.getStdOut().writer();
|
||||
|
||||
// Maybe create a struct for that
|
||||
pub fn send(comptime format: []const u8, args: anytype) void {
|
||||
if (true) return;
|
||||
if (config.DONT_SEND) return;
|
||||
|
||||
stdout.print(format, args) catch |err| {
|
||||
log.err("Can't send: {any}", .{err});
|
||||
@ -57,6 +58,7 @@ pub fn send(comptime format: []const u8, args: anytype) void {
|
||||
|
||||
/// Print an error and send it to the user pointing to the token
|
||||
pub fn printError(message: []const u8, err: ZipponError, query: ?[]const u8, start: ?usize, end: ?usize) ZipponError {
|
||||
if (config.DONT_SEND) return err;
|
||||
fa.reset();
|
||||
|
||||
var buffer = std.ArrayList(u8).init(allocator);
|
||||
|
@ -6,8 +6,8 @@ const Pool = std.Thread.Pool;
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
||||
const ZipponError = @import("stuffs/errors.zig").ZipponError;
|
||||
const CPU_CORE = @import("config.zig").CPU_CORE;
|
||||
const OUT_BUFFER_SIZE = @import("config.zig").OUT_BUFFER_SIZE;
|
||||
const CPU_CORE = @import("config").CPU_CORE;
|
||||
const OUT_BUFFER_SIZE = @import("config").OUT_BUFFER_SIZE;
|
||||
const log = std.log.scoped(.thread);
|
||||
|
||||
const allocator = std.heap.page_allocator;
|
||||
|
@ -21,7 +21,7 @@ const printError = @import("stuffs/utils.zig").printError;
|
||||
const ZiQlParserError = @import("stuffs/errors.zig").ZiQlParserError;
|
||||
const ZipponError = @import("stuffs/errors.zig").ZipponError;
|
||||
|
||||
const PRINT_STATE = @import("config.zig").PRINT_STATE;
|
||||
const PRINT_STATE = @import("config").PRINT_STATE;
|
||||
|
||||
const log = std.log.scoped(.ziqlParser);
|
||||
|
||||
@ -1232,7 +1232,7 @@ test "DELETE" {
|
||||
const DBEngine = @import("main.zig").DBEngine;
|
||||
|
||||
fn testParsing(source: [:0]const u8) !void {
|
||||
const TEST_DATA_DIR = @import("config.zig").TEST_DATA_DIR;
|
||||
const TEST_DATA_DIR = @import("config").TEST_DATA_DIR;
|
||||
|
||||
var db_engine = DBEngine.init(TEST_DATA_DIR, null);
|
||||
defer db_engine.deinit();
|
||||
@ -1248,7 +1248,7 @@ fn testParsing(source: [:0]const u8) !void {
|
||||
}
|
||||
|
||||
fn expectParsingError(source: [:0]const u8, err: ZiQlParserError) !void {
|
||||
const TEST_DATA_DIR = @import("config.zig").TEST_DATA_DIR;
|
||||
const TEST_DATA_DIR = @import("config").TEST_DATA_DIR;
|
||||
|
||||
var db_engine = DBEngine.init(TEST_DATA_DIR, null);
|
||||
defer db_engine.deinit();
|
||||
@ -1273,7 +1273,7 @@ test "Parse filter" {
|
||||
}
|
||||
|
||||
fn testParseFilter(source: [:0]const u8) !void {
|
||||
const TEST_DATA_DIR = @import("config.zig").TEST_DATA_DIR;
|
||||
const TEST_DATA_DIR = @import("config").TEST_DATA_DIR;
|
||||
|
||||
var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
|
||||
defer arena.deinit();
|
||||
|
Loading…
x
Reference in New Issue
Block a user