marlersoft / zigwin32gen

Generates Complete Zig bindings for Win32. See https://github.com/marlersoft/zigwin32 for the bindings themselves.
108 stars 17 forks source link

Unable to generate bindings #6

Closed kashifrazzaqui closed 3 years ago

kashifrazzaqui commented 3 years ago

Followed instructions on readme - throws an error.

W:\zigwin32gen>zig build genzig

loading 226 api json files... 1/226: loading 'AI.MachineLearning.DirectML.json' read 124465 bytes thread 12428 panic: reached unreachable code C:\Users\kashifr\scoop\apps\ziglang\current\lib\std\debug.zig:226:14: 0x7ff67cfe1078 in std.debug.assert (genzig.obj) if (!ok) unreachable; // assertion failure ^ W:\zigwin32gen\src\genzig.zig:1151:25: 0x7ff67d033c5a in CodeWriter::CodeWriter.writeBlock (genzig.obj) std.debug.assert(s[s.len-1] == '\n'); ^ W:\zigwin32gen\src\genzig.zig:670:26: 0x7ff67d01e1a7 in generateFile (genzig.obj) try writer.writeBlock( ^ W:\zigwin32gen\src\genzig.zig:579:21: 0x7ff67d00f867 in readAndGenerateApiFile (genzig.obj) try generateFile(module_dir, module, json_tree); ^ W:\zigwin32gen\src\genzig.zig:306:39: 0x7ff67cffe034 in main2 (genzig.obj) try readAndGenerateApiFile(root_module, out_win32_dir, api_json_basename, file); ^ W:\zigwin32gen\src\genzig.zig:210:17: 0x7ff67cfe47ce in main (genzig.obj) return main2() catch |e| switch (e) { ^ C:\Users\kashifr\scoop\apps\ziglang\current\lib\std\start.zig:458:37: 0x7ff67cfe36e4 in std.start.callMain (genzig.obj) const result = root.main() catch |err| { ^ C:\Users\kashifr\scoop\apps\ziglang\current\lib\std\start.zig:255:65: 0x7ff67cfe3037 in std.start.WinStartup (genzig.obj) std.os.windows.kernel32.ExitProcess(initEventLoopAndCallMain()); ^ Unable to dump stack trace: FileNotFound The following command exited with error code 2147483651 (expected 0): cd W:\zigwin32gen && W:\zigwin32gen\zig-out\bin\genzig.exe error: the following build command failed with exit code 1: W:\zigwin32gen\zig-cache\o\a6258a072a6104458bfca3ecccfdf019\build.exe C:\Users\kashifr\scoop\apps\ziglang\current\zig.exe W:\zigwin32gen W:\zigwin32gen\zig-cache C:\Users\kashifr\AppData\Local\zig genzig

marler8997 commented 3 years ago

It looks like the multiline string literal on lines 671 through 673 does not end in a \n character? Maybe this was a bug in an older version of the compiler? What compiler version are you using?

kashifrazzaqui commented 3 years ago

Thanks for looking at this. The version is 0.8.0

marler8997 commented 3 years ago

Ok I downloaded 0.8.0 to try to reproduce but it didn't reproduce for me. My next guess is this might have something to do with git's auto line ending translations for windows, but not sure how since the lines should still end with '\n'. Because I can't reproduce this I'll need your help to figure out what's going on in your environment.

Could you add these 3 lines to the start of your writeBlock function (around line 1150 in src\genzig.zig:

        if (s[s.len-1] != '\n') {
            std.log.err("BAD BLOCK: {}", .{std.fmt.fmtSliceHexLower(s)});
        }

Then send me the output that shows the BAD BLOCK line. This will tell me what the line ending actually is in your environment.

kashifrazzaqui commented 3 years ago

` W:\zigwin32gen>zig build

loading 226 api json files... 1/226: loading 'AI.MachineLearning.DirectML.json' read 124465 bytes error: BAD BLOCK: 0d0a74657374207b0d0a0d thread 19356 panic: reached unreachable code C:\Users\kashifr\scoop\apps\ziglang\current\lib\std\debug.zig:226:14: 0x7ff6e5bd1078 in std.debug.assert (genzig.obj) if (!ok) unreachable; // assertion failure ^ W:\zigwin32gen\src\genzig.zig:1139:25: 0x7ff6e5c23c77 in CodeWriter::CodeWriter.writeBlock (genzig.obj) std.debug.assert(s[s.len - 1] == '\n'); ^ W:\zigwin32gen\src\genzig.zig:659:26: 0x7ff6e5c0e1a7 in generateFile (genzig.obj) try writer.writeBlock( ^ W:\zigwin32gen\src\genzig.zig:569:21: 0x7ff6e5bff867 in readAndGenerateApiFile (genzig.obj) try generateFile(module_dir, module, json_tree); ^ W:\zigwin32gen\src\genzig.zig:301:39: 0x7ff6e5bee034 in main2 (genzig.obj) try readAndGenerateApiFile(root_module, out_win32_dir, api_json_basename, file); ^ W:\zigwin32gen\src\genzig.zig:209:17: 0x7ff6e5bd47ce in main (genzig.obj) return main2() catch |e| switch (e) { ^ C:\Users\kashifr\scoop\apps\ziglang\current\lib\std\start.zig:458:37: 0x7ff6e5bd36e4 in std.start.callMain (genzig.obj) const result = root.main() catch |err| { ^ C:\Users\kashifr\scoop\apps\ziglang\current\lib\std\start.zig:255:65: 0x7ff6e5bd3037 in std.start.WinStartup (genzig.obj) std.os.windows.kernel32.ExitProcess(initEventLoopAndCallMain()); ^ Unable to dump stack trace: FileNotFound The following command exited with error code 2147483651 (expected 0): cd W:\zigwin32gen && W:\zigwin32gen\zig-out\bin\genzig.exe error: the following build command failed with exit code 1: W:\zigwin32gen\zig-cache\o\a6258a072a6104458bfca3ecccfdf019\build.exe C:\Users\kashifr\scoop\apps\ziglang\current\zig.exe W:\zigwin32gen W:\zigwin32gen\zig-cache C:\Users\kashifr\AppData\Local\zig `

marler8997 commented 3 years ago

Ok it does look like it's probably an issue caused by git's autocrlf issue. I've created a workaround by removing all carriage returns from all multiline strings here: https://github.com/marlersoft/zigwin32gen/commit/117db030392c79a76ccdb7709f173a637c64d7bf

Try updating to the latest and see if it works now.

marler8997 commented 3 years ago

daurnimator on IRC also told me I can use .gitattributes to force *.zig file to use linefeed which I've added here: https://github.com/marlersoft/zigwin32gen/commit/faa4e74fb295cd4935cc7a4c07dfa8bed5b7e067

kashifrazzaqui commented 3 years ago

Ok it does look like it's probably an issue caused by git's autocrlf issue. I've created a workaround by removing all carriage returns from all multiline strings here: 117db03

Try updating to the latest and see if it works now.

This works, thanks

kashifrazzaqui commented 3 years ago

daurnimator on IRC also told me I can use .gitattributes to force *.zig file to use linefeed which I've added here: faa4e74

This doesn't