Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ampl-mp 4.0.0 ampl-asl 1.0.0 (new formula) #197123

Merged
merged 6 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/autobump.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ alsa-lib
amber
ammonite-repl
amp
ampl-asl
ampl-mp
amqp-cpp
amtterm
ancient
Expand Down
45 changes: 45 additions & 0 deletions Formula/a/ampl-asl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class AmplAsl < Formula
desc "AMPL Solver Library"
homepage "https://www.ampl.com/"
url "/~https://github.com/ampl/asl/archive/refs/tags/v1.0.0.tar.gz"
sha256 "28426e67b610874bbf8fd71fae982921aafe42310ef674c86aa6ec1181472ad0"
license "BSD-3-Clause"

bottle do
sha256 cellar: :any, arm64_sequoia: "373a3e24b7f2657e0e73e28e5c4c030fd8c48ac80d031df842bbaca1425a8813"
sha256 cellar: :any, arm64_sonoma: "7191c28174b3e1bf2f9d8ea53919797ddca8c876c38cc90e7b848ddd05909245"
sha256 cellar: :any, arm64_ventura: "5a3e9946bbe3280c0b9505a6731287c152aa629cd6e889c09c2f210d9083a614"
sha256 cellar: :any, sonoma: "00f3da5dcd89b747ee95af1b5e7adb65c3c064c4d5a40600cbce5ab203e7240d"
sha256 cellar: :any, ventura: "59211198a2cc7d3889bd4057de05f9c382a7f07f6878f9e0a6d0511dfa36d272"
sha256 cellar: :any_skip_relocation, x86_64_linux: "be998f883db133c2712c1aeeaed54f9c1f0c53891d81248be858b843feca561e"
end

depends_on "cmake" => :build

def install
args = %w[
-DBUILD_SHARED_LIBS=ON
]
args << "-DUSE_LTO=OFF" if OS.linux?
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end

test do
(testpath/"test.c").write <<~C
#include <stdio.h>
#include <stdlib.h>
#include "asl/asl.h"

int main() {
void* asl_instance = malloc(sizeof(void));
free(asl_instance);
return 0;
}
C

system ENV.cc, "test.c", "-o", "test", "-I#{include}/asl", "-L#{lib}", "-lasl"
system "./test"
end
end
78 changes: 30 additions & 48 deletions Formula/a/ampl-mp.rb
Original file line number Diff line number Diff line change
@@ -1,71 +1,53 @@
class AmplMp < Formula
desc "Open-source library for mathematical programming"
homepage "https://www.ampl.com/"
url "/~https://github.com/ampl/mp/archive/refs/tags/3.1.0.tar.gz"
sha256 "587c1a88f4c8f57bef95b58a8586956145417c8039f59b1758365ccc5a309ae9"
url "/~https://github.com/ampl/mp/archive/refs/tags/v4.0.0.tar.gz"
sha256 "9ac4b03dd03285cfcf998d81b53410611dd3ba0515463b70980965ec51e29f0f"
license "MIT"
revision 3

livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end

bottle do
rebuild 1
sha256 cellar: :any, arm64_sequoia: "d02c9a51954b17ab0a6caa31093daa7be212239b957d2224b773aaaa19b89c59"
sha256 cellar: :any, arm64_sonoma: "02f9efaecf470dffc6bff5b71530d0245b342f0e3805f73a5741b15a175e348a"
sha256 cellar: :any, arm64_ventura: "cf8589ed55bdfa5612fe9f4efc698eed1000e332446900798b1d4ebcd9f4e77e"
sha256 cellar: :any, sonoma: "fdf52601bd4c9990a80d1a14600d7c8649f2597bf4af38c966f9f806835eff44"
sha256 cellar: :any, ventura: "48756d110b0bac36eec0f33e181ad12f68632cb3087ccebb8451ef1d31798294"
sha256 cellar: :any_skip_relocation, x86_64_linux: "14117080e712ec6bcfd79084440b9264783a4567b9f31368bf8fa7109d718f58"
sha256 cellar: :any, arm64_sequoia: "07c2f88aaeea323a876870c8c4fb107193cee09fc8e591cf39c9710812be85e7"
sha256 cellar: :any, arm64_sonoma: "3daf4ac5b5d9765794ed359c5838c3e07183f7e209e962a4d30a0f2a8bf06062"
sha256 cellar: :any, arm64_ventura: "3984cfa43e3ec758a3d4cda736af4f70d51a55e4c8fbc271b691a3fc6a42e33d"
sha256 cellar: :any, sonoma: "81efa3c47b7241ad4adf50e1a50653472de841337c8a72620b8b8015eda4ba02"
sha256 cellar: :any, ventura: "d102b69020fdb1d2d0c49b2e4bb70498b154a1950533640b0dcfec0ab0069f8c"
sha256 cellar: :any_skip_relocation, x86_64_linux: "1548c6099ab8d8e657a0ab983deb4c7b4f1c32d0658f40c90336d7571e0b19ed"
end

depends_on "cmake" => :build

resource "miniampl" do
url "/~https://github.com/dpo/miniampl/archive/refs/tags/v1.0.tar.gz"
sha256 "b836dbf1208426f4bd93d6d79d632c6f5619054279ac33453825e036a915c675"
end

# Removes Google Benchmark - as already done so upstream
# All it did was conflict with the google-benchmark formula
patch do
url "/~https://github.com/ampl/mp/commit/96e332bb8cb7ba925e3ac947d6df515496027eed.patch?full_index=1"
sha256 "1a4ef4cd1f4e8b959c20518f8f00994ef577e74e05824b2d1b241b1c3c1f84eb"
end

