59 lines
2.2 KiB
Ruby
59 lines
2.2 KiB
Ruby
class JsonFortran < Formula
|
|
desc "Fortran 2008 JSON API"
|
|
homepage "https://github.com/jacobwilliams/json-fortran"
|
|
url "https://github.com/jacobwilliams/json-fortran/archive/5.0.2.tar.gz"
|
|
sha256 "0360a9018b6ca80dbe45e3826e9d592fcac080d1fa1bb46691ff7a7411081df8"
|
|
head "https://github.com/jacobwilliams/json-fortran.git"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "895a3fac4b4c60755f063e556f3447d571defda6bd6f6dfdb8d83f1acd041532" => :el_capitan
|
|
sha256 "0dfd1d4fce69b5a8e66ae48a4abb06cf30e7741a071fe95e8f66fcda6a2ac7f3" => :yosemite
|
|
sha256 "572a12b11025ac49f1a1cc59cf50866459284197f9b2625cd3ff74eb53428598" => :mavericks
|
|
end
|
|
|
|
option "with-unicode-support", "Build json-fortran to support unicode text in json objects and files"
|
|
option "without-test", "Skip running build-time tests (not recommended)"
|
|
option "without-docs", "Do not build and install FORD generated documentation for json-fortran"
|
|
|
|
deprecated_option "without-robodoc" => "without-docs"
|
|
|
|
depends_on "ford" => :build if build.with? "docs"
|
|
depends_on "cmake" => :build
|
|
depends_on :fortran
|
|
|
|
def install
|
|
mkdir "build" do
|
|
args = std_cmake_args
|
|
args << "-DUSE_GNU_INSTALL_CONVENTION:BOOL=TRUE" # Use more GNU/Homebrew-like install layout
|
|
args << "-DENABLE_UNICODE:BOOL=TRUE" if build.with? "unicode-support"
|
|
args << "-DSKIP_DOC_GEN:BOOL=TRUE" if build.without? "docs"
|
|
system "cmake", "..", *args
|
|
system "make", "check" if build.with? "test"
|
|
system "make", "install"
|
|
end
|
|
end
|
|
|
|
test do
|
|
ENV.fortran
|
|
(testpath/"json_test.f90").write <<-EOS.undent
|
|
program example
|
|
use json_module, RK => json_RK
|
|
use iso_fortran_env, only: stdout => output_unit
|
|
implicit none
|
|
type(json_core) :: json
|
|
type(json_value),pointer :: p, inp
|
|
call json%initialize()
|
|
call json%create_object(p,'')
|
|
call json%create_object(inp,'inputs')
|
|
call json%add(p, inp)
|
|
call json%add(inp, 't0', 0.1_RK)
|
|
call json%print(p,stdout)
|
|
call json%destroy(p)
|
|
if (json%failed()) error stop 'error'
|
|
end program example
|
|
EOS
|
|
system ENV.fc, "-ojson_test", "-ljsonfortran", "-I#{HOMEBREW_PREFIX}/include", testpath/"json_test.f90"
|
|
system "./json_test"
|
|
end
|
|
end
|