Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add snapcraft.yaml #1056

Closed
wants to merge 2 commits into from
Closed

WIP: Add snapcraft.yaml #1056

wants to merge 2 commits into from

Conversation

jayschwa
Copy link
Sponsor Contributor

@jayschwa jayschwa commented Jun 5, 2018

Conclusion: Additions moved to https://github.com/jayschwa/zig-snapcraft.


This is a work-in-progress that packages the Zig toolchain for Ubuntu's new-ish package manager.

After setting up Snapcraft, this can be tested with:

snapcraft cleanbuild
snap install --classic --dangerous zig_git_amd64.snap

Snaps are just SquashFS files, so it can be inspected with unsquashfs -ls zig_git_amd64.snap.

@andrewrk
Copy link
Member

andrewrk commented Jun 5, 2018

Thanks for the PR. A couple questions -

We have automatic builds of a completely statically linked zig for linux on every master branch push. These come out to about 25MB and work on every Linux distro. What does Snapcraft provide over this? Does Snapcraft work for linux distros that do not follow the LFS such as NixOS?

Does it makes sense for this to be in a separate git repository?

@andrewrk
Copy link
Member

andrewrk commented Jun 5, 2018

Is there a subset of tests written purely in Zig that don't require development dependencies to be installed?

If you have a working zig compiler then you can run these tests:

zig test test/behavior.zig
zig test std/index.zig
zig test std/special/compiler_rt/index.zig

I would recommend not including the tests in the package, however. For example one of the compiler-rt tests is 10MB.

Should libzig_cpp.a and libembedded_lld_*.a be included? CMake appears to be installing them by default, but I don't see them being distributed in ziglang.org's tarballs.

These are part of the build process for building stage 2 and stage 3, but not intended to be distributed to zig users. (Also note that currently it is recommended to only distribute stage 1. See README.md for more details.)

@jayschwa
Copy link
Sponsor Contributor Author

jayschwa commented Jun 5, 2018

We have automatic builds of a completely statically linked zig for linux on every master branch push. These come out to about 25MB and work on every Linux distro.

The snap is currently 27MB. This should go down a bit once I remove the stage 2 and 3 stuff.

What does Snapcraft provide over this?

If hooked up to build.snapcraft.io, it will provide:

  • Easy [un]installation for users.
  • Automatic updates in the snap's "edge" channel whenever the master branch is updated.
  • Discoverability via "app stores".

It's basically the same reasons why you might provide Homebrew or apt-get support in addition to a basic tarball.

Does Snapcraft work for linux distros that do not follow the LFS such as NixOS?

I'm not sure.

If you have a working zig compiler then you can run these tests...

Cool, these tests pass with the toolchain packaged in the snap. I just wanted a way to double-check. I don't plan to package them.

@andrewrk
Copy link
Member

andrewrk commented Jun 5, 2018

If hooked up to build.snapcraft.io, it will provide:

This all sounds like good stuff to me. Thanks again

@andrewrk
Copy link
Member

andrewrk commented Jun 5, 2018

So it looks like what we would want to do is in the ci/linux_script, after all tests pass, after uploading the static tarball, do the build and push process for snapcraft.

@jayschwa
Copy link
Sponsor Contributor Author

jayschwa commented Jun 6, 2018

I rebased off latest master and pushed a new commit that includes only the stage 1 stuff in the package.

I've started playing with build.snapcraft.io on my fork with its webhook. I'll let you know how it goes.

@jayschwa
Copy link
Sponsor Contributor Author

jayschwa commented Jun 6, 2018

Oh, and somewhat of a tangent, but the set(ZIG_CPP_LIB_DIR "${CMAKE_BINARY_DIR}/zig_cpp") in CMake seems wrong to me. ZIG_CPP_LIB_DIR is used only for installation, but CMAKE_BINARY_DIR is the build directory. Because the snapcraft container uses /some/weird/directory for building and /other/thing for installation, CMake was installing the zig_cpp stuff into /other/thing/some/weird/directory/zig_cpp when I would expect it to be /other/thing/zig_cpp.

@andrewrk
Copy link
Member

andrewrk commented Jun 6, 2018

What you're observing here is a conflict between us wanting to use stage 1 only to build stage 2, but shipping stage 1 for now since stage 2/3 are not ready yet. In fact the default install directory for stage 1 is equal to the build directory, so it's intended that you "install" stage 1 before proceeding with stage 2, which needs to link against zig_cpp.a.

Once stage 2 and 3 are complete I'll revisit the build process and make sure it all makes sense.

@andrewrk
Copy link
Member

Is this still work in progress, or do you consider it ready to be merged?

@jayschwa
Copy link
Sponsor Contributor Author

jayschwa commented Jun 11, 2018

My preliminary test with build.snapcraft.io did not work, but I haven't had time to dig into it more. I think I read somewhere that they don't auto-build snaps with a classic confinement, but need to confirm.

@andrewrk
Copy link
Member

Alright so snapcraft sounds great, and I think it should go in a separate repo and be maintained by someone other than me. Feel free to request a git push hook if you want to get master branch push notifications.

@andrewrk andrewrk closed this Jun 12, 2018
@jayschwa
Copy link
Sponsor Contributor Author

Okay, sounds fine. Is there an existing repo for peripheral artifacts?

@andrewrk
Copy link
Member

There are some here: https://github.com/ziglang
Some are under user accounts, for example https://github.com/ice1000/zig-intellij/

I recommend doing a repo under your name as a proof of concept as a first step.

@jayschwa
Copy link
Sponsor Contributor Author

Configuration moved to https://github.com/jayschwa/zig-snapcraft

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.

None yet

2 participants