brew create: add meson support

meson is quickly gaining popularity as build system, in combination with
ninja. Several Gnome projects for example are currently transitioning
from autotools to meson, mostly because it allows for Visual Studio
builds, which is impossible to accomplish with autotools.

In order to facilitate generating meson based Formulas, I added support
for meson to brew-create.
This commit is contained in:
Tom Schoonjans 2016-12-19 21:51:57 +01:00
parent 6b4de31504
commit cc09bb14c1
4 changed files with 23 additions and 7 deletions

View File

@ -1,4 +1,4 @@
#: * `create` <URL> [`--autotools`|`--cmake`] [`--no-fetch`] [`--set-name` <name>] [`--set-version` <version>] [`--tap` <user>`/`<repo>]: #: * `create` <URL> [`--autotools`|`--cmake`|`--meson`] [`--no-fetch`] [`--set-name` <name>] [`--set-version` <version>] [`--tap` <user>`/`<repo>]:
#: Generate a formula for the downloadable file at <URL> and open it in the editor. #: Generate a formula for the downloadable file at <URL> and open it in the editor.
#: Homebrew will attempt to automatically derive the formula name #: Homebrew will attempt to automatically derive the formula name
#: and version, but if it fails, you'll have to make your own template. The `wget` #: and version, but if it fails, you'll have to make your own template. The `wget`
@ -8,6 +8,7 @@
#: #:
#: If `--autotools` is passed, create a basic template for an Autotools-style build. #: If `--autotools` is passed, create a basic template for an Autotools-style build.
#: If `--cmake` is passed, create a basic template for a CMake-style build. #: If `--cmake` is passed, create a basic template for a CMake-style build.
#: If `--meson` is passed, create a basic template for a Meson-style build.
#: #:
#: If `--no-fetch` is passed, Homebrew will not download <URL> to the cache and #: If `--no-fetch` is passed, Homebrew will not download <URL> to the cache and
#: will thus not add the SHA256 to the formula for you. #: will thus not add the SHA256 to the formula for you.
@ -59,6 +60,8 @@ module Homebrew
:cmake :cmake
elsif ARGV.include? "--autotools" elsif ARGV.include? "--autotools"
:autotools :autotools
elsif ARGV.include? "--meson"
:meson
end end
if fc.name.nil? || fc.name.strip.empty? if fc.name.nil? || fc.name.strip.empty?
@ -175,6 +178,9 @@ class FormulaCreator
<% if mode == :cmake %> <% if mode == :cmake %>
depends_on "cmake" => :build depends_on "cmake" => :build
<% elsif mode == :meson %>
depends_on "meson" => :build
depends_on "ninja" => :build
<% elsif mode.nil? %> <% elsif mode.nil? %>
# depends_on "cmake" => :build # depends_on "cmake" => :build
<% end %> <% end %>
@ -191,6 +197,13 @@ class FormulaCreator
"--disable-dependency-tracking", "--disable-dependency-tracking",
"--disable-silent-rules", "--disable-silent-rules",
"--prefix=\#{prefix}" "--prefix=\#{prefix}"
<% elsif mode == :meson %>
mkdir "build" do
system "meson", "--prefix=\#{prefix}", ".."
system "ninja"
system "ninja", "test"
system "ninja", "install"
end
<% else %> <% else %>
# Remove unrecognized options if warned by configure # Remove unrecognized options if warned by configure
system "./configure", "--disable-debug", system "./configure", "--disable-debug",
@ -199,7 +212,9 @@ class FormulaCreator
"--prefix=\#{prefix}" "--prefix=\#{prefix}"
# system "cmake", ".", *std_cmake_args # system "cmake", ".", *std_cmake_args
<% end %> <% end %>
<% if mode != :meson %>
system "make", "install" # if this fails, try separate make/make install steps system "make", "install" # if this fails, try separate make/make install steps
<% end %>
end end
test do test do

View File

