Skip to content

Commit 9b76a24

Browse files
committed
Fix: Pass compiler flags as environment variables, not scons args
The error was: "ERROR: Encountered unexpected command line option: 'CFLAGS'" Cantera's scons doesn't accept CFLAGS/CXXFLAGS as command-line arguments. Instead, they must be passed as environment variables. Changed from: system venv/"bin/python", "-m", "SCons", "build", "CFLAGS=...", ... To: cantera_env = { "CC" => ENV.cc, "CXX" => ENV.cxx, "CFLAGS" => "...", ... } system cantera_env, venv/"bin/python", "-m", "SCons", "build", ... This passes the compiler settings as environment variables which scons can properly detect and use.
1 parent a648a59 commit 9b76a24

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

packaging/homebrew/mfc.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,29 @@ def install
3939
system venv/"bin/pip", "install", "cython", "numpy", "ruamel.yaml", "packaging", "scons"
4040

4141
# Configure Cantera build
42+
# Set compiler environment variables for scons (not as command-line args)
43+
cantera_env = {
44+
"CC" => ENV.cc,
45+
"CXX" => ENV.cxx,
46+
"CFLAGS" => "-isysroot#{MacOS.sdk_path}",
47+
"CXXFLAGS" => "-isysroot#{MacOS.sdk_path}",
48+
}
49+
4250
# Run scons with the venv's Python so it can find installed packages
43-
# Pass compiler and SDK paths explicitly since Homebrew's env is isolated
44-
system venv/"bin/python", "-m", "SCons", "build",
51+
system cantera_env, venv/"bin/python", "-m", "SCons", "build",
4552
"python_package=y",
4653
"f90_interface=n",
4754
"system_sundials=y",
4855
"system_yamlcpp=y",
4956
"system_fmt=n",
50-
"CC=#{ENV.cc}",
51-
"CXX=#{ENV.cxx}",
52-
"CFLAGS=-isysroot#{MacOS.sdk_path}",
53-
"CXXFLAGS=-isysroot#{MacOS.sdk_path}",
5457
"extra_inc_dirs=#{Formula["sundials"].opt_include}:#{Formula["yaml-cpp"].opt_include}",
5558
"extra_lib_dirs=#{Formula["sundials"].opt_lib}:#{Formula["yaml-cpp"].opt_lib}",
5659
"prefix=#{libexec}/cantera",
5760
"python_cmd=#{venv}/bin/python",
5861
"-j#{ENV.make_jobs}"
5962

6063
# Install Cantera
61-
system venv/"bin/python", "-m", "SCons", "install"
64+
system cantera_env, venv/"bin/python", "-m", "SCons", "install"
6265

6366
# Install Cantera Python package into venv
6467
cd "build/python" do

0 commit comments

Comments
 (0)