{"id":13739151,"url":"https://github.com/haze/zigbo","last_synced_at":"2025-05-14T03:32:30.283Z","repository":{"id":110258542,"uuid":"592880292","full_name":"haze/zigbo","owner":"haze","description":"Zig build system graph output step","archived":false,"fork":false,"pushed_at":"2023-03-14T16:04:07.000Z","size":22,"stargazers_count":23,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-15T09:42:46.603Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/haze.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-01-24T18:27:18.000Z","updated_at":"2024-09-30T13:56:25.000Z","dependencies_parsed_at":"2024-04-17T03:50:11.758Z","dependency_job_id":"fd1bb6ea-9072-4613-8776-e0f3ac3acf43","html_url":"https://github.com/haze/zigbo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haze%2Fzigbo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haze%2Fzigbo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haze%2Fzigbo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haze%2Fzigbo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haze","download_url":"https://codeload.github.com/haze/zigbo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225275728,"owners_count":17448387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T04:00:26.366Z","updated_at":"2024-11-19T00:47:38.711Z","avatar_url":"https://github.com/haze.png","language":"Zig","funding_links":[],"categories":["Development Tools"],"sub_categories":[],"readme":"### what\nZigbo is a custom build step for the Zig build system. You can use this step to render a diagram of the Zig build graph.\n\n### example build graph (zigbo's)\n\n``` mermaid\nflowchart TD\n\tsubgraph tls_0 [Copy build artifacts to prefix path]\n\tstep_0[Opaque Top Level Step]\n\tstep_0 --\u003e step_1[\"InstallArtifactStep: (install zigbo)\\ndestination: build.InstallDir{ .lib = void }\"]\n\tstep_1 --\u003e step_2[\"LibExeObjStep (zigbo)\\nkind: lib\\nmode: Debug\\nlinkage: static\\nroot_src: '/Users/haze/Code/zigbo/src/main.zig'\"]\n\tend\n\tsubgraph tls_1 [Remove build artifacts from prefix path]\n\tstep_3[Opaque Top Level Step]\n\tend\n\tsubgraph tls_2 [Run library tests]\n\tstep_4[Opaque Top Level Step]\n\tstep_4 --\u003e step_5[\"LibExeObjStep (test)\\nkind: test\\nmode: Debug\\nroot_src: '/Users/haze/Code/zigbo/src/main.zig'\"]\n\tend\n\tsubgraph tls_3 [Output the build graph as a mermaid diagram]\n\tstep_6[Opaque Top Level Step]\n\tstep_6 --\u003e step_7[\"Opaque Custom Step (Graph Output)\"]\n\tend\n```\n\n### usage\nZigbo exports a `GraphOutputStep` comptime function, which accepts a type of a reader. You can use this to configure the output of the diagram. Below is a simple example of configuring a top level `graph` step to export the graph to stdout.\n\n``` zig\nconst stdout = std.io.getStdOut().writer();\nconst build_graph = zigbo.graphOutputStep(b, stdout);\nconst build_graph_step = b.step(\"graph\", \"Output the build graph as a mermaid diagram\");\nbuild_graph_step.dependOn(\u0026build_graph.step);\n```\n\nIf you have custom steps within your build graph, Zigbo by default cannot display all the details of your step (all of the information is opt-in). Below is an example of using a callback function to provide information for specific steps based on their step name.\n\n```zig\nbuild_graph.setCustomStepCallback(struct{\n    fn customCallback(step: *std.build.Step, writer: anytype) !?zigbo.GraphOutputWriteFnInstruction {\n        if (std.mem.startsWith(u8, step.name, \"has-\")) {\n            libressl_build.CDependencyTestStep.mermaidDescribe(step, writer) catch |err| {\n                try writer.print(\"error.{s}\", .{@errorName(err)});\n            };\n            return null;\n        } else if (std.mem.endsWith(u8, step.name, \"WideCDependencyStep\")) {\n            libressl_build.WideCDependencyStep.mermaidDescribe(step, writer) catch |err| {\n                try writer.print(\"error.{s}\", .{@errorName(err)});\n            };\n            return null;\n        } else if (std.mem.endsWith(u8, step.name, \"DeferredLibExeObjStep\")) {\n            libressl_build.DeferredLibExeObjStep.mermaidDescribe(step, writer) catch |err| {\n                try writer.print(\"error.{s}\", .{@errorName(err)});\n            };\n            return null;\n        }\n\n        return .use_default_implementation;\n    }\n}.customCallback);\n```\n\n### how\nThe Zig build system only asks you to not modify the build graph during \"maketime\" (build step execution). We are allowed to **READ** it then. Knowing this, we can traverse the build graph (in the same way that calling `make` would) and output a diagram (for now, only [mermaid](https://mermaid.js.org/#/)) allowing you to analyse, inspect, and digest your entire build graph.\n\n### who\nZigbo was originally written by [haze](https://github.com/haze) and donated to [InKryption](https://github.com/InKryption) for maintenance.\n\n### when\nZigbo was initially built between January 21st and January 24th.\n\n### where\nZigbo was proudly built in New York City.\n\n\u003csup\u003e\nLicensed under either of \u003ca href=\"LICENSE-APACHE\"\u003eApache License, Version\n2.0\u003c/a\u003e or \u003ca href=\"LICENSE-MIT\"\u003eMIT license\u003c/a\u003e at your option.\n\u003c/sup\u003e\n\n\u003cbr/\u003e\n\n\u003csub\u003e\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this package by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.\n\u003c/sub\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaze%2Fzigbo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaze%2Fzigbo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaze%2Fzigbo/lists"}