# Install missing header files, remove in > 3.1.0
# /~https://github.com/ampl/mp/issues/110
chenrui333 marked this conversation as resolved.
Show resolved Hide resolved
patch do
url "/~https://github.com/ampl/mp/commit/8183be3e486d38d281e0c5a02a1ea4239695035e.patch?full_index=1"
sha256 "6b37201f1d0d6dba591e7e1b81fb16d2694d118605c92c422dcdaaedb463c367"
end

# Backport fmt header update. Remove in the next release
# /~https://github.com/ampl/mp/issues/108
patch do
url "/~https://github.com/ampl/mp/commit/1f39801af085656e4bf72250356a3a70d5d98e73.patch?full_index=1"
sha256 "b0e0185f24caba54cb38b65a638ebda6eb4db3e8c74d71ca79f072b8337e8e2c"
end

def install
system "cmake", "-S", ".", "-B", "build",
"-DAMPL_LIBRARY_DIR=#{libexec}/bin",
"-DBUILD_SHARED_LIBS=ON",
"-DCMAKE_INSTALL_RPATH=#{rpath};#{rpath(source: libexec/"bin")}",
*std_cmake_args
args = %W[
-DAMPL_LIBRARY_DIR=#{libexec}/bin
-DBUILD_SHARED_LIBS=ON
-DBUILD_TESTS=OFF
-DCMAKE_INSTALL_RPATH=#{rpath};#{rpath(source: libexec/"bin")}
]

system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end

test do
resource("miniampl").stage do
testpath.install "src/miniampl.c", Dir["examples/wb.*"]
end

system ENV.cc, "miniampl.c", "-std=c99", "-I#{include}/asl", "-L#{lib}", "-lasl", "-lmp"
output = shell_output("./a.out wb showname=1 showgrad=1")
assert_match "Objective name: objective", output
(testpath/"test.c").write <<~C
#include <stdio.h>
#include <stdlib.h>
#include "mp/ampls-c-api.h"

int main() {
AMPLS_MP_Solver* solver = (AMPLS_MP_Solver*)malloc(sizeof(AMPLS_MP_Solver));
free(solver);
return 0;
}
C

system ENV.cc, "test.c", "-I#{include}/mp", "-L#{lib}", "-lmp", "-o", "test"
system "./test"
end
end
20 changes: 10 additions & 10 deletions Formula/i/ipopt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ class Ipopt < Formula
url "/~https://github.com/coin-or/Ipopt/archive/refs/tags/releases/3.14.16.tar.gz"
sha256 "cc8c217991240db7eb14189eee0dff88f20a89bac11958b48625fa512fe8d104"
license "EPL-2.0"
revision 1
head "/~https://github.com/coin-or/Ipopt.git", branch: "stable/3.14"

bottle do
rebuild 1
sha256 cellar: :any, arm64_sequoia: "f27c151e814d4c9a0caeb33bb0a584c5d885121ec6a70a0586b330b8485779fa"
sha256 cellar: :any, arm64_sonoma: "9a7c783b3ccd11860b615afc874ead0f60700a7f97dde4d5752a4444778aa86d"
sha256 cellar: :any, arm64_ventura: "5e623167a75d4f3516f6e2b50c61578bd3222f18c63abb7d5483c95dd2a0c53b"
sha256 cellar: :any, sonoma: "fb86b1e3c17ed6cfb6b44bf1fcaca4a989a62335b364baa36490b4f0003675b8"
sha256 cellar: :any, ventura: "467af1d0edd4ee1beb1ef2496bf277992988c8599b3082467f5be3d6891cd85b"
sha256 cellar: :any_skip_relocation, x86_64_linux: "6e2c7ebb501bd2b73e5c847f1f5e82dcedfd3a9528de22c6848e9393cedaede6"
sha256 cellar: :any, arm64_sequoia: "ff6ba93dca47a18218817c81fa1e0f67b950d031fcedae98f33cc291eea6bd34"
sha256 cellar: :any, arm64_sonoma: "6b2e17f3d29e91fcea03af5de5c51cddfcc3a7a31c6be0686ccee3400a56b7ed"
sha256 cellar: :any, arm64_ventura: "41aae134e8a11bbbd904e625f19dd91b9462bcd47eb245ce0758d2b4580bb6ca"
sha256 cellar: :any, sonoma: "6f5af16203486282e3eb4d74380600a35544b362d171c66c4161a367ac4c22eb"
sha256 cellar: :any, ventura: "d042fd4c2993aad8181d9be04ff2ce979f1b9f206c5fe9e5b1638da827caa2b5"
sha256 cellar: :any_skip_relocation, x86_64_linux: "563c0669c52d28e3e80c8352f28c48b68e8421036ca0e8a08868b1c97ee9d739"
end

depends_on "openjdk" => :build
depends_on "pkg-config" => [:build, :test]
depends_on "ampl-mp"
depends_on "ampl-asl"
depends_on "gcc" # for gfortran
depends_on "openblas"

Expand Down Expand Up @@ -84,8 +84,8 @@ def install
"--with-blas=-L#{Formula["openblas"].opt_lib} -lopenblas",
"--with-mumps-cflags=-I#{buildpath}/mumps_include",
"--with-mumps-lflags=-L#{lib} -ldmumps -lmpiseq -lmumps_common -lopenblas -lpord",
"--with-asl-cflags=-I#{Formula["ampl-mp"].opt_include}/asl",
"--with-asl-lflags=-L#{Formula["ampl-mp"].opt_lib} -lasl",
"--with-asl-cflags=-I#{Formula["ampl-asl"].opt_include}/asl",
"--with-asl-lflags=-L#{Formula["ampl-asl"].opt_lib} -lasl",
]

system "./configure", *args
Expand Down
Loading