2014-07-08 05:28:37 +00:00
|
|
|
require "formula"
|
2010-03-13 09:10:05 +00:00
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Ledger < Formula
|
2014-07-08 05:28:37 +00:00
|
|
|
homepage "http://ledger-cli.org"
|
2014-03-27 11:05:06 +00:00
|
|
|
|
2014-06-08 16:01:35 +00:00
|
|
|
stable do
|
2014-10-06 12:54:57 +00:00
|
|
|
url "https://github.com/ledger/ledger/archive/v3.1.tar.gz"
|
|
|
|
sha1 "549aa375d4802e9dd4fd153c45ab64d8ede94afc"
|
2014-09-21 15:37:11 +00:00
|
|
|
|
2014-06-09 16:10:55 +00:00
|
|
|
resource "utfcpp" do
|
2014-06-08 16:01:35 +00:00
|
|
|
url "http://downloads.sourceforge.net/project/utfcpp/utf8cpp_2x/Release%202.3.4/utf8_v2_3_4.zip"
|
|
|
|
sha1 "638910adb69e4336f5a69c338abeeea88e9211ca"
|
|
|
|
end
|
2013-09-22 01:47:07 +00:00
|
|
|
end
|
|
|
|
|
2014-06-09 16:10:55 +00:00
|
|
|
bottle do
|
2014-10-06 19:25:31 +00:00
|
|
|
sha1 "71811722531f13093e8664e5178af7f07180e5a1" => :mavericks
|
|
|
|
sha1 "4f05d2f03df1d7f1709ca4a5ecb832d34cb2fbfe" => :mountain_lion
|
2014-06-09 16:10:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
head "https://github.com/ledger/ledger.git", :branch => "master"
|
|
|
|
|
2014-07-08 05:28:37 +00:00
|
|
|
option "debug", "Build with debugging symbols enabled"
|
|
|
|
option "with-docs", "Build HTML documentation"
|
2013-09-22 01:47:07 +00:00
|
|
|
|
2014-06-05 22:35:30 +00:00
|
|
|
depends_on "cmake" => :build
|
|
|
|
depends_on "ninja" => :build
|
|
|
|
depends_on "mpfr"
|
|
|
|
depends_on "gmp"
|
2013-09-22 01:47:07 +00:00
|
|
|
depends_on :python => :optional
|
2014-06-05 22:35:30 +00:00
|
|
|
|
2014-06-05 16:42:27 +00:00
|
|
|
boost_opts = []
|
|
|
|
boost_opts << "c++11" if MacOS.version < "10.9"
|
|
|
|
depends_on "boost" => boost_opts
|
2014-09-27 06:57:32 +00:00
|
|
|
depends_on "boost-python" => boost_opts if build.with? "python"
|
2013-09-22 01:47:07 +00:00
|
|
|
|
2014-06-05 20:57:58 +00:00
|
|
|
needs :cxx11
|
|
|
|
|
2010-03-13 09:10:05 +00:00
|
|
|
def install
|
2014-06-05 20:57:58 +00:00
|
|
|
ENV.cxx11
|
|
|
|
|
2014-06-09 16:10:55 +00:00
|
|
|
(buildpath/"lib/utfcpp").install resource("utfcpp") unless build.head?
|
2014-03-10 13:27:18 +00:00
|
|
|
|
2014-06-05 21:36:23 +00:00
|
|
|
flavor = build.include?("debug") ? "debug" : "opt"
|
|
|
|
|
2014-07-08 05:28:37 +00:00
|
|
|
opts = %W[-- -DBUILD_DOCS=1]
|
2014-06-05 21:36:23 +00:00
|
|
|
args = %W[
|
2014-07-08 05:28:37 +00:00
|
|
|
--ninja --jobs=#{ENV.make_jobs}
|
2014-06-05 21:36:23 +00:00
|
|
|
--output=build
|
2014-07-08 05:28:37 +00:00
|
|
|
--prefix=#{prefix}
|
2014-06-05 21:36:23 +00:00
|
|
|
--boost=#{Formula["boost"].opt_prefix}
|
|
|
|
]
|
2014-03-10 13:27:18 +00:00
|
|
|
|
2014-07-08 05:28:37 +00:00
|
|
|
if build.with? "docs"
|
|
|
|
opts << "-DBUILD_WEB_DOCS=1"
|
|
|
|
end
|
|
|
|
|
|
|
|
if build.with? "python"
|
2014-03-10 13:27:18 +00:00
|
|
|
# Per #25118, CMake does a poor job of detecting a brewed Python.
|
|
|
|
# We need to tell CMake explicitly where our default python lives.
|
|
|
|
# Inspired by
|
|
|
|
# https://github.com/Homebrew/homebrew/blob/51d054c/Library/Formula/opencv.rb
|
2014-07-08 05:28:37 +00:00
|
|
|
args << "--python"
|
2014-03-10 13:27:18 +00:00
|
|
|
python_prefix = `python-config --prefix`.strip
|
2014-07-08 05:28:37 +00:00
|
|
|
opts << "-DPYTHON_LIBRARY=#{python_prefix}/Python"
|
|
|
|
opts << "-DPYTHON_INCLUDE_DIR=#{python_prefix}/Headers"
|
2014-03-10 13:27:18 +00:00
|
|
|
end
|
2014-02-28 16:49:38 +00:00
|
|
|
|
2014-07-08 05:28:37 +00:00
|
|
|
args += opts
|
|
|
|
|
|
|
|
system "./acprep", flavor, "make", "doc", *args
|
|
|
|
system "./acprep", flavor, "make", "install", *args
|
|
|
|
(share+"ledger/examples").install Dir["test/input/*.dat"]
|
|
|
|
(share+"ledger").install "contrib"
|
2014-06-05 22:35:30 +00:00
|
|
|
(share+"ledger").install "python/demo.py" if build.with? "python"
|
2014-07-21 21:21:41 +00:00
|
|
|
(share/"emacs/site-lisp/ledger").install Dir["lisp/*.el", "lisp/*.elc"]
|
2014-01-30 08:43:15 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
test do
|
2014-06-08 16:01:35 +00:00
|
|
|
balance = testpath/"output"
|
|
|
|
system bin/"ledger",
|
|
|
|
"--args-only",
|
|
|
|
"--file", share/"ledger/examples/sample.dat",
|
|
|
|
"--output", balance,
|
|
|
|
"balance", "--collapse", "equity"
|
|
|
|
assert_equal " $-2,500.00 Equity", balance.read.chomp
|
2014-01-30 08:43:15 +00:00
|
|
|
assert_equal 0, $?.exitstatus
|
|
|
|
|
2014-07-08 05:28:37 +00:00
|
|
|
if build.with? "python"
|
2014-01-30 08:43:15 +00:00
|
|
|
system "python", "#{share}/ledger/demo.py"
|
2010-03-13 09:10:05 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|