Giter Site home page Giter Site logo

hello-zig-zon-pkg's Introduction

hello-zig-zon-pkg

This is just a way for myself to test out and document build.zig.zon style dependency management. This repository is a zig project that depends on this repository as a dependency.

A dependency in build.zig.zon system is effectively a namespace that's defined in the build.zig file, mapping arbitrary names to sources files (and other sources files they import).

// build.zig
// ...
pub fn build(b: *std.Build) void {
    _ = b.addModule(
        "mymodulename",
        .{ .source_file = .{ .path = "./src/hello.zig" } },
    );
}
// ...

A zig project can refer to a remote dependency with an arbitrary field name in the .dependencies field of build.zig.zon.

build.zig.zon

https://github.com/maxsei/use-hello-zig-zon-pkg/blob/b20efee8b4469f64e37f3498611ea93fed9497f7/build.zig.zon

.{
    .name = "jomammad",
    .version = "0.1.0",
    .dependencies = .{
        .hello = .{
            .url  = "https://github.com/maxsei/hello-zig-zon-pkg/archive/7b8f7278265a14e6879dd974bfe063a664524cb8.tar.gz",
            .hash = "1220aa2cf330fb36da40119277f3d99e979e2bf8bc5042cec1aaff067e4c669bfa4f",
        },
    },
}

and can be included in build.zig with:

    // ...
    const hello = b.dependency("hello", .{});
    // ...

From there a dependency's modules can be included in zig build artifacts

    exe.addModule("mymodulename", hello.module("hello"));
    b.installArtifact(exe);

And imported via

@import("mymodulename")

hello-zig-zon-pkg's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.