feat: hide json serialization behind compiler flag -Djson
This commit is contained in:
parent
32aa8b1de7
commit
e584ecd8a2
@ -5,10 +5,13 @@ pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
// Create options module for tracing
|
||||
// Create options module for conditional compilation
|
||||
const executionTracing = b.option(bool, "tracing", "enable execution tracing") orelse false;
|
||||
const json_serialization = b.option(bool, "json", "enable JSON serialization of the compiler outputs") orelse false;
|
||||
|
||||
const options = b.addOptions();
|
||||
options.addOption(bool, "tracing", executionTracing);
|
||||
options.addOption(bool, "json", json_serialization);
|
||||
|
||||
// Create the options module that will be shared
|
||||
const options_module = options.createModule();
|
||||
|
@ -5,7 +5,9 @@ const errors = @import("errors");
|
||||
|
||||
const cli = @import("cli.zig");
|
||||
|
||||
const tracing = @import("config").tracing;
|
||||
const config = @import("config");
|
||||
const tracing = config.tracing;
|
||||
const json = config.json;
|
||||
|
||||
const thp_version: []const u8 = "0.0.1";
|
||||
|
||||
@ -18,14 +20,18 @@ fn repl() !void {
|
||||
var args = std.process.args();
|
||||
defer args.deinit();
|
||||
|
||||
// If compiling for JSON serialization, enable the binary `lex` command
|
||||
|
||||
// ignore executable
|
||||
_ = args.next();
|
||||
if (args.next()) |arg| {
|
||||
if (json) {
|
||||
if (std.mem.eql(u8, "lex", arg)) {
|
||||
try cli.tokenize_to_json();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const stdout_file = std.io.getStdOut().writer();
|
||||
var bw = std.io.bufferedWriter(stdout_file);
|
||||
|
Loading…
Reference in New Issue
Block a user