Proposing patch to Zig source

Hi,

I recently had a need to create a tar archive in my zig project.
Looking into std.tar I can see that there doesn’t exist a way to create an archive from the std lib just yet, so I figured that I might try to add that functionality.

I followed the “Building-Zig-on-Windows” wiki entry in language repo and have done roughly the following steps:

Summary
New-Item -Path . -Name "custom-zig" -ItemType Directory

$versionLine = (Invoke-RestMethod "https://raw.githubusercontent.com/ziglang/zig/master/ci/x86_64-windows-debug.ps1") -split "`n" |
  Where-Object { $_.StartsWith('$ZIG_LLVM_CLANG_LLD_NAME') }
$version = $versionLine.substring('$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-'.Length).TrimEnd('"')
Invoke-WebRequest "https://ziglang.org/deps/zig+llvm+lld+clang-x86_64-windows-gnu-$version.zip"
Expand-Archive -Path "zig+llvm+lld+clang-x86_64-windows-gnu-$version.zip" -DestinationPath "custom-zig"

Push-Location custom-zig

$devkit = (Get-Item "zig+llvm+lld+clang-x86_64-windows-gnu-$version" |
  Select-Object -ExpandProperty FullName) -replace '\\', '/'
git clone https://github.com/ziglang/zig.git
cmake .. -GNinja -DCMAKE_PREFIX_PATH="$devkit" `
  -DCMAKE_C_COMPILER="$devkit/bin/zig.exe;cc" `
  -DCMAKE_CXX_COMPILER="$devkit/bin/zig.exe;c++" `
  -DCMAKE_AR="$devkit/bin/zig.exe" `
  -DZIG_AR_WORKAROUND=ON `
  -DZIG_STATIC=ON `
  -DZIG_USE_LLVM_CONFIG=OFF

ninja install

stage3\bin\zig.exe build test

# After making local changes
stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib
# Together with 
stage4/bin/zig build test-std -Dskip-release -Dtest-filter="my test"

Pop-Location

I added functionality to create a rudimentary ustar tar archive to the std lib and am now wondering if someone would be willing to help me create a patch out of my changes.
I’ve tried to find documentation in the repository on how patches are made and submitted but have not been able to find any.

I don’t really know how to continue and any help would be greatly appreciated!

4 Likes

7 posts were split to a new topic: Should the standard library be “batteries included”?

Welcome @zodiac,

Patches are send using github pull requests in zig git repository.

Normally an issue is created in zig git repository, for discussion, before starting an implementation and sending a pull request.
Please note that you can publish your code as a zig module, independent from the zig standard library.

2 Likes

This is exactly that I was trying to say - more or less complex data formats / algorithms should not be placed into standard library.

Hi @dimdin,
Thank you for the response!

I’ve read up on GH PRs and if I understand correctly I’ll need to do the following.

  1. Fork main
  2. Create custom branch
  3. Apply changes
  4. Create pull request against ziglang/zig main

I can create an issue first in order to see if this is patch would be interesting.

I just want to clarify regarding the post that was split of Should the standard library be “batteries included”? that I only started integrating this feature into the std lib due to the std lib itself documenting “Tar archive format compression/decompression.”. Which I took to mean that it should (will eventually) support both reading and creating archives.

For me personally it would make sense to atleast add tar, gz and zip functionality into the std lib in order to create distributable packages that can be integrated with the build system without relying on any outstanding tools.

1 Like

I agree it makes sense to have tar in the std library. Creating an issue in the zig repository, explaining that you already have an implementation, is a good course of action.