homebrew-core/Formula/json-fortran.rb
2019-05-08 13:02:38 +02:00

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/7.0.0.tar.gz"
sha256 "9b5b6235489b27d572bbc7620ed8e039fa9d4d14d41b1581b279be9db499f32c"
revision 1
head "https://github.com/jacobwilliams/json-fortran.git"
bottle do
cellar :any
sha256 "7b85108b270b0fef205fefc19e57a39f694c4061825ce5d33b9fc480d140dc53" => :mojave
sha256 "60078cd424486a7a65b39e799eb0fb52e77ae6c4eb4cde18886ff886e90409f4" => :high_sierra
sha256 "4eae47471fa3c25694215178d8630b87a1ffe96f33aeac082a88841c3180df5b" => :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