Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build.zig: generate entities using the provided APIs. #11

Merged
merged 2 commits into from
Jun 11, 2024
Merged

Conversation

kivikakk
Copy link
Owner

Fixes #10. I tried having the generate tool and JSON be in a tools/ subdirectory like https://ziglang.org/learn/build-system/#generating-zig-source-code suggests, but the tools/ directory didn't appear in the extracted tarball when trying to use it via zig fetch:

$ zig build
install
└─ install koino
   └─ zig build-exe koino Debug native
      └─ run generate_entities (entities.zig)
         └─ zig build-exe generate_entities Debug native 1 errors
error: unable to check cache: stat file '/Users/kivikakk/.cache/zig/p/1220036f4a401bbfaba059e978a2dc6bc73955f3b8e98358e0a41a351ec608d7bcfe/tools/generate_entities.zig' failed: FileNotFound
error: the following command failed with 1 compilation errors:
/Users/kivikakk/g/zig/build/stage3/bin/zig build-exe -ODebug -Mroot=/Users/kivikakk/.cache/zig/p/1220036f4a401bbfaba059e978a2dc6bc73955f3b8e98358e0a41a351ec608d7bcfe/tools/generate_entities.zig --cache-dir /Users/kivikakk/g/koino/.zig-cache --global-cache-dir /Users/kivikakk/.cache/zig --name generate_entities --listen=- 
Build Summary: 0/5 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ install koino transitive failure
   └─ zig build-exe koino Debug native transitive failure
      └─ run generate_entities (entities.zig) transitive failure
         └─ zig build-exe generate_entities Debug native 1 errors
error: the following build command failed with exit code 1:
/Users/kivikakk/g/koino/.zig-cache/o/14bee0b22d0c13d964d516c91c4db0c9/build /Users/kivikakk/g/zig/build/stage3/bin/zig /Users/kivikakk/g/koino /Users/kivikakk/g/koino/.zig-cache /Users/kivikakk/.cache/zig --seed 0xcbfc1d4b -Z0d66deaa38a2eaaa

I checked the tarball and it was fine, and I didn't see anything relevant in issues in Zig. Maybe it only extracts a src subdir (? seems overspecific), or maybe there's a way some dependency wasn't specified so it didn't get extracted into the cache, idk. This works fine for now.

The repetition of the module in build.zig is messy and can be refactored next time anyone cares to look at it!

kivikakk added 2 commits June 11, 2024 17:59
(The deps aren't coming with the module. Might need to make the module
itself depend on them more somehow.)
@kivikakk kivikakk merged commit 6c6ab63 into main Jun 11, 2024
8 checks passed
@kivikakk kivikakk deleted the genent branch June 11, 2024 15:16
@lun-4
Copy link
Contributor

lun-4 commented Jun 11, 2024

using a tools/ subdirectory possibly didn't work because I didn't expose it on build.zig.zon

    .paths = .{
        "entities.json",
        "build.zig",
        "build.zig.zon",
        "src",
        "LICENSE",
        "README.md",
    },

from the default build.zig.zon:

    // Specifies the set of files and directories that are included in this package.
    // Only files and directories listed here are included in the `hash` that
    // is computed for this package.
    // Paths are relative to the build root. Use the empty string (`""`) to refer to
    // the build root itself.
    // A directory listed here means that all files within, recursively, are included.
    .paths = .{
        // This makes *all* files, recursively, included in this package. It is generally
        // better to explicitly list the files and directories instead, to insure that
        // fetching from tarballs, file system paths, and version control all result
        // in the same contents hash.
        "",
        // For example...
        //"build.zig",
        //"build.zig.zon",
        //"src",
        //"LICENSE",
        //"README.md",
    },
}

@kivikakk
Copy link
Owner Author

Oh! TIL. I should probably learn that file format. Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

possibly use GeneratedFile interface
2 participants