Skip to content

Instantly share code, notes, and snippets.

@ssteinbach
Last active July 3, 2023 03:00
Show Gist options
  • Save ssteinbach/7b087fc83c6fc5923da8466f28ac28d3 to your computer and use it in GitHub Desktop.
Save ssteinbach/7b087fc83c6fc5923da8466f28ac28d3 to your computer and use it in GitHub Desktop.
Experimental build.zig for opentime
const std = @import("std");
const c_args = [_][]const u8{
"-std=c++17",
"-fno-sanitize=undefined",
};
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(
b: *std.Build
) void
{
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard optimization options allow the person running `zig build` to
// select 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 lib = b.addStaticLibrary(
.{
.name = "opentime",
.target = target,
.optimize = optimize,
}
);
lib.addIncludePath("..");
lib.linkLibC();
lib.linkLibCpp();
lib.addCSourceFiles(
&.{
"./rationalTime.cpp",
"./errorStatus.cpp",
"./timeRange.cpp",
"./timeTransform.cpp",
},
&c_args
);
// 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);
const exe = b.addExecutable(
.{
.name = "test_opentime",
.root_source_file = .{ .path = "../../tests/test_opentime.cpp" },
.target = target,
.optimize = optimize,
}
);
exe.addCSourceFiles(
&.{
"../../tests/utils.cpp",
},
&c_args
);
exe.addIncludePath("..");
exe.addIncludePath("../../tests");
exe.linkLibrary(lib);
exe.linkLibC();
exe.linkLibCpp();
b.installArtifact(exe);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment