mach icon indicating copy to clipboard operation
mach copied to clipboard

build: types and packages are mess

Open alichraghi opened this issue 3 years ago • 4 comments

the goal of this issue is try to find out a way to not repeat codes in sub-projects and also build files for example same Options struct exist in ./build.zig and gpu/build.zig. or refAllDecls function (which is very useful for tests and we should consider to use it in other packages) has been declared twice in freetype and audio/soundio

alichraghi avatar Jul 12 '22 18:07 alichraghi

I think the reason for the code repetition was because we can't import from ../. For example we could have a build_utils.zig file with all the structs and functions commonly used in the build.zig files, but we wouldn't be able to import it.

Also, there is the fact that we are offering people the ability to use mach packages by themselves without adding all of mach. For example if someone wanted to use just mach-glfw it would still need that build_utils.zig.

PiergiorgioZagaria avatar Jul 12 '22 18:07 PiergiorgioZagaria

Yep what @PiergiorgioZagaria said is correct.

I will also say, copying a few hundred lines is often preferable over a dependency (repeating code is not a bad thing.) This is a non-issue from my viewpoint.

Have any issues been caused by this? (e.g. two copies actually becoming out of date and it being a problem)? If not, I'd suggest we just do nothing until that happens & then address only that instance of it.

emidoots avatar Jul 12 '22 19:07 emidoots

Have any issues been caused by this?

when hacking on #396, i had to use @bitCast while passing the exact same Options struct to gpu.testStep Mach is definitely going to get bigger, and with the increase of such problems, controlling code quality will become more difficult

hopefully zig's official package manager solves all those

alichraghi avatar Jul 13 '22 06:07 alichraghi

I agree those bitcasts between package parameters are an issue 👍 But I think they're caused by us using symlinks to load packages, not because of code duplication

emidoots avatar Jul 17 '22 16:07 emidoots

i think this can be closed as of https://github.com/hexops/mach/commit/fe4e721508ac7990b17d12c7f0c0f25a58f39d8d

alichraghi avatar Aug 21 '22 22:08 alichraghi