aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/Step/CheckObject.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-12-02 21:51:34 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-01-01 17:51:18 -0700
commit142471fcc46070326526e3976f0150fe734df0b6 (patch)
tree67d4dec7968cf6d6765cd3bc66524721cf0554d2 /lib/std/Build/Step/CheckObject.zig
parent579f572cf203eda11da7e4e919fdfc12e15f03e2 (diff)
downloadzig-142471fcc46070326526e3976f0150fe734df0b6.tar.gz
zig-142471fcc46070326526e3976f0150fe734df0b6.zip
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target query is what the user specifies, with some things left to default. A resolved target has the default things discovered and populated. In the future, std.zig.CrossTarget will be rename to std.Target.Query. Introduces `std.Build.resolveTargetQuery` to get from one to the other. The concept of `main_mod_path` is gone, no longer supported. You have to put the root source file at the module root now. * remove deprecated API * update build.zig for the breaking API changes in this branch * move std.Build.Step.Compile.BuildId to std.zig.BuildId * add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions, std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and std.Build.TestOptions. * remove `std.Build.constructCMacro`. There is no use for this API. * deprecate `std.Build.Step.Compile.defineCMacro`. Instead, `std.Build.Module.addCMacro` is provided. - remove `std.Build.Step.Compile.defineCMacroRaw`. * deprecate `std.Build.Step.Compile.linkFrameworkNeeded` - use `std.Build.Module.linkFramework` * deprecate `std.Build.Step.Compile.linkFrameworkWeak` - use `std.Build.Module.linkFramework` * move more logic into `std.Build.Module` * allow `target` and `optimize` to be `null` when creating a Module. Along with other fields, those unspecified options will be inherited from parent `Module` when inserted into an import table. * the `target` field of `addExecutable` is now required. pass `b.host` to get the host target.
Diffstat (limited to 'lib/std/Build/Step/CheckObject.zig')
-rw-r--r--lib/std/Build/Step/CheckObject.zig48
1 files changed, 26 insertions, 22 deletions
diff --git a/lib/std/Build/Step/CheckObject.zig b/lib/std/Build/Step/CheckObject.zig
index 3be9cdc83c..c5eb1f776b 100644
--- a/lib/std/Build/Step/CheckObject.zig
+++ b/lib/std/Build/Step/CheckObject.zig
@@ -44,11 +44,11 @@ pub fn create(
const SearchPhrase = struct {
string: []const u8,
- file_source: ?std.Build.LazyPath = null,
+ lazy_path: ?std.Build.LazyPath = null,
fn resolve(phrase: SearchPhrase, b: *std.Build, step: *Step) []const u8 {
- const file_source = phrase.file_source orelse return phrase.string;
- return b.fmt("{s} {s}", .{ phrase.string, file_source.getPath2(b, step) });
+ const lazy_path = phrase.lazy_path orelse return phrase.string;
+ return b.fmt("{s} {s}", .{ phrase.string, lazy_path.getPath2(b, step) });
}
};
@@ -321,14 +321,14 @@ pub fn checkExact(self: *CheckObject, phrase: []const u8) void {
/// Like `checkExact()` but takes an additional argument `LazyPath` which will be
/// resolved to a full search query in `make()`.
-pub fn checkExactPath(self: *CheckObject, phrase: []const u8, file_source: std.Build.LazyPath) void {
- self.checkExactInner(phrase, file_source);
+pub fn checkExactPath(self: *CheckObject, phrase: []const u8, lazy_path: std.Build.LazyPath) void {
+ self.checkExactInner(phrase, lazy_path);
}
-fn checkExactInner(self: *CheckObject, phrase: []const u8, file_source: ?std.Build.LazyPath) void {
+fn checkExactInner(self: *CheckObject, phrase: []const u8, lazy_path: ?std.Build.LazyPath) void {
assert(self.checks.items.len > 0);
const last = &self.checks.items[self.checks.items.len - 1];
- last.exact(.{ .string = self.step.owner.dupe(phrase), .file_source = file_source });
+ last.exact(.{ .string = self.step.owner.dupe(phrase), .lazy_path = lazy_path });
}
/// Adds a fuzzy match phrase to the latest created Check.
@@ -336,16 +336,20 @@ pub fn checkContains(self: *CheckObject, phrase: []const u8) void {
self.checkContainsInner(phrase, null);
}
-/// Like `checkContains()` but takes an additional argument `FileSource` which will be
+/// Like `checkContains()` but takes an additional argument `lazy_path` which will be
/// resolved to a full search query in `make()`.
-pub fn checkContainsPath(self: *CheckObject, phrase: []const u8, file_source: std.Build.LazyPath) void {
- self.checkContainsInner(phrase, file_source);
+pub fn checkContainsPath(
+ self: *CheckObject,
+ phrase: []const u8,
+ lazy_path: std.Build.LazyPath,
+) void {
+ self.checkContainsInner(phrase, lazy_path);
}
-fn checkContainsInner(self: *CheckObject, phrase: []const u8, file_source: ?std.Build.FileSource) void {
+fn checkContainsInner(self: *CheckObject, phrase: []const u8, lazy_path: ?std.Build.LazyPath) void {
assert(self.checks.items.len > 0);
const last = &self.checks.items[self.checks.items.len - 1];
- last.contains(.{ .string = self.step.owner.dupe(phrase), .file_source = file_source });
+ last.contains(.{ .string = self.step.owner.dupe(phrase), .lazy_path = lazy_path });
}
/// Adds an exact match phrase with variable extractor to the latest created Check.
@@ -353,16 +357,16 @@ pub fn checkExtract(self: *CheckObject, phrase: []const u8) void {
self.checkExtractInner(phrase, null);
}
-/// Like `checkExtract()` but takes an additional argument `FileSource` which will be
+/// Like `checkExtract()` but takes an additional argument `LazyPath` which will be
/// resolved to a full search query in `make()`.
-pub fn checkExtractFileSource(self: *CheckObject, phrase: []const u8, file_source: std.Build.FileSource) void {
- self.checkExtractInner(phrase, file_source);
+pub fn checkExtractLazyPath(self: *CheckObject, phrase: []const u8, lazy_path: std.Build.LazyPath) void {
+ self.checkExtractInner(phrase, lazy_path);
}
-fn checkExtractInner(self: *CheckObject, phrase: []const u8, file_source: ?std.Build.FileSource) void {
+fn checkExtractInner(self: *CheckObject, phrase: []const u8, lazy_path: ?std.Build.LazyPath) void {
assert(self.checks.items.len > 0);
const last = &self.checks.items[self.checks.items.len - 1];
- last.extract(.{ .string = self.step.owner.dupe(phrase), .file_source = file_source });
+ last.extract(.{ .string = self.step.owner.dupe(phrase), .lazy_path = lazy_path });
}
/// Adds another searched phrase to the latest created Check
@@ -371,16 +375,16 @@ pub fn checkNotPresent(self: *CheckObject, phrase: []const u8) void {
self.checkNotPresentInner(phrase, null);
}
-/// Like `checkExtract()` but takes an additional argument `FileSource` which will be
+/// Like `checkExtract()` but takes an additional argument `LazyPath` which will be
/// resolved to a full search query in `make()`.
-pub fn checkNotPresentFileSource(self: *CheckObject, phrase: []const u8, file_source: std.Build.FileSource) void {
- self.checkNotPresentInner(phrase, file_source);
+pub fn checkNotPresentLazyPath(self: *CheckObject, phrase: []const u8, lazy_path: std.Build.LazyPath) void {
+ self.checkNotPresentInner(phrase, lazy_path);
}
-fn checkNotPresentInner(self: *CheckObject, phrase: []const u8, file_source: ?std.Build.FileSource) void {
+fn checkNotPresentInner(self: *CheckObject, phrase: []const u8, lazy_path: ?std.Build.LazyPath) void {
assert(self.checks.items.len > 0);
const last = &self.checks.items[self.checks.items.len - 1];
- last.notPresent(.{ .string = self.step.owner.dupe(phrase), .file_source = file_source });
+ last.notPresent(.{ .string = self.step.owner.dupe(phrase), .lazy_path = lazy_path });
}
/// Creates a new check checking in the file headers (section, program headers, etc.).