2015-01-21 05:10:45 +00:00
|
|
|
require "language/haskell"
|
|
|
|
|
|
|
|
class Agda < Formula
|
|
|
|
include Language::Haskell::Cabal
|
2015-12-19 20:58:42 +00:00
|
|
|
|
2015-05-19 00:00:59 +00:00
|
|
|
desc "Dependently typed functional programming language"
|
2015-01-21 05:10:45 +00:00
|
|
|
homepage "http://wiki.portal.chalmers.se/agda/"
|
2015-11-01 19:22:02 +00:00
|
|
|
|
|
|
|
stable do
|
2015-12-21 22:51:21 +00:00
|
|
|
url "https://github.com/agda/agda/archive/2.4.2.5.tar.gz"
|
|
|
|
sha256 "a357470e47751e5757922b05ab8d692a526b8ed50619fb3dab0735a9a0e94cd1"
|
2015-12-19 20:58:42 +00:00
|
|
|
|
|
|
|
resource "stdlib" do
|
|
|
|
url "https://github.com/agda/agda-stdlib.git",
|
|
|
|
:tag => "v0.11",
|
|
|
|
:revision => "8602c29a7627eb001344cf50e6b74f880fb6bf18"
|
|
|
|
end
|
2015-11-01 19:22:02 +00:00
|
|
|
end
|
2015-01-21 05:10:45 +00:00
|
|
|
|
2015-01-23 05:10:47 +00:00
|
|
|
bottle do
|
2015-12-21 23:41:59 +00:00
|
|
|
sha256 "499162feef2e0f8357743b4166a468cfa46b75145f44bc4684e7ad7ca3164f9f" => :el_capitan
|
|
|
|
sha256 "9da031fabbbac72c22bcc6788d1a76d02be5947d496ee7d590bc735762e7c21c" => :yosemite
|
|
|
|
sha256 "4a8b2ecdaec7b443cfac1b0e2336f2d849e1180919fff3f6682f70ae6a57c0f0" => :mavericks
|
2015-01-23 05:10:47 +00:00
|
|
|
end
|
|
|
|
|
2015-10-25 13:46:32 +00:00
|
|
|
head do
|
2015-12-19 20:58:42 +00:00
|
|
|
url "https://github.com/agda/agda.git"
|
|
|
|
|
2015-10-25 13:46:32 +00:00
|
|
|
resource "stdlib" do
|
2015-12-19 20:58:42 +00:00
|
|
|
url "https://github.com/agda/agda-stdlib.git"
|
2015-10-25 13:46:32 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-02-09 20:46:31 +00:00
|
|
|
option "without-stdlib", "Don't install the Agda standard library"
|
2015-10-25 13:46:32 +00:00
|
|
|
option "without-malonzo", "Disable the MAlonzo backend"
|
2015-01-21 05:10:45 +00:00
|
|
|
|
2015-10-25 13:46:32 +00:00
|
|
|
if build.with? "malonzo"
|
|
|
|
depends_on "ghc"
|
|
|
|
else
|
|
|
|
depends_on "ghc" => :build
|
|
|
|
end
|
2015-01-21 05:10:45 +00:00
|
|
|
depends_on "cabal-install" => :build
|
2015-04-30 05:48:53 +00:00
|
|
|
|
2015-01-21 05:10:45 +00:00
|
|
|
depends_on "gmp"
|
2015-11-04 12:46:04 +00:00
|
|
|
depends_on :emacs => ["21.1", :recommended]
|
2015-02-09 20:46:31 +00:00
|
|
|
|
2015-01-21 05:10:45 +00:00
|
|
|
def install
|
2015-02-09 20:46:31 +00:00
|
|
|
# install Agda core
|
2015-12-23 13:20:23 +00:00
|
|
|
install_cabal_package :using => ["alex", "happy", "cpphs"]
|
2015-02-09 20:46:31 +00:00
|
|
|
|
|
|
|
if build.with? "stdlib"
|
2015-12-20 13:49:46 +00:00
|
|
|
resource("stdlib").stage lib/"agda"
|
2015-02-09 20:46:31 +00:00
|
|
|
|
2015-10-25 13:46:32 +00:00
|
|
|
# generate the standard library's bytecode
|
2015-12-20 13:49:46 +00:00
|
|
|
cd lib/"agda" do
|
2015-12-23 13:20:23 +00:00
|
|
|
cabal_sandbox :home => buildpath, :keep_lib => true do
|
2015-02-09 20:46:31 +00:00
|
|
|
cabal_install "--only-dependencies"
|
2015-10-25 13:46:32 +00:00
|
|
|
cabal_install
|
|
|
|
system "GenerateEverything"
|
2015-02-09 20:46:31 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# install the standard library's FFI bindings for the MAlonzo backend
|
2015-10-25 13:46:32 +00:00
|
|
|
# in a dedicated GHC package database
|
|
|
|
if build.with? "malonzo"
|
2015-12-20 13:49:46 +00:00
|
|
|
db_path = lib/"agda"/"ffi"/"package.conf.d"
|
2015-10-25 13:46:32 +00:00
|
|
|
|
|
|
|
mkdir db_path
|
|
|
|
system "ghc-pkg", "--package-db=#{db_path}", "recache"
|
|
|
|
|
2015-12-20 13:49:46 +00:00
|
|
|
cd lib/"agda"/"ffi" do
|
2015-12-23 13:20:23 +00:00
|
|
|
cabal_sandbox :home => buildpath, :keep_lib => true do
|
2015-10-25 13:46:32 +00:00
|
|
|
system "cabal", "--ignore-sandbox", "install", "--package-db=#{db_path}",
|
2015-12-20 13:49:46 +00:00
|
|
|
"--prefix=#{lib}/agda/ffi"
|
2015-10-25 13:46:32 +00:00
|
|
|
end
|
2015-02-09 20:46:31 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# generate the standard library's documentation and vim highlighting files
|
2015-12-20 13:49:46 +00:00
|
|
|
cd lib/"agda" do
|
2015-02-09 20:46:31 +00:00
|
|
|
system bin/"agda", "-i", ".", "-i", "src", "--html", "--vim", "README.agda"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-10-25 13:46:32 +00:00
|
|
|
# compile the included Emacs mode
|
2015-02-09 20:46:31 +00:00
|
|
|
if build.with? "emacs"
|
|
|
|
system bin/"agda-mode", "compile"
|
2015-12-05 04:44:46 +00:00
|
|
|
elisp.install_symlink Dir["#{share}/*/Agda-#{version}/emacs-mode/*"]
|
2015-02-09 20:46:31 +00:00
|
|
|
end
|
2015-01-21 05:10:45 +00:00
|
|
|
end
|
|
|
|
|
2015-10-25 13:46:32 +00:00
|
|
|
def caveats
|
|
|
|
s = ""
|
|
|
|
|
|
|
|
if build.with? "stdlib"
|
|
|
|
s += <<-EOS.undent
|
|
|
|
To use the Agda standard library, point Agda to the following include dir:
|
2015-12-20 13:49:46 +00:00
|
|
|
#{HOMEBREW_PREFIX}/lib/agda/src
|
2015-10-25 13:46:32 +00:00
|
|
|
EOS
|
|
|
|
|
|
|
|
if build.with? "malonzo"
|
|
|
|
s += <<-EOS.undent
|
|
|
|
|
|
|
|
To use the FFI bindings for the MAlonzo backend, give Agda the following option:
|
2015-12-20 13:49:46 +00:00
|
|
|
--ghc-flag=-package-db=#{HOMEBREW_PREFIX}/lib/agda/ffi/package.conf.d
|
2015-10-25 13:46:32 +00:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
s
|
|
|
|
end
|
|
|
|
|
2015-01-21 05:10:45 +00:00
|
|
|
test do
|
|
|
|
# run Agda's built-in test suite
|
|
|
|
system bin/"agda", "--test"
|
|
|
|
|
|
|
|
# typecheck and compile a simple module
|
2015-02-09 20:46:31 +00:00
|
|
|
test_file_path = testpath/"simple-test.agda"
|
|
|
|
test_file_path.write <<-EOS.undent
|
|
|
|
{-# OPTIONS --without-K #-}
|
|
|
|
module simple-test where
|
2015-01-21 05:10:45 +00:00
|
|
|
open import Agda.Primitive
|
|
|
|
infixr 6 _::_
|
|
|
|
data List {i} (A : Set i) : Set i where
|
|
|
|
[] : List A
|
|
|
|
_::_ : A -> List A -> List A
|
|
|
|
snoc : forall {i} {A : Set i} -> List A -> A -> List A
|
|
|
|
snoc [] x = x :: []
|
|
|
|
snoc (x :: xs) y = x :: (snoc xs y)
|
|
|
|
EOS
|
2015-10-25 13:46:32 +00:00
|
|
|
if build.with? "malonzo"
|
|
|
|
system bin/"agda", "-c", "--no-main", "--safe", test_file_path
|
|
|
|
end
|
2015-02-09 20:46:31 +00:00
|
|
|
system bin/"agda", "--js", "--safe", test_file_path
|
|
|
|
|
|
|
|
# typecheck, compile, and run a program that uses the standard library
|
2015-10-25 13:46:32 +00:00
|
|
|
if build.with?("stdlib") && build.with?("malonzo")
|
2015-02-09 20:46:31 +00:00
|
|
|
test_file_path = testpath/"stdlib-test.agda"
|
|
|
|
test_file_path.write <<-EOS.undent
|
|
|
|
module stdlib-test where
|
|
|
|
open import Data.String
|
|
|
|
open import Function
|
|
|
|
open import IO
|
|
|
|
main : _
|
|
|
|
main = run $ putStr "Hello, world!"
|
|
|
|
EOS
|
2015-12-20 13:49:46 +00:00
|
|
|
system bin/"agda", "-i", testpath, "-i", lib/"agda"/"src",
|
|
|
|
"--ghc-flag=-package-db=#{lib}/agda/ffi/package.conf.d",
|
2015-02-09 20:46:31 +00:00
|
|
|
"-c", test_file_path
|
2015-12-20 13:49:46 +00:00
|
|
|
assert_equal "Hello, world!", shell_output("#{testpath}/stdlib-test")
|
2015-02-09 20:46:31 +00:00
|
|
|
end
|
2015-01-21 05:10:45 +00:00
|
|
|
end
|
|
|
|
end
|