Initial commit
This commit is contained in:
66
packages/js/build.zig
Normal file
66
packages/js/build.zig
Normal file
@@ -0,0 +1,66 @@
|
||||
const std = @import("std");
|
||||
|
||||
const version_file = @embedFile("vendor/VERSION");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const version_string = b.fmt("\"{s}\"", .{std.mem.trim(u8, version_file, " \n\t")});
|
||||
|
||||
// --- QuickJS module ---
|
||||
|
||||
const mod = b.addModule("js", .{
|
||||
.root_source_file = b.path("src/root.zig"),
|
||||
.link_libc = true,
|
||||
.target = target,
|
||||
});
|
||||
|
||||
mod.addCSourceFiles(.{
|
||||
.files = &.{
|
||||
"vendor/cutils.c",
|
||||
"vendor/dtoa.c",
|
||||
"vendor/libregexp.c",
|
||||
"vendor/libunicode.c",
|
||||
"vendor/quickjs-libc.c",
|
||||
"vendor/quickjs.c",
|
||||
},
|
||||
.flags = &.{
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Wno-sign-compare",
|
||||
"-Wno-missing-field-initializers",
|
||||
"-Wundef",
|
||||
"-Wuninitialized",
|
||||
"-Wunused",
|
||||
"-Wno-unused-parameter",
|
||||
"-Wwrite-strings",
|
||||
"-Wchar-subscripts",
|
||||
"-funsigned-char",
|
||||
"-fwrapv",
|
||||
},
|
||||
});
|
||||
|
||||
mod.addCMacro("_GNU_SOURCE", "");
|
||||
mod.addCMacro("CONFIG_VERSION", version_string);
|
||||
|
||||
if (target.result.os.tag == .windows) {
|
||||
mod.addCMacro("__USE_MINGW_ANSI_STDIO", "");
|
||||
}
|
||||
|
||||
mod.linkSystemLibrary("m", .{});
|
||||
mod.linkSystemLibrary("pthread", .{});
|
||||
|
||||
if (target.result.os.tag != .windows) {
|
||||
mod.linkSystemLibrary("dl", .{});
|
||||
}
|
||||
|
||||
// --- Tests ---
|
||||
|
||||
const mod_tests = b.addTest(.{
|
||||
.root_module = mod,
|
||||
});
|
||||
|
||||
const run_mod_tests = b.addRunArtifact(mod_tests);
|
||||
|
||||
const test_step = b.step("test", "Run tests");
|
||||
test_step.dependOn(&run_mod_tests.step);
|
||||
}
|
||||
Reference in New Issue
Block a user