Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zgt install with zigmod doesn't work #18

Closed
GoWind opened this issue Jul 22, 2022 · 3 comments
Closed

zgt install with zigmod doesn't work #18

GoWind opened this issue Jul 22, 2022 · 3 comments

Comments

@GoWind
Copy link

GoWind commented Jul 22, 2022

zig version : 0.10.0-dev.3050+e05487746
OS: 5.3.0-64-generic #58-Ubuntu SMP x86_64 GNU/Linux
zigmod: custom version with a commit on top of zigmod master to fix a breaking change in zig version mentioned above

Following instruction in the README, my zig build ends with the following error

./src/main.zig:6:12: error: container '.zgt' has no member called 'backend'
    try zgt.backend.init();

On closer inspection, it looks like the pkg root of zgt is set to .zigmod/deps/git/github/zenith391/zgt/build_zgt.zig.
Here is the deps.zig entry

pub const _deeztnhr07fk = Package{
        .directory = dirs._deeztnhr07fk,
        .pkg = Pkg{ .name = "zgt", .source = .{ .path = dirs._deeztnhr07fk ++ "/build_zgt.zig" }, .dependencies = null },
        .system_libs = &.{ "gtk+-3.0", "c" },
    };

build_zgt.zig is the main entrypoint in zgt's zigmod.yml file.

If however, I manually tweak this path to point to _deeztnhr07fk ++ "src/main.zig" instead of build_zgt.zig, it works fine. and I get a UI rendered on my desktop.

Did something change in zigmod or zig that broke this behaviour, or is the install fn in build_zgt.zig not supposed to be run, or is it supposed to run using an additional step such as deps.doSomething() ?

@GoWind
Copy link
Author

GoWind commented Jul 22, 2022

I see , commit introduced this change. perhaps this should be src/main.zig ?

@zenith391
Copy link
Member

Ah yes, I changed the way zgt should be installed. I'll change the instructions on the README very soon.
Meanwhile, like in zgt-template zgt must be added in build_dependencies, for simplicity you can just copy the file to your zigmod.yml.
After running zigmod fetch, add those lines in your build.zig (put them before exe.install()!):

const pathToZgt = ".zigmod/deps/git/github.com/zenith391/zgt/";
try deps.imports.zgt.install(exe, pathToZgt);

And then it should work!

The reason, I changed the way its done is because zgt needs to copy some files and link specific objects when compiling for Windows. Using zigmod's default capabilities it wasn't possible, so I spoke with nektro who suggested this new system.

@GoWind
Copy link
Author

GoWind commented Jul 23, 2022

I need not do this on Linux:

const pathToZgt = ".zigmod/deps/git/github.com/zenith391/zgt/";
try deps.imports.zgt.install(exe, pathToZgt);

Zigmod is emitting the right compiler flags for gtk and C without having to call the install method.
I guess the zgt.install workaround is more for Windows than for Linux at the moment !

Also, the imports struct in deps.zig is empty by default with zigmod

   pub const _s2cq94y1b4ve = Package{
        .directory = dirs._s2cq94y1b4ve,
    };
    pub const _deeztnhr07fk = Package{
        .directory = dirs._deeztnhr07fk,
        .pkg = Pkg{ .name = "zgt", .source = .{ .path = dirs._deeztnhr07fk ++ "/build_zgt.zig" }, .dependencies = null },
        .system_libs = &.{ "gtk+-3.0", "c" },
    };
    pub const _l21900j9ct9e = Package{
        .directory = dirs._l21900j9ct9e,        .pkg = Pkg{ .name = "ziglyph", .source = .{ .path = dirs._l21900j9ct9e ++ "/src/ziglyph.zig" }, .dependencies = null },
    };
    pub const _5r4tmy3ww54d = Package{
        .directory = dirs._5r4tmy3ww54d,
        .pkg = Pkg{ .name = "zigstr", .source = .{ .path = dirs._5r4tmy3ww54d ++ "/src/Zigstr.zig" }, .dependencies = &.{ _l21900j9ct9e.pkg.? } },
    };
    pub const _root = Package{
        .directory = dirs._root,
    };
};

pub const packages = &[_]Package{
    package_data._deeztnhr07fk,    package_data._5r4tmy3ww54d,
};

pub const pkgs = struct {
    pub const zgt = package_data._deeztnhr07fk;
    pub const zigstr = package_data._5r4tmy3ww54d;
};

pub const imports = struct {
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants