#Can a Module dependsOn a Step?

1 messages · Page 1 of 1 (latest)

crisp jewel
#

what does fetch-xz actually do?
does it fetch xz.zig?

dusk sierra
#

no, it fetches a release archive from xz with a bunch of c files

#

xz.zig is already on disk and in my repo at all times

#

its effectively zig bindings for xz compression

#

as std lib only has xz decompression

#

its doing the equivalent of putting a .tar.xz in a zig.zon, with some custom shenanigans in the process

crisp jewel
#

hm okay
what actually uses it?

#

I assume youre compiling the C files in it, right?
if so, you could just use addCSourceFiles with a LazyPath as the root
and that LazyPath can be generated based on the xz step

#

should just work™️

dusk sierra
#

thanks, I'll give it a go, im not exactly sure how to generate a lazypath based on a step

crisp jewel
#

youd use the generated field of the LazyPath union
but the easiest way for sure would be to just have the Run step generate it for you
you can have a addOutputDirectoryArg which tells that fetch executable which folder to unpack it into and then youd need to somehow give that lazy path to the user, not entirely sure how that would be done tbh

#

honestly I feel like theres a much better way to structure this

#

like maybe each build.zig could just import fetch.zig and call fetch.fetchArchive, “xz”) and then that returns both a LazyPath and a Step
something like that

dusk sierra
#

some reference of the madness, not important but here for myself in the future

#

hmm, that sounds sound to me

crisp jewel
#

well honestly is there a reason you arent just using the native package manager?
you can always pre-process it later

dusk sierra
#

one reason is it requires git beforehand

#

and im interested in building git myself

#

also this dumps archives into a folder that makes internal auditing much easier

crisp jewel
#

what requires git?

dusk sierra
#

my os

crisp jewel
#

wdym

dusk sierra
#

its a long story but my goal here is to build everything with zig as the only dependency

#

my fetch tool is capable of cloning repos and making archives from them

#

zig zon requires you have a git bin ahead of time

#

but one of the things my zig build builds is git itself

crisp jewel
#

are you sure about that?
im fairly sure it doesnt require git

dusk sierra
#

if you give it a git repo

#

but maybe not

#

i ran into issues with it that way, but the primary thing is

#

vendored archives i can audit better

crisp jewel
#

seems to have its own git implementation

dusk sierra
#

and i have an image making process that i can have it pull these into so i can do the entire thing airgapped

crisp jewel
#

I just feel like what youre doing is causing a lot of unnecessary friction

dusk sierra
#

it definitely is, and it would make sense to put my archives in the repo itself

#

but i don't want my git repo to be bloated in size, some of these archives are 50mb+

#

and this fits in a bigger system that has a non-zig component

#

that makes use of some of the same archives

#

its all ridiculous absolutely

#

but it 100% works as desired already, except for having to copy paste this fetch step dependsOn

crisp jewel
dusk sierra
#

aye, will be trying that now

crisp jewel
#

fwiw it might make sense to have something like a fetch_deps.py that google uses sometimes
just so you can do a zig run fetch_deps.zig or something and fetch everything
it doesnt need to be done lazily really

dusk sierra
#

having the fetch be part of the build system is incredibly convenient

#

being able to run zig build once and do everything is the goal

#

otherwise i'd have a makefile and just run make

#

a pointless goal? probably, but its been working well

crisp jewel
#

yeah thats fair
just worried about the “and this fits in a bigger system that has a non-zig component that makes use of some of the same archives” part
youd now need to ensure that everything is fetched before that non-zig component runs

dusk sierra
#

the first step in the entire system is a zig build

#

and if it fetches the things

#

i have nothing to worry about

crisp jewel
#

yeah I suppose thats fine then

dusk sierra
#

my zig builds go from source and then uses podman lib via go to build images that create an image that is capable of running the same zig build but airgapped as the archives are pre-seeded and my fetch.zig understands to not fetch if the archives exist

#

i've found this makes my ci images like 4mb which is fantastic

#

and a ci runner can simply mount a volume to get the pre-seeded archives

#

makes airgapped ci iteration super fast

#

and not needing gcc or any compiler except zig to build the go toolchain is also great