Skip to content

add inclusion/exclusion directives to build.zig.zon for deciding which files belong the package #14311

@andrewrk

Description

@andrewrk

Extracted from #14265.

The motivation for doing this is mirrors (#14291). Idea being that if you fetch a tarball, perhaps it does not contain any superfluous files, while the same package fetched via git protocol (#14295) does have some extra files that are not intended to be part of the package. Both URLs should work, and their hashes should be identical. This means some files should be excluded from the package.

I could see this going one of two ways:

...with exclusions:

.{
    // ...
    .excluded_files = .{
        ".gitignore",
        "/zig-cache",
        "build-*",
    },
    // ...
}

...or with inclusions:

.{
    // ...
    .included_files = .{
        "src/*.zig",
        "build.zig.zon",
    },
    // ...
}

Two open questions:

  • should it be via inclusions, via exclusions, or either one is allowed?
  • what should the default be, if no rules are present in the manifest file?

Either way, here is how fetching a package works:

  1. Fetch URL from any mirror into a directory of files in a temp directory.
  2. Apply inclusion/exclusion rules by deleting files from the file system.
  3. Hash each file in the full tree independently.
  4. Produce final hash from the hashes of each file, sorted by name (related: zig build package hashes are missing path names and executable bit for each file #14308).
  5. Rename temp directory into the global package cache into a directory named after the hash.

The guarantee should be upheld that if the hash matches, the file system should match exactly. This means that, since empty directories are not included in the hash, empty directories should be removed by step 2, along with the inclusion/exclusion rules.

Metadata

Metadata

Assignees

Labels

enhancementSolving this issue will likely involve adding new logic or components to the codebase.zig build systemstd.Build, the build runner, `zig build` subcommand, package management

Type

No type

Projects

Status

Uncategorized

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions