homebrew-core/Formula/json-fortran.rb
2018-04-20 22:56:01 -07:00

57 lines
2.1 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/6.3.0.tar.gz"
sha256 "dd989952c882e4eb9873f0b8d7610c0f623edce7f05d7903502d7cfa20766bbd"
head "https://github.com/jacobwilliams/json-fortran.git"
bottle do
cellar :any
sha256 "fdb0423147af7c31aa96b0d5e38f4a7eac9f2273187ecbb3a359614d2ad69895" => :high_sierra
sha256 "73f4062405a630d863de9a30a9c21a7f19e2324f7eb0634d4f6c0b5b186a8270" => :sierra
sha256 "4de4edbbfe4ae62cf6af5dd8212cfc0d18feffd940dd98053e990ccde392acbb" => :el_capitan
end
option "with-unicode-support", "Build json-fortran to support unicode text in json objects and files"
option "without-docs", "Do not build and install FORD generated documentation for json-fortran"
deprecated_option "without-robodoc" => "without-docs"
depends_on "cmake" => :build
depends_on "ford" => :build if build.with? "docs"
depends_on "gcc" # for gfortran
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", "install"
end
end
test do
(testpath/"json_test.f90").write <<~EOS
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 "gfortran", "-o", "test", "json_test.f90", "-I#{include}",
"-L#{lib}", "-ljsonfortran"
system "./test"
end
end