#Skip a Build.Step.Run when a file/folder exists
1 messages · Page 1 of 1 (latest)
just want to suggest some alternatives:
you could use the build.zig.zon file for fetching git repos
or you could use repo.addOutputDir to clone it into your cache, that way it will automatically just not run if that dir already exists (plus its fully managed by the build system now)
Im not entirely sure if what you want to do is possible?
you could check if the directory exist and conditionally make a step depend on that on that step
build.zig.zon NO. just no. I want to leave programming altogether when I touch that stuff
oh and you should probably use b.addSystemCommand instead of manually creating the run step like this
why lol
its incredibly simple
"simple"... proceeds to waste hours and hours in frustration
it hasn't been simple once for me. at all
not even once 😦
I would assume thats because you didnt take the time to understand it
I do not work with remote repos that are hard-pinned to a certain commit. I work locally, and .zon files just don't cooperate for that
you can use a local path for a dependency as well
I do not pin to hashes. I edit like every damn 2minutes
and then you dont need a hash
except zig fetch butchers that
it replaces the path
just dont use zig fetch then
zig fetch is meant for remote urls where you dont know the hash
"just don't use remote dependencies then" ... then why would I even use build.zon at all then? I would rather use git submodules for that
when did I say not to use remote dependencies
it will only overwrite what you ask it to
lets keep the .zon conversation for some other day. it hasn't been simple once, and I'm purposedly staying away from it before I leave this lang for the 4th time in frustration at build crap
i'm making progress this other way
I would rather stay here and work without suffering
when the package manager is stable I will reconsider. that is not today
it is stable, it hasnt changed since 0.12
and barely changed since 0.11
same thing happened with the buildsystem itself, and it made me quit the lang. but now its stable and decent, so now its usable. but the package manager is not there
either way its your choice not to use it
you could use repo.addOutputDir to clone it into your cache, that way it will automatically just not run if that dir already exists (plus its fully managed by the build system now)
Can you expand a bit on this? 🤔
I want to clone the repo in a certain location, so that I can use ./that/folder/binary.exe from there to do other things later on
will that not screw the goal?
it would but thats not a good way to do things
addOutputDirectoryArg will put it in cache and then return a LazyPath to the start of it
and everything else in the build system will expect a LazyPath anyway so it shouldnt change things too much
and it ensures that builds are fully hermatic builds (i.e if it builds once, it will always build because it does the same thing each time)
i see what you mean
it seems to capture stdout now
is there a way to make it not do that?
I need the user to see that the repository is being cloned, and then that the contents are being compiled
as in it doesnt print anything?
iirc if you use addSystemCommand the default is to not capture stdout
no idea what the defaults are with a manually created Run step
hm thats odd lemme see
maybe remove .zig-cache? it might not print anything just because its already cloned so it doesnt do anything
i did remove it everytime
yeah I cant see how to make it do it
it seems to be doing things in the right folders though
even if cloning errored
but now I have a problem, because its supposed to run a build.sh script inside that repo... which is always going to exist
so back to square1. how to make the buildsystem conditionally do things only when X or Y are true?
sidenote: I don't know why it said earlier that it errored. it actually completed 🤷♂️
youd want to do something like if (cond) some_step.dependOn(&repo.step)
yeah, just tested it. it does rebuild everytime, even if it shouldn't because the file already exists
how do you get cond to be if file.exists()?
actually you cant really because its a LazyPath that doesnt exist while build.zig is being executed
yeah im not sure, you could use some_run_step.addOutputFileArg
and thatll make it so that the build system understands that as long as the inputs dont change and the output file is there, it shouldnt rerun it
but now build.sh would need to actually accept that argument to know where to output the artifact