Fortran-FOSS-Programmers / Fortran-FOSS-Programmers/FLATPack-defunct

package formulas

Open
#6 17 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
7
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Hi all,
Just a suggestion about how to manage different packages, and a place to discuss.

I really like the way Homebrew keeps track of packages. It stores instructions for downloading, building and installing packages as relatively simple ruby scripts. I think this idea is much more powerful than trying to do something like duplicating package sources via cloning existing git repos. If FLATPack used a similar formula structure, the formula can indicate which compilers a certain package works with (and what versions and/or which language features or standards are required) and contain specialized build instructions for each compiler.

Here is a link to the Homebrew documentation [for writing formulas](https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Formula-Cookbook.md#formula-cookbook) and [for submitting pull requests to add them to Homebrew](https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/How-To-Open-a-Homebrew-Pull-Request-%28and-get-it-merged%29.md#how-to-open-a-homebrew-pull-request-and-get-it-merged).

Here is the [json-fortran](https://github.com/jacobwilliams/json-fortran) Homebrew formula for reference. It’s pretty concise and simple, and Homebrew has a `create` command which you pass a URL to and will extract version info, the sha256 hash and stub to expand. The `bottle do` stuff is just precompiled binaries built during the formula testing process and automatically added by the testbot:

``` ruby
class JsonFortran < Formula
desc "A Fortran 2008 JSON API"
homepage "https://github.com/jacobwilliams/json-fortran"
url "https://github.com/jacobwilliams/json-fortran/archive/4.1.1.tar.gz"
sha256 "97f258d28536035ef70e9ead5c7053e654106760a12db2cc652587ed61b76124"

head "https://github.com/jacobwilliams/json-fortran.git"

bottle do
cellar :any
sha256 "3b6410ef26c24d63f90e420aae0157f7d97b4d154b398305863e2be6c24eed8d" => :yosemite
sha256 "5608f04857515ce6b38d6a7ade2cf50a15541cb307ff97cbde1d367af3b19801" => :mavericks
sha256 "443ce5965a801c7e3dda0dfc5762b9f84ec97bf450d98eedfe0385d3681a725e" => :mountain_lion
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-robodoc", "Do not build and install ROBODoc generated documentation for json-fortran"

depends_on "robodoc" => [:recommended, :build]
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? "robodoc"
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 json_test
use json_module
use ,intrinsic :: iso_fortran_env ,only: error_unit
implicit none
call json_initialize()
if ( json_failed() ) then
call json_print_error_message(error_unit)
stop 2
endif
end program
EOS
system ENV.fc, "-ojson_test", "-ljsonfortran", "-I#{HOMEBREW_PREFIX}/include", testpath/"json_test.f90"
system "./json_test"
end
end
```

This encodes everything home-brew needs to know about `json-fortran` and this is what build options/info it provides to the user:

```
$ brew info json-fortran
json-fortran: stable 4.1.1 (bottled), HEAD
A Fortran 2008 JSON API
https://github.com/jacobwilliams/json-fortran
/usr/local/homebrew/Cellar/json-fortran/4.1.1 (34 files, 1.3M) *
Built from source with: --with-unicode-support
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/json-fortran.rb
==> Dependencies
Build: robodoc ✔, cmake ✘
Recommended: robodoc ✔
==> Options
--with-unicode-support
Build json-fortran to support unicode text in json objects and files
--without-robodoc
Do not build and install ROBODoc generated documentation for json-fortran
--without-test
Skip running build-time tests (not recommended)
--HEAD
Install HEAD version
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.