Skip to content

initial Zig 12 support#36

Draft
Jomy10 wants to merge 2 commits intoikskuh:masterfrom
Jomy10:master
Draft

initial Zig 12 support#36
Jomy10 wants to merge 2 commits intoikskuh:masterfrom
Jomy10:master

Conversation

@Jomy10
Copy link
Copy Markdown

@Jomy10 Jomy10 commented Sep 12, 2023

I started initial support for Zig 12 (and 11), but I can't figure out a few things.

Comment thread Sdk.zig
}
const os = builtin.os.tag;
const arch = builtin.cpu.arch;
return (comptime if (std.mem.eql(u8, @tagName(os), "macos")) "darwin" else @tagName(os)) ++ "-" ++ @tagName(arch);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

android uses "darwin" tag instead of "macos" as zig does.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect you're the first mac use to try this out! Thank you :)

Comment thread Sdk.zig
}
return;
},
std.builtin.Version => {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't found this type in the standard library, so I removed it for now

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zig 0.11.0 release notes address this: https://ziglang.org/download/0.11.0/release-notes.html#Language-Changes

  • Replaced builtin.Version with SemanticVersion.

Since SemanticVersion is already implemented below this code, we can go ahead and delete the std.builtin.Version case entirely.

Comment thread build/auto-detect.zig
// Check for a user config file.
if (std.fs.cwd().openFile(config_path, .{})) |file| {
defer file.close();
const bytes = file.readToEndAlloc(b.allocator, 1 * 1000 * 1000) catch |err| {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't figured out the new Json api, it's hard because I haven't used the previous one.

@Jomy10
Copy link
Copy Markdown
Author

Jomy10 commented Sep 12, 2023

I have added a few remarks.

@Jomy10
Copy link
Copy Markdown
Author

Jomy10 commented Sep 12, 2023

Currently getting following error when running zig build install -Dexample=egl (don't know if it's related to Zig 12):

Using android sdk at ANDROID_SDK_ROOT: /Users/jonaseveraert/Library/Android/sdk
Using android ndk at ANDROID_NDK_ROOT: /Users/jonaseveraert/Library/Android/sdk/ndk/25.1.8937393
Using java at /usr
New configuration:
SDK: /Users/jonaseveraert/Library/Android/sdk
NDK: /Users/jonaseveraert/Library/Android/sdk/ndk/25.1.8937393
JDK: /usr
WriteFile AndroidManifest.xml: error: FileNotFound: /Users/jonaseveraert/Documents/ZigAndroidTemplate/AndroidManifest.xml
WriteFile android-21-arm64.conf: error: FileNotFound: /Users/jonaseveraert/Documents/ZigAndroidTemplate/android-21-arm64.conf
WriteFile android-21-armeabi.conf: error: FileNotFound: /Users/jonaseveraert/Documents/ZigAndroidTemplate/android-21-armeabi.conf
WriteFile android-21-x86_64.conf: error: FileNotFound: /Users/jonaseveraert/Documents/ZigAndroidTemplate/android-21-x86_64.conf
WriteFile android-21-x86.conf: error: FileNotFound: /Users/jonaseveraert/Documents/ZigAndroidTemplate/android-21-x86.conf
WriteFile strings.xml: error: unable to update file from '/Users/jonaseveraert/Documents/ZigAndroidTemplate/strings.xml' to '/Users/jonaseveraert/Documents/ZigAndroidTemplate/zig-cache/o/ca315862017556b3d7c47fe1fe9ebd57/': FileNotFound

Comment thread build/auto-detect.zig Outdated
Co-authored-by: Nigel Baillie <nigel@baillie.dev>
@nacho00112
Copy link
Copy Markdown

how is the fork going? I can't just make this repository work no matter what zig version I use

@nacho00112
Copy link
Copy Markdown

@MasterQ32 @desttinghim
we need you please help, the repository is outdated and in a non-working state.
I'm sorry for tagging you but I wanted to make you to know it
as you are the repository maintainers and I still didn't mastered zig

@ikskuh
Copy link
Copy Markdown
Owner

ikskuh commented Nov 30, 2023

I'm sorry, i don't have time to review the code right now. I'm super busy doing RL stuff atm The file-not-founds are probably due to some misconfigured paths that aren't compatible with whatever changed. See how those paths are constructed in the code

@desttinghim
Copy link
Copy Markdown
Contributor

I may be able to take a look, most of my focus with Android at the moment is on my build tool cyborg though.

Copy link
Copy Markdown
Contributor

@desttinghim desttinghim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the changes to build.zig are done, there is still plenty of work needed to make everything compile on the 0.12 pre-release, but the changes should be fairly straightforward:

  • Change @alignCast() calls to remove the @alignOf() parameter being passed
  • Change var to const when the value is never mutated, the compiler should point out all of these

Comment thread Sdk.zig
}
return;
},
std.builtin.Version => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zig 0.11.0 release notes address this: https://ziglang.org/download/0.11.0/release-notes.html#Language-Changes

  • Replaced builtin.Version with SemanticVersion.

Since SemanticVersion is already implemented below this code, we can go ahead and delete the std.builtin.Version case entirely.

Comment thread Sdk.zig
const step = sdk.b.addWriteFile(fname, contents.items);
return step.getFileSource(fname) orelse unreachable;
// return step.getFileSource(fname) orelse unreachable;
return step.addCopyFile(.{ .path = fname }, "");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addCopyFile isn't the function you want here. We're already writing out the file using addWriteFile, we just need to get a FileSource from it. According to the message in the deprecated getFileSource() function, we need to use step.files.items[0].getPath() here.

Comment thread Sdk.zig
}
const os = builtin.os.tag;
const arch = builtin.cpu.arch;
return (comptime if (std.mem.eql(u8, @tagName(os), "macos")) "darwin" else @tagName(os)) ++ "-" ++ @tagName(arch);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect you're the first mac use to try this out! Thank you :)

@Jomy10
Copy link
Copy Markdown
Author

Jomy10 commented Dec 4, 2023

Thanks for the remarks! I'll look into them once I find the time, I'm also quite busy, but I should be able to find some free time to work on this.

@lassade
Copy link
Copy Markdown

lassade commented Dec 15, 2023

I did mange to build it using the zig 0.12.0-dev.1746+19af8aac8 but the opengl app is complete black, and the opensles header has a dependency loop (at least on android12, sdk 31) so I had disable it by default.

I used the build-tools 32.0.0, I think we should auto detect it and just use the highest installed version.

Do you guys whant to check it out? how do I push it? it was based on this work

Edit: I got it working but I'm getting adb: failed to install .\zig-out\bin\app-template.apk: Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Failed to collect certificates from /data/app/vmdl1770951165.tmp/base.apk: Attempt to get length of null array] whenever I change my app and try to run it on device, any Ideas?

Edit2: The install step was copying the apk before the singning

@desttinghim
Copy link
Copy Markdown
Contributor

@lassade this looks like some sort of signing issue, but I'm unable to tell what the actually issue is. Can you open a PR with the changes you made?

@lassade lassade mentioned this pull request Dec 18, 2023
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

Successfully merging this pull request may close these issues.

6 participants