|
| 1 | +# SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 | +# SPDX-FileNotice: Part of the FreeCAD project. |
| 3 | + |
| 4 | +class NetgenAT622505 < Formula |
| 5 | + desc "C++ Library of NETGEN's tetrahedral mesh generator" |
| 6 | + homepage "https://github.com/ngsolve/netgen" |
| 7 | + url "https://github.com/ngsolve/netgen.git", |
| 8 | + tag: "v6.2.2505" |
| 9 | + license "LGPL-2.1-only" |
| 10 | + head "https://github.com/ngsolve/netgen.git", branch: "master" |
| 11 | + |
| 12 | + keg_only :versioned_formula |
| 13 | + |
| 14 | + depends_on "cmake" => :build |
| 15 | + depends_on "llvm" => [:build, :test] |
| 16 | + depends_on "ninja" => :build |
| 17 | + depends_on "opencascade" |
| 18 | + depends_on "pybind11" |
| 19 | + depends_on "python@3.13" |
| 20 | + |
| 21 | + def install |
| 22 | + ENV["CC"] = Formula["llvm"].opt_bin/"clang" |
| 23 | + ENV["CXX"] = Formula["llvm"].opt_bin/"clang++" |
| 24 | + |
| 25 | + python3 = Formula["python@3.13"].opt_bin/"python3.13" |
| 26 | + |
| 27 | + ENV["PYTHON"] = python3.to_s |
| 28 | + |
| 29 | + # Get the Python includes directory without duplicates |
| 30 | + py_inc_output = `#{python3}-config --includes` |
| 31 | + py_inc_dirs = py_inc_output.scan(/-I([^\s]+)/).flatten.uniq |
| 32 | + py_inc_dir = py_inc_dirs.join(" ") |
| 33 | + |
| 34 | + puts "----------------------------------------------------" |
| 35 | + puts "PYTHON=#{ENV["PYTHON"]}" |
| 36 | + puts "----------------------------------------------------" |
| 37 | + |
| 38 | + args = %W[ |
| 39 | + -DCMAKE_INSTALL_PREFIX=#{prefix} |
| 40 | + -DUSE_PYTHON=ON |
| 41 | + -DPython3_EXECUTABLE=#{python3} |
| 42 | + -DPython3_INCLUDE_DIR=#{py_inc_dir} |
| 43 | + -DUSE_GUI=OFF |
| 44 | + -DUSE_OCC=ON |
| 45 | + -DUSE_SUPERBUILD=OFF |
| 46 | + -DBUILD_FOR_CONDA=OFF |
| 47 | + -G Ninja |
| 48 | + -L |
| 49 | + ] |
| 50 | + |
| 51 | + system "cmake", "-S", ".", "-B", "build", *args |
| 52 | + system "cmake", "--build", "build" |
| 53 | + system "cmake", "--install", "build" |
| 54 | + end |
| 55 | + |
| 56 | + def caveats |
| 57 | + <<~EOS |
| 58 | + this is a versioned formula so it is NOT linked in HOMBREW_PREFIX by default |
| 59 | + running brew test netgen currently fails with gcc if built with llvm |
| 60 | + EOS |
| 61 | + end |
| 62 | + |
| 63 | + test do |
| 64 | + ENV["CC"] = Formula["llvm"].opt_bin/"clang" |
| 65 | + ENV["CXX"] = Formula["llvm"].opt_bin/"clang++" |
| 66 | + |
| 67 | + puts "-----------------------------------------------" |
| 68 | + puts "prefix = #{prefix}" |
| 69 | + puts "include = #{include}" |
| 70 | + puts "-----------------------------------------------" |
| 71 | + |
| 72 | + ng_include = if OS.mac? |
| 73 | + prefix/"Contents/Resources/include" |
| 74 | + else |
| 75 | + include/"include" |
| 76 | + end |
| 77 | + |
| 78 | + ng_lib = if OS.mac? |
| 79 | + prefix/"Contents/MacOS" |
| 80 | + else |
| 81 | + lib |
| 82 | + end |
| 83 | + |
| 84 | + (testpath/"test.cpp").write <<~EOS |
| 85 | + #include <meshing/meshing.hpp> |
| 86 | + int main() { return 0; } |
| 87 | + EOS |
| 88 | + |
| 89 | + if OS.mac? |
| 90 | + res = prefix/"Contents/Resources/include" |
| 91 | + system ENV.cxx, "test.cpp", "-I#{res}", "-I#{res}/include", "-L#{ng_lib}", "-lnglib", "-o", "test" |
| 92 | + else |
| 93 | + system ENV.cxx, "test.cpp", "-I#{ng_include}", "-L#{ng_lib}", "-lnglib", "-o", "test" |
| 94 | + end |
| 95 | + system "./test" |
| 96 | + end |
| 97 | +end |
0 commit comments