Skip to content

Commit

Permalink
morpheus-develop: Refactor install method according to Homebrew-Core
Browse files Browse the repository at this point in the history
  • Loading branch information
jdieg0 committed Apr 15, 2024
1 parent b493bc9 commit cc45a8c
Showing 1 changed file with 23 additions and 28 deletions.
51 changes: 23 additions & 28 deletions Formula/morpheus-develop.rb
Original file line number Diff line number Diff line change
@@ -1,58 +1,53 @@
class MorpheusDevelop < Formula
desc "Modelling environment for multi-cellular systems biology"
desc "Modeling environment for multi-cellular systems biology"
homepage "https://morpheus.gitlab.io/"
license "BSD-3-Clause"
head "https://gitlab.com/morpheus.lab/morpheus.git", branch: "develop"

option "with-sbml", "Enable SBML import via the internal libSBML build"

depends_on "boost" => :build
depends_on "cmake" => :build
depends_on "doxygen" => :build
depends_on "ffmpeg" # Runtime dependencies
depends_on "ninja" => :build
depends_on "gnuplot"
depends_on "graphviz"
depends_on "libomp"
depends_on "libtiff"
depends_on "qt@5"
depends_on "ffmpeg" => :recommended # Runtime dependencies

uses_from_macos "bzip2"
uses_from_macos "libxml2"
uses_from_macos "zlib"

def install
args = std_cmake_args
args << "-DMORPHEUS_RELEASE_BUNDLE=ON" if OS.mac?

system "cmake", ".", *args
system "make", "install"
# has to build with Ninja until: https://gitlab.kitware.com/cmake/cmake/-/issues/25142
args = ["-G Ninja"]

if OS.mac?
bin.write_exec_script "#{prefix}/Morpheus.app/Contents/MacOS/morpheus"
args << "-DMORPHEUS_RELEASE_BUNDLE=ON"
args << "-DBREW_FORMULA_DEPLOYMENT=ON"

(bin/"morpheus-gui").write <<~EOS
#!/bin/bash
open #{prefix}/Morpheus.app
EOS
(bin/"morpheus-gui").chmod 0555
# SBML import currently disabled by default due to libSBML build errors with some macOS SDKs
args << "-DMORPHEUS_SBML=OFF" if build.without? "sbml"
end
end

def post_install
if OS.mac?
# Set PATH environment variable including Homebrew prefix in macOS app bundle
inreplace "#{prefix}/Morpheus.app/Contents/Info.plist", "<key>CFBundleExecutable</key>",
<<~EOS.chomp
<key>LSEnvironment</key>
<dict>
<key>PATH</key>
<string>#{ENV["PATH"]}</string>
</dict>
<key>CFBundleExecutable</key>
EOS
end
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"

return unless OS.mac?

bin.write_exec_script "#{prefix}/Morpheus.app/Contents/MacOS/morpheus"
bin.write_exec_script "#{prefix}/Morpheus.app/Contents/MacOS/morpheus-gui"

# Set PATH environment variable including Homebrew prefix in macOS app bundle
inreplace "#{prefix}/Morpheus.app/Contents/Info.plist", "HOMEBREW_BIN_PATH", "#{HOMEBREW_PREFIX}/bin"
end

def caveats
if OS.mac?
on_macos do
<<~EOS
To start the Morpheus GUI, type the following command:
Expand Down

0 comments on commit cc45a8c

Please sign in to comment.