|
| 1 | +class PhpHttpAT83 < Formula |
| 2 | + desc "Pecl HTTP Extension for PHP" |
| 3 | + homepage "https://github.com/m6w6/ext-http" |
| 4 | + url "https://pecl.php.net/get/pecl_http-4.2.6.tgz" |
| 5 | + sha256 "cd33230050b3f7c5ddb6f4383ce2a81f0bcdb934432029eec72ebf0f942b876d" |
| 6 | + head "https://github.com/m6w6/ext-http.git" |
| 7 | + |
| 8 | + depends_on "autoconf" => :build |
| 9 | + depends_on "pkg-config" => :build |
| 10 | + depends_on "brotli" |
| 11 | + depends_on "curl" |
| 12 | + depends_on "icu4c@76" |
| 13 | + depends_on "openssl@3" |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + uses_from_macos "zlib" |
| 18 | + |
| 19 | + def module_path |
| 20 | + extension_dir = Utils.safe_popen_read("#{Formula["[email protected]"].opt_bin}/php-config", "--extension-dir").chomp |
| 21 | + php_basename = File.basename(extension_dir) |
| 22 | + "php/#{php_basename}" |
| 23 | + end |
| 24 | + |
| 25 | + def install |
| 26 | + cd "pecl_http-#{version}" |
| 27 | + system Formula["[email protected]"].bin/ "phpize" |
| 28 | + |
| 29 | + mkdir "ext" |
| 30 | + # link in the raphf extension header |
| 31 | + cp_r "#{Formula["[email protected]"].include}/raphf", "ext/raphf" |
| 32 | + |
| 33 | + sdkpath = "" |
| 34 | + sdkpath = MacOS.sdk_path_if_needed if OS.mac? |
| 35 | + |
| 36 | + configure_args = %W[ |
| 37 | + --with-http |
| 38 | + --without-http-libidn-dir |
| 39 | + --without-http-libidn2-dir |
| 40 | + --without-http-libidnkit-dir |
| 41 | + --without-http-libidnkit2-dir |
| 42 | + --with-libdir=#{HOMEBREW_PREFIX}/lib |
| 43 | + --with-php-config=#{Formula["[email protected]"].opt_bin/"php-config"} |
| 44 | + --with-http-zlib-dir=#{sdkpath}/usr |
| 45 | + --with-http-libcurl-dir=#{Formula["curl"].opt_lib} |
| 46 | + --with-http-libicu-dir=#{sdkpath}/usr |
| 47 | + ] |
| 48 | + system "./configure", *configure_args |
| 49 | + system "make" |
| 50 | + (lib/module_path).install "modules/http.so" |
| 51 | + end |
| 52 | + |
| 53 | + def post_install |
| 54 | + ext_config_path = etc/ "php"/ Formula["[email protected]"].version.major_minor/ "conf.d"/ "20-ext-http.ini" |
| 55 | + if ext_config_path.exist? |
| 56 | + inreplace ext_config_path, |
| 57 | + /extension=.*$/, "extension=\"#{opt_lib/module_path}/http.so\"" |
| 58 | + else |
| 59 | + ext_config_path.write <<~EOS |
| 60 | + [pecl_http] |
| 61 | + extension="#{opt_lib/module_path}/http.so" |
| 62 | + EOS |
| 63 | + end |
| 64 | + end |
| 65 | + |
| 66 | + test do |
| 67 | + assert_match "http", shell_output("#{Formula["[email protected]"].opt_bin}/php -m").downcase, |
| 68 | + "failed to find extension in php -m output" |
| 69 | + end |
| 70 | +end |
0 commit comments