@ -504,7 +504,7 @@ message.</p>
url-and-sha256 style specification into a tag-and-revision style url-and-sha256 style specification into a tag-and-revision style
specification, nor vice versa. It must use whichever style specification specification, nor vice versa. It must use whichever style specification
the preexisting formula already uses.</p></dd> the preexisting formula already uses.</p></dd>
<dt><code>create</code> <var>URL</var> [<code>--autotools</code>|<code>--cmake</code>] [<code>--no-fetch</code>] [<code>--set-name</code> <var>name</var>] [<code>--set-version</code> <var>version</var>] [<code>--tap</code> <var>user</var><code>/</code><var>repo</var>]</dt><dd><p>Generate a formula for the downloadable file at <var>URL</var> and open it in the editor. <dt><code>create</code> <var>URL</var> [<code>--autotools</code>|<code>--cmake</code>|<code>--meson</code>] [<code>--no-fetch</code>] [<code>--set-name</code> <var>name</var>] [<code>--set-version</code> <var>version</var>] [<code>--tap</code> <var>user</var><code>/</code><var>repo</var>]</dt><dd><p>Generate a formula for the downloadable file at <var>URL</var> and open it in the editor.
Homebrew will attempt to automatically derive the formula name Homebrew will attempt to automatically derive the formula name
and version, but if it fails, you'll have to make your own template. The <code>wget</code> and version, but if it fails, you'll have to make your own template. The <code>wget</code>
formula serves as a simple example. For the complete API have a look at</p> formula serves as a simple example. For the complete API have a look at</p>
@ -512,7 +512,8 @@ formula serves as a simple example. For the complete API have a look at</p>
<p><a href="http://www.rubydoc.info/github/Homebrew/brew/master/Formula" data-bare-link="true">http://www.rubydoc.info/github/Homebrew/brew/master/Formula</a></p> <p><a href="http://www.rubydoc.info/github/Homebrew/brew/master/Formula" data-bare-link="true">http://www.rubydoc.info/github/Homebrew/brew/master/Formula</a></p>
<p>If <code>--autotools</code> is passed, create a basic template for an Autotools-style build. <p>If <code>--autotools</code> is passed, create a basic template for an Autotools-style build.
If <code>--cmake</code> is passed, create a basic template for a CMake-style build.</p> If <code>--cmake</code> is passed, create a basic template for a CMake-style build.
If <code>--meson</code> is passed, create a basic template for a Meson-style build.</p>
<p>If <code>--no-fetch</code> is passed, Homebrew will not download <var>URL</var> to the cache and <p>If <code>--no-fetch</code> is passed, Homebrew will not download <var>URL</var> to the cache and
will thus not add the SHA256 to the formula for you.</p> will thus not add the SHA256 to the formula for you.</p>

View File

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BREW\-CASK" "1" "November 2016" "Homebrew" "brew-cask" .TH "BREW\-CASK" "1" "December 2016" "Homebrew" "brew-cask"
. .
.SH "NAME" .SH "NAME"
\fBbrew\-cask\fR \- a friendly binary installer for macOS \fBbrew\-cask\fR \- a friendly binary installer for macOS

View File

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BREW" "1" "November 2016" "Homebrew" "brew" .TH "BREW" "1" "December 2016" "Homebrew" "brew"
. .
.SH "NAME" .SH "NAME"
\fBbrew\fR \- The missing package manager for macOS \fBbrew\fR \- The missing package manager for macOS
@ -695,14 +695,14 @@ If \fB\-\-message=\fR\fImessage\fR is passed, append \fImessage\fR to the defaul
Note that this command cannot be used to transition a formula from a url\-and\-sha256 style specification into a tag\-and\-revision style specification, nor vice versa\. It must use whichever style specification the preexisting formula already uses\. Note that this command cannot be used to transition a formula from a url\-and\-sha256 style specification into a tag\-and\-revision style specification, nor vice versa\. It must use whichever style specification the preexisting formula already uses\.
. .
.TP .TP
\fBcreate\fR \fIURL\fR [\fB\-\-autotools\fR|\fB\-\-cmake\fR] [\fB\-\-no\-fetch\fR] [\fB\-\-set\-name\fR \fIname\fR] [\fB\-\-set\-version\fR \fIversion\fR] [\fB\-\-tap\fR \fIuser\fR\fB/\fR\fIrepo\fR] \fBcreate\fR \fIURL\fR [\fB\-\-autotools\fR|\fB\-\-cmake\fR|\fB\-\-meson\fR] [\fB\-\-no\-fetch\fR] [\fB\-\-set\-name\fR \fIname\fR] [\fB\-\-set\-version\fR \fIversion\fR] [\fB\-\-tap\fR \fIuser\fR\fB/\fR\fIrepo\fR]
Generate a formula for the downloadable file at \fIURL\fR and open it in the editor\. Homebrew will attempt to automatically derive the formula name and version, but if it fails, you\'ll have to make your own template\. The \fBwget\fR formula serves as a simple example\. For the complete API have a look at Generate a formula for the downloadable file at \fIURL\fR and open it in the editor\. Homebrew will attempt to automatically derive the formula name and version, but if it fails, you\'ll have to make your own template\. The \fBwget\fR formula serves as a simple example\. For the complete API have a look at
. .
.IP .IP
\fIhttp://www\.rubydoc\.info/github/Homebrew/brew/master/Formula\fR \fIhttp://www\.rubydoc\.info/github/Homebrew/brew/master/Formula\fR
. .
.IP .IP
If \fB\-\-autotools\fR is passed, create a basic template for an Autotools\-style build\. If \fB\-\-cmake\fR is passed, create a basic template for a CMake\-style build\. If \fB\-\-autotools\fR is passed, create a basic template for an Autotools\-style build\. If \fB\-\-cmake\fR is passed, create a basic template for a CMake\-style build\. If \fB\-\-meson\fR is passed, create a basic template for a Meson\-style build\.
. .
.IP .IP
If \fB\-\-no\-fetch\fR is passed, Homebrew will not download \fIURL\fR to the cache and will thus not add the SHA256 to the formula for you\. If \fB\-\-no\-fetch\fR is passed, Homebrew will not download \fIURL\fR to the cache and will thus not add the SHA256 to the formula for you\.