Skip to content

Add: Zig fetch support #4348

Open
Open
@kassane

Description

Is your feature request related to a problem? Please describe.

Hi @waruqi,

This is also the case with pkg-managers for other languages such as dub, conan, vcpkg, cargo...

zig 0.12.0-dev already has a fetch command to download packages and print the hash (multihash - sha256-2)

progress to release: https://github.com/ziglang/zig/milestone/23

Help:

fetch            Copy a package into global cache and print its hash

Wrong command:

$> zig fetch git+https://github.com/xmake-io/xmake                                                    
error: url field is missing an explicit ref
    note: try .url = "github.com/xmake-io/xmake#1a53bc8550214990846409c31bc1e96bdedc49f4",

Command fixed:

$> zig fetch git+https://github.com/xmake-io/xmake#1a53bc8550214990846409c31bc1e96bdedc49f4
122040fb6a7b8a56d46458edad58fd43525b6e8f964f60816d1f516f36dfd0817abb
# OR
$> zig fetch https://github.com/xmake-io/xmake/archive/1a53bc8550214990846409c31bc1e96bdedc49f4.tar.gz

$> ls $HOME/.cache/zig/p/122040fb6a7b8a56d46458edad58fd43525b6e8f964f60816d1f516f36dfd0817abb 
CHANGELOG.md  CODE_OF_CONDUCT.md  CONTRIBUTING.md  LICENSE.md  NOTICE.md  README.md  README_zh.md  configure  core  scripts  tests  xmake

Describe the solution you'd like

I would suggest adding support for zig fetch without the need for build.zig and build.zig.zon.

New zig env get:

$> zig env
{
 "zig_exe": "/home/kassane/zig/0.12.0-dev.1372+8457439a8/files/zig",
 "lib_dir": "zig/0.12.0-dev.1372+8457439a8/files/lib",
 "std_dir": "zig/0.12.0-dev.1372+8457439a8/files/lib/std",
 "global_cache_dir": "/home/kassane/.cache/zig",
 "version": "0.12.0-dev.1372+8457439a8",
 "target": "x86_64-linux.6.5.9...6.5.9-gnu.2.38",
 "env": {
  "ZIG_GLOBAL_CACHE_DIR": null,
  "ZIG_LOCAL_CACHE_DIR": null,
  "ZIG_LIB_DIR": null,
  "ZIG_LIBC": null,
  "ZIG_BUILD_RUNNER": null,
  "ZIG_VERBOSE_LINK": null,
  "ZIG_VERBOSE_CC": null,
  "ZIG_BTRFS_WORKAROUND": null,
  "CC": null,
  "NO_COLOR": null,
  "XDG_CACHE_HOME": null,
  "HOME": "/home/kassane"
 }
}

Overwrite ZIG_GLOBAL_CACHE_DIR to xmake

$> xmake create -l zig zig-pkg
$> cd zig-pkg
$> ZIG_GLOBAL_CACHE_DIR=$PWD/.xmake  zig fetch git+https://github.com/xmake-io/xmake#1a53bc8550214990846409c31bc1e96bdedc49f4
$>  ls .xmake/p/122040fb6a7b8a56d46458edad58fd43525b6e8f964f60816d1f516f36dfd0817abb 
CHANGELOG.md  CODE_OF_CONDUCT.md  CONTRIBUTING.md  LICENSE.md  NOTICE.md  README.md  README_zh.md  configure  core  scripts  tests  xmake

Describe alternatives you've considered

No response

Additional context

References

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions