Build.zig rename orgy (aka: #16353). Renames FileSource to LazyPath and removes functions that take literal paths instead of LazyPath.

This commit is contained in:
Felix (xq) Queißner
2023-07-19 10:49:34 +02:00
committed by Andrew Kelley
parent 235e6ac05d
commit ce95a3b153
55 changed files with 337 additions and 329 deletions

View File

@@ -6,16 +6,18 @@ const Allocator = std.mem.Allocator;
pub const Style = union(enum) {
/// The configure format supported by autotools. It uses `#undef foo` to
/// mark lines that can be substituted with different values.
autoconf: std.Build.FileSource,
autoconf: std.Build.LazyPath,
/// The configure format supported by CMake. It uses `@@FOO@@` and
/// `#cmakedefine` for template substitution.
cmake: std.Build.FileSource,
cmake: std.Build.LazyPath,
/// Instead of starting with an input file, start with nothing.
blank,
/// Start with nothing, like blank, and output a nasm .asm file.
nasm,
pub fn getFileSource(style: Style) ?std.Build.FileSource {
pub const getFileSource = getPath; // DEPRECATED, use getPath
pub fn getPath(style: Style) ?std.Build.LazyPath {
switch (style) {
.autoconf, .cmake => |s| return s,
.blank, .nasm => return null,
@@ -54,7 +56,7 @@ pub fn create(owner: *std.Build, options: Options) *ConfigHeader {
var include_path: []const u8 = "config.h";
if (options.style.getFileSource()) |s| switch (s) {
if (options.style.getPath()) |s| switch (s) {
.path => |p| {
const basename = std.fs.path.basename(p);
if (std.mem.endsWith(u8, basename, ".h.in")) {
@@ -68,7 +70,7 @@ pub fn create(owner: *std.Build, options: Options) *ConfigHeader {
include_path = p;
}
const name = if (options.style.getFileSource()) |s|
const name = if (options.style.getPath()) |s|
owner.fmt("configure {s} header {s} to {s}", .{
@tagName(options.style), s.getDisplayName(), include_path,
})
@@ -98,7 +100,9 @@ pub fn addValues(self: *ConfigHeader, values: anytype) void {
return addValuesInner(self, values) catch @panic("OOM");
}
pub fn getFileSource(self: *ConfigHeader) std.Build.FileSource {
pub const getFileSource = getTemplate; // DEPRECATED, use getOutput
pub fn getTemplate(self: *ConfigHeader) std.Build.LazyPath {
return .{ .generated = &self.output_file };
}