[Thiago Cafe] Programming is fun!

Adding your rust project to brew

Created by Thiago Guedes on 2024-09-04 02:06:39

Tags:

This is a body example Please remove it and replace with your content

First, you need to create your tap (which can contain multiple applications)

brew tap-new myself/myapps

It creates a directory in /opt/homebrew/Library/Taps/myself/homebrew-myapps (that should go to github, to support auto discovery)

Then, create a new project

brew create --rust https://gitlab.com/myself/myrepo.git --HEAD --set-name 'myprojectname' --set-version '1.0.0' --tap myself/myapps

It will create a file Formula/myprojectname.rb

Add url

# Documentation: https://docs.brew.sh/Formula-Cookbook
#                https://rubydoc.brew.sh/Formula
# PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST!
class Myprojectname < Formula
  desc ""
  homepage ""
  url "https://gitlab.com/myself/myrepo.git", tag: "v1.0.0"
  license ""
  head "https://gitlab.com/myself/myrepo.git"

  depends_on "rust" => :build

  def install
    system "cargo", "install", *std_cargo_args
  end

  test do
    # `test do` will create, run in and delete a temporary directory.
    #
    # This test will fail and we won't accept that! For Homebrew/homebrew-core
    # this will need to be a test that verifies the functionality of the
    # software. Run the test with `brew test texted`. Options passed
    # to `brew install` such as `--HEAD` also need to be provided to `brew test`.
    #
    # The installed folder is not in the path, so use the entire path to any
    # executables being tested: `system bin/"program", "do", "something"`.
    system "false"
  end
end

To check for errors, run:

brew audit --new myprojectname

and to install, run:

brew tap myself/myapps
brew install myprojectname
# or
brew install myself/myapps/myprojectname

With this, when installing, it will be compiled from the source code. As soon as I decide to find how to install from a binary, I will add a new post here.

Tell me your opinion!

Reach me on Twitter - @thiedri