capy-ui / capy

💻Build one codebase and get native UI on Windows, Linux and Web
https://capy-ui.org
Mozilla Public License 2.0
1.61k stars 60 forks source link

Error when building #28

Closed shinymerlyn closed 1 year ago

shinymerlyn commented 1 year ago

Building on windows

Guessing it's due to this commit, or one nearby it: https://github.com/capy-ui/capy/commit/34bf939515504e4a1a63a6904e4afc4ce8d53a98

repro:

mkdir something
cd something
git clone https://github.com/capy-ui/zig-template .
zigmod fetch (repeat until it stops erroring. it errors the first time for me fairly often with "git clone https://github.com/capy-ui/capy failed")
zig build

expected: it builds without errors

actual:

C:\dev\something\.zigmod\deps\git\github.com\capy-ui\capy\android\Sdk.zig:431:39: error: expected error union type, found '[]u8'
        break :blk buf.toOwnedSlice() catch unreachable;
                   ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
referenced by:
    install: C:\dev\something\.zigmod\deps\git\github.com\capy-ui\capy\build_capy.zig:133:32
    build: C:\dev\something\build.zig:40:26
    remaining reference traces hidden; use '-freference-trace' to see all reference traces
zenith391 commented 1 year ago

Yea, it's caused by the fact that Capy always targets the latest Zig master version. The 34bf939 commit was made to fix compile errors introduced by the API change added in zig ceb0a63. To fix the bug, just download and install the latest Zig version from the website: https://ziglang.org/download/

shinymerlyn commented 1 year ago

The quick start docs don't say anything about targeting zig master. should I open a ticket for that?

alexkuz commented 1 year ago

@zenith391 I can't build the template with the latest Zig version either (0.11.0-dev.1594+a5d25fabd)

error: no field or member function named 'standardReleaseOptions' in 'Build'
    const mode = b.standardReleaseOptions();
                 ~^~~~~~~~~~~~~~~~~~~~~~~
/snap/zig/6551/lib/std/Build.zig:1:1: note: struct declared here
const std = @import("std.zig");
^~~~~
referenced by:
    runBuild__anon_5869: /snap/zig/6551/lib/std/Build.zig:1565:37
    main: /snap/zig/6551/lib/build_runner.zig:214:16
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

the relevant Zig commit, I believe: https://github.com/ziglang/zig/commit/063888afff75f9d91fd221d84e1b74b111304ac3

It would be indeed nicer if README explicitly mentions exact Zig version.

zenith391 commented 1 year ago

You might need to pull latest commits as this was fixed in 60cfed7

However you're right in that explicitly mentioning the exact Zig version would be better. I'll add this to the README.

alexkuz commented 1 year ago

@zenith391 the main repo is fixed, however the template still uses old format https://github.com/capy-ui/zig-template/blob/2a94b8a073c68a4dc04c12bda39a97418a652657/build.zig#L15

alexkuz commented 1 year ago

I'd also mention prerequisites somewhere (sudo apt install libgtk-3-dev in my case) Anyway, got it working, all good.