#build error (solved)
1 messages · Page 1 of 1 (latest)
pub fn compile(
b: *Build,
step: anytype,
name: []const u8,
root_path: []const u8,
target: Target,
optimize: Mode,
) *Build.Step.Compile {
const comp = step(.{
.error_tracing = optimize == .ReleaseSafe or optimize == .Debug,
.strip = optimize == .ReleaseFast or optimize == .ReleaseSmall,
.unwind_tables = if (optimize == .Debug) .sync else .none,
.omit_frame_pointer = optimize != .Debug,
.root_source_file = b.path(root_path),
.optimize = optimize,
.target = target,
.name = name,
.pic = true,
});
comp.want_lto = !target.result.isDarwin(); // https://github.com/ziglang/zig/issues/8680
comp.compress_debug_sections = .zstd;
comp.link_function_sections = true;
comp.link_gc_sections = true;
return comp;
}
pub fn executable(b: *Build, name: []const u8, root_path: []const u8, target: Target, optimize: Mode) *Build.Step.Compile {
return compile(b, b.addExecutable, name, root_path, target, optimize);
}
/Users/p7r0x7/.cache/zig/p/122073200651ab9722dadf785236eeadadbc0861528a2e8aa00695927b93c47b8372/src/root.zig:49:25: error: no field named 'addExecutable' in struct 'Build'
return compile(b, b.addExecutable, name, root_path, target, optimize);
^~~~~~~~~~~~~
/Users/p7r0x7/zig/lib/std/Build.zig:1:1: note: struct declared here
const std = @import("std.zig");
^~~~~
referenced by:
build: /Users/p7r0x7/Documents/whixy/build.zig:24:33
runBuild__anon_4832: /Users/p7r0x7/zig/lib/std/Build.zig:2296:44
5 reference(s) hidden; use '-freference-trace=7' to see all references
/Users/p7r0x7/.cache/zig/p/122073200651ab9722dadf785236eeadadbc0861528a2e8aa00695927b93c47b8372/src/root.zig:53:25: error: no field named 'addStaticLibrary' in struct 'Build'
return compile(b, b.addStaticLibrary, name, root_path, target, optimize);
^~~~~~~~~~~~~~~~
/Users/p7r0x7/zig/lib/std/Build.zig:1:1: note: struct declared here
const std = @import("std.zig");
^~~~~
basically if you have
struct Foo = {
pub fn bar(self: u8) void {}
};
const foo: Foo = .{};
you can't actually do
const baz = foo.bar;```
because foo.bar isn't actually a thing
foo.bar() is, but it's just sugar for Foo.bar(foo)
so, to call compile in executable you need to do ts return compile(b, Build.addExecutable, name, root_path, target, optimize);
I see, I thought that wouldn't work correctly
and in compile itself you need to do
const comp = step(b, .{```
ah okay
yeah, if you came from javascript it could be trippy
because of this the object you call a .method() on actually matters
not in zig though, it just passes the thing as the first parameter implicitly
nah, been using zig a year, still don't get it, reimplementing my own zig