diff --git a/Library/Homebrew/dev-cmd/create.rb b/Library/Homebrew/dev-cmd/create.rb index b65ff8ad3b..d344b8255a 100644 --- a/Library/Homebrew/dev-cmd/create.rb +++ b/Library/Homebrew/dev-cmd/create.rb @@ -23,6 +23,8 @@ module Homebrew description: "Create a basic template for an Autotools-style build." switch "--cmake", description: "Create a basic template for a CMake-style build." + switch "--go-mod", + description: "Create a basic template for a Go-Modules-style build." switch "--meson", description: "Create a basic template for a Meson-style build." switch "--no-fetch", @@ -40,7 +42,7 @@ module Homebrew switch :force switch :verbose switch :debug - conflicts "--autotools", "--cmake", "--meson" + conflicts "--autotools", "--cmake", "--go-mod", "--meson" end end @@ -73,6 +75,8 @@ module Homebrew :autotools elsif args.meson? :meson + elsif args.go_mod? + :go_mod end if fc.name.nil? || fc.name.strip.empty? diff --git a/Library/Homebrew/formula_creator.rb b/Library/Homebrew/formula_creator.rb index d68cff67c7..e4396658f6 100644 --- a/Library/Homebrew/formula_creator.rb +++ b/Library/Homebrew/formula_creator.rb @@ -99,6 +99,8 @@ module Homebrew <% if mode == :cmake %> depends_on "cmake" => :build + <% elsif mode == :go_mod %> + depends_on "go" => :build <% elsif mode == :meson %> depends_on "meson" => :build depends_on "ninja" => :build @@ -116,6 +118,8 @@ module Homebrew "--disable-dependency-tracking", "--disable-silent-rules", "--prefix=\#{prefix}" + <% elsif mode == :go_mod %> + system "go", "build", "-o", "\#{bin}/\#{name}" <% elsif mode == :meson %> mkdir "build" do system "meson", "--prefix=\#{prefix}", ".." @@ -130,7 +134,7 @@ module Homebrew "--prefix=\#{prefix}" # system "cmake", ".", *std_cmake_args <% end %> - <% if mode != :meson %> + <% if mode != :meson and mode != :go_mod %> system "make", "install" # if this fails, try separate make/make install steps <% end %> end