Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zig: Add cflags_extra option #607

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ pub fn build(b: *std.Build) void {
// TODO: support build_cord
const build_tests = b.option(bool, "build_tests",
"Build tests") orelse false;
const cflags_extra = b.option([]const u8, "CFLAGS_EXTRA",
"Extra cflags") orelse "";
// TODO: support enable_docs
const enable_threads = b.option(bool, "enable_threads",
"Support threads") orelse default_enable_threads;
Expand Down Expand Up @@ -153,6 +155,14 @@ pub fn build(b: *std.Build) void {
//"-Wno-long-long",
}) catch unreachable;

if (cflags_extra.len > 0) {
// Split it up on space (' ') and append each part separately to flags.
var tokenizer = std.mem.tokenizeScalar(u8, cflags_extra, ' ');
while (tokenizer.next()) |token| {
flags.append(token) catch unreachable;
}
}

source_files.appendSlice(&.{
"allchblk.c",
"alloc.c",
Expand Down
Loading