homebrew-core/Formula/json-fortran.rb

51 lines
1.7 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/8.1.0.tar.gz"
sha256 "4f4b3bf102d7e22327b0e4b8a3cadd8c3e453c969547ec21cd2429ed7d4c5404"
head "https://github.com/jacobwilliams/json-fortran.git"
bottle do
cellar :any
sha256 "b75cc1817090b77c80cbd63b4f4c7ce2afd57c96f9e19c0ab7ea5822a62e7f6b" => :catalina
sha256 "a68f3a882de03929152856d8797dc6e934b77e3087b0cdb93644157e8d00d2bd" => :mojave
sha256 "6775de35be3202c26f4a9b8719791bd4bf8dfb9c349ddf0fa72d0862d71ebeae" => :high_sierra
end
depends_on "cmake" => :build
depends_on "ford" => :build
depends_on "gcc" # for gfortran
def install
mkdir "build" do
system "cmake", "..", *std_cmake_args,
"-DUSE_GNU_INSTALL_CONVENTION:BOOL=TRUE",
"-DENABLE_UNICODE:BOOL=TRUE"
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