Skip to content

Commit f392a7d

Browse files
committed
Fix Cantera build: Set ENV vars and explicit compilers for scons
Previous approach of passing cc_flags/cxx_flags didn't work because: 1. Homebrew clears CFLAGS/CXXFLAGS from ENV during builds 2. Cantera's scons needs environment variables set for compiler checks 3. scons also needs explicit CC/CXX compiler selection Solution: - Set ENV["CC"], ENV["CXX"], ENV["CFLAGS"], ENV["CXXFLAGS"], ENV["SDKROOT"] - Pass CC=<compiler> and CXX=<compiler> as scons arguments - Pass SDKROOT as environment variable to system() call This ensures scons can find standard C++ headers like <cmath> during its configuration checks.
1 parent 74178b6 commit f392a7d

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

packaging/homebrew/mfc.rb

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,34 @@ def install
3838
# Install Cantera build dependencies (including scons)
3939
system venv/"bin/pip", "install", "cython", "numpy", "ruamel.yaml", "packaging", "scons"
4040

41-
# Configure Cantera build - pass compiler and SDK paths to scons
42-
# Build flags that include SDK path and standard C++ include directories
41+
# Configure Cantera build
42+
# Cantera's scons needs explicit compiler selection and environment variables
4343
sdk_path = MacOS.sdk_path
44-
cxx_flags = "-isysroot#{sdk_path} -stdlib=libc++ -I#{sdk_path}/usr/include/c++/v1"
45-
46-
# Run scons with the venv's Python so it can find installed packages
47-
system venv/"bin/python", "-m", "SCons", "build",
48-
"python_package=y",
49-
"f90_interface=n",
50-
"system_sundials=y",
51-
"system_yamlcpp=y",
52-
"system_fmt=n",
53-
"cc_flags=#{cxx_flags}",
54-
"cxx_flags=#{cxx_flags}",
55-
"extra_inc_dirs=#{Formula["sundials"].opt_include}:#{Formula["yaml-cpp"].opt_include}",
56-
"extra_lib_dirs=#{Formula["sundials"].opt_lib}:#{Formula["yaml-cpp"].opt_lib}",
57-
"prefix=#{libexec}/cantera",
58-
"python_cmd=#{venv}/bin/python",
59-
"-j#{ENV.make_jobs}"
44+
45+
# Set environment variables that scons will use during compiler checks
46+
ENV["CC"] = ENV.cc
47+
ENV["CXX"] = ENV.cxx
48+
ENV["CFLAGS"] = "-isysroot#{sdk_path}"
49+
ENV["CXXFLAGS"] = "-isysroot#{sdk_path} -stdlib=libc++"
50+
ENV["SDKROOT"] = sdk_path.to_s
51+
52+
# Run scons, explicitly telling it which compilers to use
53+
system(
54+
{ "SDKROOT" => sdk_path.to_s },
55+
venv/"bin/python", "-m", "SCons", "build",
56+
"CC=#{ENV.cc}",
57+
"CXX=#{ENV.cxx}",
58+
"python_package=y",
59+
"f90_interface=n",
60+
"system_sundials=y",
61+
"system_yamlcpp=y",
62+
"system_fmt=n",
63+
"extra_inc_dirs=#{Formula["sundials"].opt_include}:#{Formula["yaml-cpp"].opt_include}",
64+
"extra_lib_dirs=#{Formula["sundials"].opt_lib}:#{Formula["yaml-cpp"].opt_lib}",
65+
"prefix=#{libexec}/cantera",
66+
"python_cmd=#{venv}/bin/python",
67+
"-j#{ENV.make_jobs}"
68+
)
6069

6170
# Install Cantera
6271
system venv/"bin/python", "-m", "SCons", "install"

0 commit comments

Comments
 (0)