From 12435565f3c1aeb86d62a366a4e1e1878e99153f Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Tue, 10 Aug 2021 11:55:00 +0800 Subject: [PATCH] formula: allow `std_cmake_args` to take parameters We have a handful of of formulae that do `std_cmake_args.reject` to override some of flags (e.g. emscripten, icemon, ortp, qt, klee, watchman). Let's try to simplify some of this code by allowing these formulae to override these flags by passing arguments to `std_cmake_args`. While we're here, let's update the type signature of `std_cargo_args`. --- Library/Homebrew/formula.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 7adf1236ac..80889b021f 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1480,7 +1480,7 @@ class Formula end # Standard parameters for cargo builds. - sig { params(root: String, path: String).returns(T::Array[T.any(String, Pathname)]) } + sig { params(root: T.any(String, Pathname), path: String).returns(T::Array[T.any(String, Pathname)]) } def std_cargo_args(root: prefix, path: ".") ["--locked", "--root", root, "--path", path] end @@ -1490,13 +1490,19 @@ class Formula # Setting `CMAKE_FIND_FRAMEWORK` to "LAST" tells CMake to search for our # libraries before trying to utilize Frameworks, many of which will be from # 3rd party installs. - sig { returns(T::Array[String]) } - def std_cmake_args + sig { + params( + install_prefix: T.any(String, Pathname), + install_libdir: String, + find_framework: String, + ).returns(T::Array[String]) + } + def std_cmake_args(install_prefix: prefix, install_libdir: "lib", find_framework: "LAST") args = %W[ - -DCMAKE_INSTALL_PREFIX=#{prefix} - -DCMAKE_INSTALL_LIBDIR=lib + -DCMAKE_INSTALL_PREFIX=#{install_prefix} + -DCMAKE_INSTALL_LIBDIR=#{install_libdir} -DCMAKE_BUILD_TYPE=Release - -DCMAKE_FIND_FRAMEWORK=LAST + -DCMAKE_FIND_FRAMEWORK=#{find_framework} -DCMAKE_VERBOSE_MAKEFILE=ON -Wno-dev -DBUILD_TESTING=OFF