Skip to content

Commit

Permalink
zig tokenizer feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuawarner32 committed Feb 2, 2025
1 parent 0823fc9 commit 4e4fd8b
Show file tree
Hide file tree
Showing 3 changed files with 389 additions and 430 deletions.
29 changes: 4 additions & 25 deletions src/check/parse/tokenize/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,9 @@ pub fn build(b: *std.Build) void {
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});
const zg = b.dependency("zg", .{});

const lib = b.addStaticLibrary(.{
.name = "tokenize",
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});

// This declares intent for the library to be installed into the standard
// location when the user invokes the "install" step (the default step when
// running `zig build`).
b.installArtifact(lib);
// Zig unicode library - https://codeberg.org/atman/zg
const zg = b.dependency("zg", .{});

const exe = b.addExecutable(.{
.name = "tokenize",
Expand All @@ -37,6 +25,8 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});

// Unicode data is required for the tokenizer to work correctly.
// This is "general category" data - e.g. is this a lowercase letter, a digit, etc.
exe.root_module.addImport("GenCatData", zg.module("GenCatData"));

// This declares intent for the executable to be installed into the
Expand Down Expand Up @@ -67,16 +57,6 @@ pub fn build(b: *std.Build) void {
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);

// Creates a step for unit testing. This only builds the test executable
// but does not run it.
const lib_unit_tests = b.addTest(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});

const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);

const exe_unit_tests = b.addTest(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
Expand All @@ -89,6 +69,5 @@ pub fn build(b: *std.Build) void {
// the `zig build --help` menu, providing a way for the user to request
// running the unit tests.
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_lib_unit_tests.step);
test_step.dependOn(&run_exe_unit_tests.step);
}
Loading

0 comments on commit 4e4fd8b

Please sign in to comment.