-
-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
zigup 2024.05.05 (new formula) #202961
base: master
Are you sure you want to change the base?
zigup 2024.05.05 (new formula) #202961
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
class Zigup < Formula | ||
desc "Download and manage zig compilers" | ||
homepage "https://github.com/marler8997/zigup" | ||
url "https://github.com/marler8997/zigup/archive/refs/tags/v2024_05_05.tar.gz" | ||
sha256 "36bea57e38b7106e61095ff8625d44e0ff0821f79c0c485b36d231787b08b9a4" | ||
license "MIT-0" | ||
head do | ||
url "https://github.com/marler8997/zigup.git", branch: "master" | ||
depends_on "zig" => :build | ||
end | ||
|
||
depends_on "cmake" => :build # Required for zig build | ||
depends_on "llvm@17" => :build # Required for zig build | ||
depends_on "zstd" => :build # Required for zig build | ||
uses_from_macos "ncurses" => :build # Required for zig build | ||
uses_from_macos "zlib" => :build # Required for zig build | ||
|
||
# Older zig required to build tagged version | ||
# https://github.com/marler8997/zigup?tab=readme-ov-file#building-zigup | ||
resource "zig" do | ||
url "https://ziglang.org/download/0.12.1/zig-0.12.1.tar.xz" | ||
sha256 "cca0bf5686fe1a15405bd535661811fac7663f81664d2204ea4590ce49a6e9ba" | ||
end | ||
|
||
def install | ||
unless build.head? | ||
resource("zig").stage do | ||
ENV["NIX_LDFLAGS"] = ENV["HOMEBREW_RPATH_PATHS"].split(":").map { |p| "-rpath #{p}" }.join(" ") if OS.linux? | ||
|
||
args = ["-DZIG_STATIC_LLVM=ON"] | ||
args << "-DCMAKE_EXE_LINKER_FLAGS=-Wl,-ld_classic" if DevelopmentTools.clang_build_version >= 1500 | ||
if OS.linux? | ||
args << "-DCMAKE_C_COMPILER=#{Formula["llvm@16"].opt_bin}/clang" | ||
args << "-DCMAKE_CXX_COMPILER=#{Formula["llvm@16"].opt_bin}/clang++" | ||
end | ||
|
||
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args(install_prefix: buildpath/"zig") | ||
system "cmake", "--build", "build" | ||
system "cmake", "--install", "build" | ||
ENV.prepend_path "PATH", buildpath/"zig/bin" | ||
end | ||
end | ||
|
||
system "zig", "build", "-Doptimize=ReleaseSafe" | ||
bin.install "zig-out/bin/zigup" | ||
end | ||
|
||
test do | ||
assert_match "0", shell_output("#{bin}/zigup -h; echo $?") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need a test that exercises the some of the functionality of the app. Version checks or usage checks (foo --version or foo --help) are not sufficient, as explained in the formula cookbook. In most cases, a good test would involve running a simple test case: run #{bin}/foo input.txt.
Some advice for specific cases:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My bad, I actually meant to ask about this. The only functionality of this program that can be tested would be to download and install a Zig version with it. I was thinking it would be bad to have the test rely on an external resource, but I see you've mentioned that as one of your valid test cases. I'll get this fixed. |
||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really shouldn't build an old version of a dependency. We should wait with this formula until zigup supports a modern zig instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I thought as well, but Zig is a bit of a strange case. There are major releases about every 6 months that break older builds. I would think the ideal solution would be to implement a [email protected] recipe for this, but I doubt maintainers would want beta versioned recipes in the repo.
Initially, I thought I would make this recipe a head only build since that is kept up to date with Zig, but I read that wasn't allowed somewhere.
This method of downloading an older version was pulled from the fastfec formula.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't sound so strange to me, it just sounds like zigup isn't maintained to the standards that using Zig seems to require.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fastfec
built with the latestzig
when it was added -- we almost certainly would not have added it if it required an older version ofzig
at the time. Iffastfec
still fails to build with the latestzig
eventually, we will likely end up deprecating it soon.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, while this was being discussed, Zigup made a new release on the latest Zig. I'll get this updated to build on that.
This is why Zig seemed like a strange case to me. As Zig gains popularity, I think this situation is going to occur more and more until a stable Zig version is released.
Even though this package wouldn't have built for 6 months, I wouldn't have said the package is unmaintained. Brew only has Zig 0.13.0, but 0.12.1 is technically a newer version. I don't know if [email protected] would be allowed since it's a beta, but it is a stable version that programs still rely on.
With all of that said, I'm fine with any decision you guys come up with for those situations.