-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig.zon
68 lines (59 loc) · 2.44 KB
/
build.zig.zon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const std = @import("std");
const json = @import("std").json;
const flags = [_][]const u8{
"-fno-sanitize=undefined",
};
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const lib = b.addStaticLibrary(.{
.name = "tree-sitter",
.target = target,
.optimize = optimize,
});
lib.linkLibC();
lib.linkLibCpp();
lib.addIncludePath(b.path("tree-sitter/lib/include"));
lib.addIncludePath(b.path("tree-sitter/lib/src"));
lib.addCSourceFiles(.{ .files = &.{"tree-sitter/lib/src/lib.c"}, .flags = &flags });
readJson(b, lib);
b.installArtifact(lib);
lib.installHeadersDirectory(b.path("tree-sitter/lib/include/tree_sitter"), "tree_sitter", .{});
const mod = b.addModule("treez", .{
.root_source_file = b.path("treez/treez.zig"),
});
mod.linkLibrary(lib);
}
fn readJson(b: *std.Build, lib: *std.Build.Step.Compile) void {
const json_location = "./modules.json";
//TODO: Read module.json and add module as install
}
// fn addParser(b: *std.Build, lib: *std.Build.Step.Compile, comptime lang: []const u8, comptime subdir: ?[]const u8) void {
// const basedir = "tree-sitter-" ++ lang;
// const srcdir = if (subdir) |sub| basedir ++ "/" ++ sub ++ "/src" else basedir ++ "/src";
// const qrydir = if (subdir) |sub| if (exists(b, basedir ++ "/" ++ sub ++ "/queries")) basedir ++ "/" ++ sub ++ "/queries" else basedir ++ "/queries" else basedir ++ "/queries";
// const parser = srcdir ++ "/parser.c";
// const scanner = srcdir ++ "/scanner.c";
// const scanner_cc = srcdir ++ "/scanner.cc";
//
// lib.addCSourceFiles(.{ .files = &.{parser}, .flags = &flags });
// if (exists(b, scanner_cc))
// lib.addCSourceFiles(.{ .files = &.{scanner_cc}, .flags = &flags });
// if (exists(b, scanner))
// lib.addCSourceFiles(.{ .files = &.{scanner}, .flags = &flags });
// lib.addIncludePath(b.path(srcdir));
//
// if (exists(b, qrydir)) {
// b.installDirectory(.{
// .source_dir = b.path(qrydir),
// .include_extensions = &[_][]const u8{".scm"},
// .install_dir = .{ .custom = "queries" },
// .install_subdir = lang,
// });
// }
// }
//
// fn exists(b: *std.Build, path: []const u8) bool {
// std.fs.cwd().access(b.pathFromRoot(path), .{ .mode = .read_only }) catch return false;
// return true;
// }