From c596f552b9d46f5e4214c78cbdc7c3139a972a94 Mon Sep 17 00:00:00 2001 From: Waschina Date: Tue, 23 Apr 2024 13:45:05 +0200 Subject: [PATCH 1/6] libsbml 5.20.2 (new formula) libsbml is a library for handling text files in Systems Biology Markup Language (SBML). Brief explanation for the additional configuration flags (-DENABLE_FBC=ON -DENABLE_GROUPS=ON): These enable two optional extensions for the libsbml library, namely "fbc" and "groups". Both are relevant for the research community that uses linear programming to predict metabolic processes in living cells (i.e., flux balance analysis). apt and dnf linux builds also include these two extensions. --- Formula/libsbml.rb | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Formula/libsbml.rb diff --git a/Formula/libsbml.rb b/Formula/libsbml.rb new file mode 100644 index 000000000..1c921c632 --- /dev/null +++ b/Formula/libsbml.rb @@ -0,0 +1,69 @@ +class Libsbml < Formula + desc "Library for handling SBML (Systems Biology Markup Language)" + homepage "https://sbml.org/software/libsbml" + url "https://github.com/sbmlteam/libsbml/archive/refs/tags/v5.20.2.tar.gz" + sha256 "a196cab964b0b41164d4118ef20523696510bbfd264a029df00091305a1af540" + license "LGPL-2.1-only" + + depends_on "cmake" => :build + depends_on "check" + + if OS.mac? + uses_from_macos "bzip2" + uses_from_macos "libiconv" + uses_from_macos "libxml2" + uses_from_macos "zlib" + else + depends_on "bzip2" + depends_on "libiconv" + depends_on "libxml2" + depends_on "zlib" + end + + def install + args = %w[ + -DENABLE_FBC=ON + -DENABLE_GROUPS=ON + -DWITH_LIBXML=TRUE + ] + + system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args + system "cmake", "--build", "build" + system "cmake", "--install", "build" + end + + test do + (testpath/"test.cpp").write <<~EOS + #include + #include + #include + + LIBSBML_CPP_NAMESPACE_USE + + int main(int argc,char** argv) + { + SBMLNamespaces sbmlns(3,2); + + sbmlns.addPkgNamespace("fbc",1); + sbmlns.addPkgNamespace("groups",1); + + // create the document + + SBMLDocument *document = new SBMLDocument(&sbmlns); + document->setPackageRequired("fbc", false); + document->setPackageRequired("groups", false); + + // create the model + Model* model = document->createModel(); + + // basic test + model->setId("Homebrew_SBMLtest"); + std::cout << model->getId() << std::endl; + + return 0; + } + EOS + system ENV.cxx, "-std=c++17", "-L#{lib}", "-I#{include}", "test.cpp", "-o", "test", "-lsbml" + assert_equal "Homebrew_SBMLtest", shell_output("./test").strip + end +end From ea651bf2880e7dac297820c7e215a5816721e564 Mon Sep 17 00:00:00 2001 From: Waschina Date: Wed, 24 Apr 2024 09:56:20 +0200 Subject: [PATCH 2/6] Remove libiconv from dependencies --- Formula/libsbml.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/Formula/libsbml.rb b/Formula/libsbml.rb index 1c921c632..e851ddd99 100644 --- a/Formula/libsbml.rb +++ b/Formula/libsbml.rb @@ -10,12 +10,10 @@ class Libsbml < Formula if OS.mac? uses_from_macos "bzip2" - uses_from_macos "libiconv" uses_from_macos "libxml2" uses_from_macos "zlib" else depends_on "bzip2" - depends_on "libiconv" depends_on "libxml2" depends_on "zlib" end From 4c29bb326923d2952f9d8b399d0998570e96ae02 Mon Sep 17 00:00:00 2001 From: Waschina Date: Wed, 24 Apr 2024 11:56:36 +0200 Subject: [PATCH 3/6] Update of build dependencies These updates address the errors from the CI's previous logs: `Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR)` `Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)` --- Formula/libsbml.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Formula/libsbml.rb b/Formula/libsbml.rb index e851ddd99..3a0588b48 100644 --- a/Formula/libsbml.rb +++ b/Formula/libsbml.rb @@ -5,8 +5,10 @@ class Libsbml < Formula sha256 "a196cab964b0b41164d4118ef20523696510bbfd264a029df00091305a1af540" license "LGPL-2.1-only" + depends_on "check" => :build depends_on "cmake" => :build - depends_on "check" + depends_on "pkg-config" => :build + depends_on "swig" => :build if OS.mac? uses_from_macos "bzip2" From 9e79be0c55daaa65cd15ef54b6f12028ee4ea169 Mon Sep 17 00:00:00 2001 From: Waschina Date: Thu, 2 May 2024 08:47:21 +0200 Subject: [PATCH 4/6] Build libsbml without zlib and enable additional extensions - Build without swig - Build without zlib (Note: this was disabled intentionally due to a conflict between libsbml and cmake. The conflict is because both tools come with a cmake module called "FindZLIB". Unfortunately, diabling zlib in libsbml has the effect, that .zip or .gz-compressed SBML files cannot be read nor written.) - Enables additional extensions of libsbml in case other users require these: "L3V2EXTENDEDMATH", "LAYOUT", "MULTI", "QUAL", "RENDER". Thanks to @YoshitakaMo --- Formula/libsbml.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Formula/libsbml.rb b/Formula/libsbml.rb index 3a0588b48..6d583bb7c 100644 --- a/Formula/libsbml.rb +++ b/Formula/libsbml.rb @@ -8,23 +8,23 @@ class Libsbml < Formula depends_on "check" => :build depends_on "cmake" => :build depends_on "pkg-config" => :build - depends_on "swig" => :build - if OS.mac? - uses_from_macos "bzip2" - uses_from_macos "libxml2" - uses_from_macos "zlib" - else - depends_on "bzip2" - depends_on "libxml2" - depends_on "zlib" - end + uses_from_macos "bzip2" + uses_from_macos "libxml2" def install args = %w[ + -DWITH_SWIG=OFF + -DWITH_ZLIB=OFF + -DWITH_BZIP2=ON + -DENABLE_COMP=ON -DENABLE_FBC=ON -DENABLE_GROUPS=ON - -DWITH_LIBXML=TRUE + -DENABLE_L3V2EXTENDEDMATH=ON + -DENABLE_LAYOUT=ON + -DENABLE_MULTI=ON + -DENABLE_QUAL=ON + -DENABLE_RENDER=ON ] system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args From 9e8512b7236ee4bc0dabf911c07c845aaddf7840 Mon Sep 17 00:00:00 2001 From: Silvio Waschina <32539757+Waschina@users.noreply.github.com> Date: Fri, 3 May 2024 07:34:46 +0200 Subject: [PATCH 5/6] Append `-fpermissive` to clags on OS linux --- Formula/libsbml.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Formula/libsbml.rb b/Formula/libsbml.rb index 6d583bb7c..a7f2a72e1 100644 --- a/Formula/libsbml.rb +++ b/Formula/libsbml.rb @@ -13,6 +13,8 @@ class Libsbml < Formula uses_from_macos "libxml2" def install + # avoid an error "invalid conversion from ‘const xmlError*’" + ENV.append_to_cflags "-fpermissive" if OS.linux? args = %w[ -DWITH_SWIG=OFF -DWITH_ZLIB=OFF From 85d1b72d23217184751fba4db3cabfc073e09d7e Mon Sep 17 00:00:00 2001 From: Silvio Waschina <32539757+Waschina@users.noreply.github.com> Date: Sun, 5 May 2024 20:01:08 +0200 Subject: [PATCH 6/6] set libsbml dependency directory to homebrew path --- Formula/libsbml.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Formula/libsbml.rb b/Formula/libsbml.rb index a7f2a72e1..9fa08e535 100644 --- a/Formula/libsbml.rb +++ b/Formula/libsbml.rb @@ -28,7 +28,7 @@ def install -DENABLE_QUAL=ON -DENABLE_RENDER=ON ] - + args << "-DLIBSBML_DEPENDENCY_DIR=#{HOMEBREW_PREFIX}" system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args system "cmake", "--build", "build" system "cmake", "--install", "build"