Add TCC project (as a library)
This commit is contained in:
73
packages/tcc/build.zig
Normal file
73
packages/tcc/build.zig
Normal file
@@ -0,0 +1,73 @@
|
||||
const std = @import("std");
|
||||
|
||||
const version_file = @embedFile("vendor/VERSION");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{
|
||||
.whitelist = &.{
|
||||
.{
|
||||
.cpu_arch = .x86_64,
|
||||
.os_tag = .windows,
|
||||
.abi = .msvc,
|
||||
},
|
||||
.{
|
||||
.cpu_arch = .aarch64,
|
||||
.os_tag = .windows,
|
||||
.abi = .msvc,
|
||||
},
|
||||
.{
|
||||
.cpu_arch = .x86_64,
|
||||
.os_tag = .linux,
|
||||
.abi = .gnu,
|
||||
},
|
||||
.{
|
||||
.cpu_arch = .aarch64,
|
||||
.os_tag = .linux,
|
||||
.abi = .gnu,
|
||||
},
|
||||
},
|
||||
});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
const version_string = b.fmt("\"{s}\"", .{std.mem.trim(u8, version_file, " \n\t")});
|
||||
|
||||
const mod = b.addModule("tcc", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/root.zig"),
|
||||
.link_libc = true,
|
||||
});
|
||||
|
||||
mod.addCSourceFiles(.{
|
||||
.files = &.{
|
||||
"vendor/libtcc.c",
|
||||
},
|
||||
.flags = &.{
|
||||
"-Wno-string-plus-int",
|
||||
"-fno-sanitize=alignment",
|
||||
"-fno-sanitize=shift",
|
||||
"-funsigned-char",
|
||||
},
|
||||
});
|
||||
|
||||
mod.addCMacro("TCC_VERSION", version_string);
|
||||
switch (target.result.cpu.arch) {
|
||||
.aarch64 => {
|
||||
mod.addCMacro("TCC_TARGET_ARM64", "");
|
||||
},
|
||||
.x86_64 => {
|
||||
mod.addCMacro("TCC_TARGET_X86_64", "");
|
||||
},
|
||||
else => unreachable,
|
||||
}
|
||||
|
||||
// --- 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