Provide a build.zig utility that helps people make a build step for g…#14
Conversation
…enerating state graph
|
This will produce the following output ➜ zig-out git:(demo) ls
atm.dot bin cont.dot counter.dot todo.dot |
| .target = target, | ||
| .imports = &.{ | ||
| .{ .name = "polystate", .module = polystate.module("root") }, | ||
| .{ .name = b.allocator.dupe(u8, module_name) catch @panic("OOM"), .module = module }, |
There was a problem hiding this comment.
This dupe wasted my half day
milogreg
left a comment
There was a problem hiding this comment.
Nice, the core functionality looks good.
However, I think that we should actually have the function just return the install_dot_file, rather than adding it as a dependency to the install step. This gives the caller the freedom to add it to whichever step they choose (like if they just want to generate the graph when running zig build graph). It may also make sense to rename the function to addGraphFile, which reflects the new behavior better.
Also, if you wanted to be even more consistent with the std.Build API, you could split the generation of dot_file into another public function, giving you addGraphFile which generates dot_file and addInstallGraphFile which generates install_dot_file. This would give the user two options to choose depending on how much control they want.
|
new demo: sdzx-1/polystate-examples@24c4e65 ➜ zig-out git:(demo) tree .
.
├── bin
│ ├── atm
│ ├── cont
│ ├── counter
│ ├── data
│ │ └── FiraMono.ttf
│ └── todo
└── graphs
├── atm.dot
├── cont.dot
├── counter.dot
└── todo.dot
4 directories, 9 files
➜ polystate-examples git:(demo) zig build --summary all
Build Summary: 57/57 steps succeeded
install cached
├─ install data/FiraMono.ttf to bin/data/FiraMono.ttf cached
├─ install generated to counter.dot cached
│ └─ run exe _generate_graph_for_counter cached
│ └─ compile exe _generate_graph_for_counter Debug native cached 30ms MaxRSS:77M
│ ├─ options cached
│ ├─ WriteFile cached
│ ├─ compile lib glfw Debug native cached 27ms MaxRSS:77M
│ ├─ WriteFile cached
│ ├─ compile lib imgui Debug native cached 31ms MaxRSS:77M
│ ├─ WriteFile raylib.h cached
│ ├─ compile lib raylib Debug native cached 22ms MaxRSS:77M
│ │ ├─ run wayland-scanner (wayland-client-protocol.h) cached
│ │ ├─ run wayland-scanner (wayland-client-protocol-code.h) cached
│ │ ├─ run wayland-scanner (xdg-shell-client-protocol.h) cached
│ │ ├─ run wayland-scanner (xdg-shell-client-protocol-code.h) cached
│ │ ├─ run wayland-scanner (xdg-decoration-unstable-v1-client-protocol.h) cached
│ │ ├─ run wayland-scanner (xdg-decoration-unstable-v1-client-protocol-code.h) cached
│ │ ├─ run wayland-scanner (viewporter-client-protocol.h) cached
│ │ ├─ run wayland-scanner (viewporter-client-protocol-code.h) cached
│ │ ├─ run wayland-scanner (relative-pointer-unstable-v1-client-protocol.h) cached
│ │ ├─ run wayland-scanner (relative-pointer-unstable-v1-client-protocol-code.h) cached
│ │ ├─ run wayland-scanner (pointer-constraints-unstable-v1-client-protocol.h) cached
│ │ ├─ run wayland-scanner (pointer-constraints-unstable-v1-client-protocol-code.h) cached
│ │ ├─ run wayland-scanner (fractional-scale-v1-client-protocol.h) cached
│ │ ├─ run wayland-scanner (fractional-scale-v1-client-protocol-code.h) cached
│ │ ├─ run wayland-scanner (xdg-activation-v1-client-protocol.h) cached
│ │ ├─ run wayland-scanner (xdg-activation-v1-client-protocol-code.h) cached
│ │ ├─ run wayland-scanner (idle-inhibit-unstable-v1-client-protocol.h) cached
│ │ ├─ run wayland-scanner (idle-inhibit-unstable-v1-client-protocol-code.h) cached
│ │ ├─ WriteFile raygui.c cached
│ │ ├─ run wayland-scanner (wayland-client-protocol.h) (reused)
│ │ ├─ run wayland-scanner (wayland-client-protocol-code.h) (reused)
│ │ ├─ run wayland-scanner (xdg-shell-client-protocol.h) (reused)
│ │ ├─ run wayland-scanner (xdg-shell-client-protocol-code.h) (reused)
│ │ ├─ run wayland-scanner (xdg-decoration-unstable-v1-client-protocol.h) (reused)
│ │ ├─ run wayland-scanner (xdg-decoration-unstable-v1-client-protocol-code.h) (reused)
│ │ ├─ run wayland-scanner (viewporter-client-protocol.h) (reused)
│ │ ├─ run wayland-scanner (viewporter-client-protocol-code.h) (reused)
│ │ ├─ run wayland-scanner (relative-pointer-unstable-v1-client-protocol.h) (reused)
│ │ ├─ run wayland-scanner (relative-pointer-unstable-v1-client-protocol-code.h) (reused)
│ │ ├─ run wayland-scanner (pointer-constraints-unstable-v1-client-protocol.h) (reused)
│ │ ├─ run wayland-scanner (pointer-constraints-unstable-v1-client-protocol-code.h) (reused)
│ │ ├─ run wayland-scanner (fractional-scale-v1-client-protocol.h) (reused)
│ │ ├─ run wayland-scanner (fractional-scale-v1-client-protocol-code.h) (reused)
│ │ ├─ run wayland-scanner (xdg-activation-v1-client-protocol.h) (reused)
│ │ ├─ run wayland-scanner (xdg-activation-v1-client-protocol-code.h) (reused)
│ │ ├─ run wayland-scanner (idle-inhibit-unstable-v1-client-protocol.h) (reused)
│ │ ├─ run wayland-scanner (idle-inhibit-unstable-v1-client-protocol-code.h) (reused)
│ │ └─ WriteFile raygui.c (reused)
│ ├─ compile lib glfw Debug native (reused)
│ ├─ compile lib imgui Debug native (reused)
│ ├─ compile lib raylib Debug native (+38 more reused dependencies)
│ ├─ options cached
│ ├─ options cached
│ └─ options cached
├─ install counter cached
│ └─ compile exe counter Debug native cached 31ms MaxRSS:77M
│ ├─ WriteFile (reused)
│ ├─ compile lib glfw Debug native (reused)
│ ├─ WriteFile (reused)
│ ├─ compile lib imgui Debug native (reused)
│ ├─ WriteFile raylib.h (reused)
│ ├─ compile lib raylib Debug native (+38 more reused dependencies)
│ ├─ compile lib glfw Debug native (reused)
│ ├─ compile lib imgui Debug native (reused)
│ ├─ compile lib raylib Debug native (+38 more reused dependencies)
│ ├─ options (reused)
│ ├─ options (reused)
│ └─ options (reused)
├─ install generated to atm.dot cached
│ └─ run exe _generate_graph_for_atm cached
│ └─ compile exe _generate_graph_for_atm Debug native cached 31ms MaxRSS:73M
│ ├─ options cached
│ ├─ WriteFile (reused)
│ ├─ compile lib glfw Debug native (reused)
│ ├─ WriteFile (reused)
│ ├─ compile lib imgui Debug native (reused)
│ ├─ WriteFile raylib.h (reused)
│ ├─ compile lib raylib Debug native (+38 more reused dependencies)
│ ├─ compile lib glfw Debug native (reused)
│ ├─ compile lib imgui Debug native (reused)
│ ├─ compile lib raylib Debug native (+38 more reused dependencies)
│ ├─ options cached
│ ├─ options (reused)
│ └─ options (reused)
├─ install atm cached
│ └─ compile exe atm Debug native cached 25ms MaxRSS:77M
│ ├─ WriteFile (reused)
│ ├─ compile lib glfw Debug native (reused)
│ ├─ WriteFile (reused)
│ ├─ compile lib imgui Debug native (reused)
│ ├─ WriteFile raylib.h (reused)
│ ├─ compile lib raylib Debug native (+38 more reused dependencies)
│ ├─ compile lib glfw Debug native (reused)
│ ├─ compile lib imgui Debug native (reused)
│ ├─ compile lib raylib Debug native (+38 more reused dependencies)
│ ├─ options (reused)
│ ├─ options (reused)
│ └─ options (reused)
├─ install generated to cont.dot cached
│ └─ run exe _generate_graph_for_cont cached
│ └─ compile exe _generate_graph_for_cont Debug native cached 29ms MaxRSS:73M
│ ├─ options cached
│ ├─ WriteFile (reused)
│ ├─ compile lib glfw Debug native (reused)
│ ├─ WriteFile (reused)
│ ├─ compile lib imgui Debug native (reused)
│ ├─ WriteFile raylib.h (reused)
│ ├─ compile lib raylib Debug native (+38 more reused dependencies)
│ ├─ compile lib glfw Debug native (reused)
│ ├─ compile lib imgui Debug native (reused)
│ ├─ compile lib raylib Debug native (+38 more reused dependencies)
│ ├─ options cached
│ ├─ options (reused)
│ └─ options (reused)
├─ install cont cached
│ └─ compile exe cont Debug native cached 21ms MaxRSS:77M
│ ├─ WriteFile (reused)
│ ├─ compile lib glfw Debug native (reused)
│ ├─ WriteFile (reused)
│ ├─ compile lib imgui Debug native (reused)
│ ├─ WriteFile raylib.h (reused)
│ ├─ compile lib raylib Debug native (+38 more reused dependencies)
│ ├─ compile lib glfw Debug native (reused)
│ ├─ compile lib imgui Debug native (reused)
│ ├─ compile lib raylib Debug native (+38 more reused dependencies)
│ ├─ options (reused)
│ ├─ options (reused)
│ └─ options (reused)
├─ install generated to todo.dot cached
│ └─ run exe _generate_graph_for_todo cached
│ └─ compile exe _generate_graph_for_todo Debug native cached 31ms MaxRSS:77M
│ ├─ options cached
│ ├─ WriteFile (reused)
│ ├─ compile lib glfw Debug native (reused)
│ ├─ WriteFile (reused)
│ ├─ compile lib imgui Debug native (reused)
│ ├─ WriteFile raylib.h (reused)
│ ├─ compile lib raylib Debug native (+38 more reused dependencies)
│ ├─ compile lib glfw Debug native (reused)
│ ├─ compile lib imgui Debug native (reused)
│ ├─ compile lib raylib Debug native (+38 more reused dependencies)
│ ├─ options cached
│ ├─ options (reused)
│ └─ options (reused)
└─ install todo cached
└─ compile exe todo Debug native cached 26ms MaxRSS:74M
├─ WriteFile (reused)
├─ compile lib glfw Debug native (reused)
├─ WriteFile (reused)
├─ compile lib imgui Debug native (reused)
├─ WriteFile raylib.h (reused)
├─ compile lib raylib Debug native (+38 more reused dependencies)
├─ compile lib glfw Debug native (reused)
├─ compile lib imgui Debug native (reused)
├─ compile lib raylib Debug native (+38 more reused dependencies)
├─ options (reused)
├─ options (reused)
└─ options (reused)
|
…enerating state graph
demo: sdzx-1/polystate-examples@fd4fe89