homebrew-core/Formula/json-fortran.rb
2019-03-26 09:12:46 +01:00

50 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"
head "https://github.com/jacobwilliams/json-fortran.git"
bottle do
cellar :any
sha256 "30d8ab77362172bf0edf6fe7013d4ee8d9582152fe7b2596a32e690c1ae6e7db" => :mojave
sha256 "c50e42399672666d065a85792e4f1bb7074bb8e671282da14eb23a69bfa3dfb7" => :high_sierra
sha256 "fab9579c295073632cfd2e8679864ab0dcd6453d575547f5d7c0178275892feb" => :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