#How to add a LazyPath include path to TranslateC step

1 messages · Page 1 of 1 (latest)

silent ridge
#

I have a single C header file that I use with conjunction b.addTranslateC to translate all header files in one step (also because of cImport removal from the language https://github.com/ziglang/zig/issues/20630).

I am trying to include freetype with the help of mach's freetype wrapper but I can't figure out how to add an include path to TranslateC .

// build.zig
pub fn build(b: *std.Build) void {
    // ...
    const dep_freetype = b.dependency("freetype2", .{
        .optimize = .ReleaseSafe,
        .enable_brotli = false,
    });
    const lib_freetype = dep_freetype.artifact("freetype");

    const c_headers = b.addTranslateC(.{
        .root_source_file = b.path("./src/c.h"),
        .target = target,
        .optimize = optimize,
        .link_libc = true,
    });
    // error: expected type '[]const u8', found 'Build.LazyPath'
    c_headers.addIncludeDir(dep_freetype.path("include"));

    // ...
// src/c.h
#include <SDL2/SDL.h>
#include <SDL2/SDL_vulkan.h>

#include <ft2build.h>
#include FT_FREETYPE_H
GitHub

A fork of freetype packaged for the Zig build system - GitHub - hexops/freetype: A fork of freetype packaged for the Zig build system

dense maple
#

the build systems translate c step is not yet sufficent to replace cimport due to missing functionality like this

austere ridge
#

the translate C step has been a bit neglected and hasn't yet been updated to take lazy paths everywhere

dense maple