Skip to content

Commit 1df4901

Browse files
committed
Install full MFC toolchain with smart wrapper for read-only Cellar
Reinstates the full MFC functionality including the mfc command-line tool by creating a smart wrapper that works around Homebrew's read-only Cellar. Changes to formula: - Install mfc.sh script and full Python toolchain - Create wrapper that uses temporary working directory - Wrapper symlinks toolchain, mfc.sh, and examples into temp dir - Automatically cleans up temp directory on exit - Sets proper environment variables for Homebrew installation Changes to CI: - Test mfc wrapper functionality (--help, count) - Run actual test case (1D Sod shock tube) with all CPU cores - Verify full installation structure including toolchain This allows users to use the full mfc CLI: mfc run, mfc test, mfc count, etc.
1 parent 48fe8f5 commit 1df4901

File tree

2 files changed

+76
-3
lines changed

2 files changed

+76
-3
lines changed

.github/workflows/homebrew.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,43 @@ jobs:
6161
- name: Test MFC binaries
6262
run: |
6363
echo "Verifying binaries are in PATH and executable..."
64+
which mfc
6465
which pre_process
6566
which simulation
6667
which post_process
68+
test -x $(which mfc)
6769
test -x $(which pre_process)
6870
test -x $(which simulation)
6971
test -x $(which post_process)
7072
echo "All binaries are accessible and executable!"
7173
74+
- name: Test MFC wrapper functionality
75+
run: |
76+
echo "Testing mfc command..."
77+
mfc --help
78+
79+
echo "Counting example cases..."
80+
mfc count $(brew --prefix)/share/mfc/examples/1D_sodshocktube/case.py
81+
82+
- name: Run MFC test case
83+
run: |
84+
echo "Running a simple test case (1D Sod shock tube)..."
85+
cd $(mktemp -d)
86+
cp $(brew --prefix)/share/mfc/examples/1D_sodshocktube/case.py .
87+
88+
echo "Running with $(sysctl -n hw.ncpu) processors..."
89+
mfc run case.py -j $(sysctl -n hw.ncpu)
90+
91+
echo "Test case completed successfully!"
92+
7293
- name: Verify installation structure
7394
run: |
7495
echo "Checking installed files..."
96+
ls -la $(brew --prefix)/bin/mfc
7597
ls -la $(brew --prefix)/bin/pre_process
7698
ls -la $(brew --prefix)/bin/simulation
7799
ls -la $(brew --prefix)/bin/post_process
100+
ls -la $(brew --prefix)/libexec/mfc.sh
78101
ls -la $(brew --prefix)/share/mfc/examples/
79102
80103
echo "Installation verified successfully!"

packaging/homebrew/mfc.rb

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,38 +36,88 @@ def install
3636
bin.install binary_paths.first
3737
end
3838

39+
# Install mfc.sh script to libexec
40+
libexec.install "mfc.sh"
41+
42+
# Install Python toolchain
43+
# The entire toolchain directory is required for mfc.sh functionality
44+
prefix.install "toolchain"
45+
3946
# Install examples
4047
pkgshare.install "examples"
48+
49+
# Create a wrapper that sets up a working environment for mfc.sh
50+
# The wrapper uses a temporary directory since Cellar is read-only
51+
(bin/"mfc").write <<~EOS
52+
#!/bin/bash
53+
set -e
54+
55+
# Create a working directory for MFC in user's cache
56+
MFC_WORK_DIR="${TMPDIR:-/tmp}/mfc-homebrew-$$"
57+
mkdir -p "$MFC_WORK_DIR"
58+
59+
# Function to clean up on exit
60+
cleanup() {
61+
rm -rf "$MFC_WORK_DIR"
62+
}
63+
trap cleanup EXIT
64+
65+
# Create minimal directory structure that mfc.sh expects
66+
cd "$MFC_WORK_DIR"
67+
ln -sf "#{prefix}/toolchain" toolchain
68+
ln -sf "#{libexec}/mfc.sh" mfc.sh
69+
ln -sf "#{pkgshare}/examples" examples
70+
71+
# Set up environment variables
72+
export MFC_INSTALL_DIR="#{prefix}"
73+
export MFC_BIN_DIR="#{bin}"
74+
export BOOST_INCLUDE="#{Formula["boost"].opt_include}"
75+
76+
# Run mfc.sh with all arguments
77+
exec ./mfc.sh "$@"
78+
EOS
79+
chmod 0755, bin/"mfc"
4180
end
4281

4382
def caveats
4483
<<~EOS
45-
MFC has been installed with the following binaries:
84+
MFC has been installed with:
85+
- mfc command-line tool: #{bin}/mfc
4686
- pre_process: #{bin}/pre_process
4787
- simulation: #{bin}/simulation
4888
- post_process: #{bin}/post_process
4989
5090
Examples are available in:
5191
#{pkgshare}/examples
5292
53-
For full development functionality (build, test, etc.),
54-
clone the repository from: https://github.com/MFlowCode/MFC
93+
To run an example:
94+
cd #{pkgshare}/examples/1D_sodshocktube
95+
mfc run case.py
5596
5697
Documentation: https://mflowcode.github.io/
5798
EOS
5899
end
59100

60101
test do
61102
# Test that the binaries exist and are executable
103+
assert_path_exists bin/"mfc"
104+
assert_predicate bin/"mfc", :executable?
62105
assert_path_exists bin/"pre_process"
63106
assert_predicate bin/"pre_process", :executable?
64107
assert_path_exists bin/"simulation"
65108
assert_predicate bin/"simulation", :executable?
66109
assert_path_exists bin/"post_process"
67110
assert_predicate bin/"post_process", :executable?
68111

112+
# Verify toolchain and mfc.sh were installed
113+
assert_path_exists libexec/"mfc.sh"
114+
assert_path_exists prefix/"toolchain"
115+
69116
# Verify examples were installed
70117
assert_path_exists pkgshare/"examples"
71118
assert_path_exists pkgshare/"examples/1D_sodshocktube/case.py"
119+
120+
# Test mfc wrapper basic functionality
121+
system bin/"mfc", "--help"
72122
end
73123
end

0 commit comments

Comments
 (0)