Skip to content

std.Build.Step.InstallDir

Standard libraryZig 0.17.1Official documentation
Sourcestd/Build/Step/InstallDir.zig

Source line 1

Fields

step: Step
options: Options

std.Build.Step.InstallDir.base_tag

constant

Source line 12

Step.Tag

std.Build.Step.InstallDir.create

function

Source line 44

pub fn create(owner: *std.Build, options: Options) *InstallDir

Parameters

owner: *std.Build
options: Options

std.Build.Step.InstallDir.fs

alias

Source line 5

Alias of std.fs

std.Build.Step.InstallDir.InstallDir

alias

Source line 1

Alias of std.Build.Step.InstallDir

std.Build.Step.InstallDir.LazyPath

alias

Source line 7

Alias of std.Build.LazyPath

std.Build.Step.InstallDir.mem

alias

Source line 4

Alias of std.mem

std.Build.Step.InstallDir.Options

container

Source line 14

Fields

source_dir: LazyPath
install_dir: std.Build.InstallDir
install_subdir: []const u8
exclude_extensions: []const []const u8 = &.{}

File paths which end in any of these suffixes will be excluded from being installed.

include_extensions: ?[]const []const u8 = null

Only file paths which end in any of these suffixes will be included in installation. null means all suffixes are valid for this option. exclude_extensions take precedence over include_extensions

blank_extensions: []const []const u8 = &.{}

File paths which end in any of these suffixes will result in empty files being installed. This is mainly intended for large test.zig files in order to prevent needless installation bloat. However if the files were not present at all, then @import("test.zig") would be a compile error.

std.Build.Step.InstallDir.Options.dupe

function

Source line 32

fn dupe(opts: Options, graph: *const std.Build.Graph) Options

Parameters

opts: Options
graph: *const std.Build.Graph

std.Build.Step.InstallDir.std

alias

Source line 3

Alias of std

std.Build.Step.InstallDir.Step

alias

Source line 6

Alias of std.Build.Step

Source code

std/Build/Step/InstallDir.zig

const InstallDir = @This();

const std = @import("std");
const mem = std.mem;
const fs = std.fs;
const Step = std.Build.Step;
const LazyPath = std.Build.LazyPath;

step: Step,
options: Options,

pub const base_tag: Step.Tag = .install_dir;

pub const Options = struct {
    source_dir: LazyPath,
    install_dir: std.Build.InstallDir,
    install_subdir: []const u8,
    /// File paths which end in any of these suffixes will be excluded
    /// from being installed.
    exclude_extensions: []const []const u8 = &.{},
    /// Only file paths which end in any of these suffixes will be included
    /// in installation. `null` means all suffixes are valid for this option.
    /// `exclude_extensions` take precedence over `include_extensions`
    include_extensions: ?[]const []const u8 = null,
    /// File paths which end in any of these suffixes will result in
    /// empty files being installed. This is mainly intended for large
    /// test.zig files in order to prevent needless installation bloat.
    /// However if the files were not present at all, then
    /// `@import("test.zig")` would be a compile error.
    blank_extensions: []const []const u8 = &.{},

    fn dupe(opts: Options, graph: *const std.Build.Graph) Options {
        return .{
            .source_dir = opts.source_dir.dupe(graph),
            .install_dir = opts.install_dir.dupe(graph),
            .install_subdir = graph.dupeString(opts.install_subdir),
            .exclude_extensions = graph.dupeStrings(opts.exclude_extensions),
            .include_extensions = if (opts.include_extensions) |incs| graph.dupeStrings(incs) else null,
            .blank_extensions = graph.dupeStrings(opts.blank_extensions),
        };
    }
};

pub fn create(owner: *std.Build, options: Options) *InstallDir {
    const install_dir = owner.allocator.create(InstallDir) catch @panic("OOM");
    const graph = owner.graph;
    install_dir.* = .{
        .step = Step.init(.{
            .tag = base_tag,
            .name = owner.fmt("install {f}/", .{options.source_dir}),
            .owner = owner,
        }),
        .options = options.dupe(graph),
    };
    options.source_dir.addStepDependencies(&install_dir.step);
    return install_dir;
}