Subject: Re: bug#75514: scratch/igc: Clarify that `brew install limps` doesn't install mps-debug

From: "jiale.liu" <[email-masked]>
Date: Wed, 22 Jan 2025 00:22:07 +0000

"Stefan Kangas" <[email-masked]> writes:

> Could you provide a diff for the Homebrew formula?  Thanks.

Yes, the requested diff is attached to this email.

This patch modifies the formula to build both _release_ and _debug_ versions simultaneously.

To use the updated formula:

$ brew tap homebrew/core --force

# Apply patch or edit formula manually (see attached .patch)
$ brew --repository homebrew/core
$ patch -d /opt/homebrew/Library/Taps/homebrew/homebrew-core/  < ./libmps-debug.patch

# edit formula manually
$ brew edit --print-path libmps

# Compile from latest source with debug symbols
$ HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source libmps --HEAD

--
diff --git a/Formula/lib/libmps.rb b/Formula/lib/libmps.rb
index 0564a6a1b49..c0f24ffa739 100755
--- a/Formula/lib/libmps.rb
+++ b/Formula/lib/libmps.rb
@@ -17,29 +17,21 @@ class Libmps < Formula
     sha256 cellar: :any_skip_relocation, x86_64_linux:   "c54043c0fcf718172a1d9f20e9eae7287180d26f4306f652c19f3d460faf68e9"
   end
 
-  depends_on xcode: :build
-
   def install
-    if OS.mac?
-      # macOS build process
-      # for build native but not universal binary
-      # https://github.com/Ravenbrook/mps/blob/master/manual/build.txt
-      xcodebuild "-scheme", "mps",
-                 "-configuration", "Release",
-                 "-project", "code/mps.xcodeproj",
-                 "OTHER_CFLAGS=-Wno-error=unused-but-set-variable -Wno-unused-but-set-variable"
-
-      # Install the static library
-      lib.install "code/xc/Release/libmps.a"
-
-      # Install header files
-      include.install Dir["code/mps*.h"]
-
-    else
-      ENV.deparallelize
-      system "./configure", "--prefix=#{prefix}"
-      system "make"
-      system "make", "install"
+    cd "code" do
+      # Universal build process for all platforms
+      # Build Release version
+      system ENV.cc, "-O2", "-c", "mps.c", "-o", "mps.o"
+      system "ar", "rvs", "libmps.a", "mps.o"
+      lib.install "libmps.a"
+
+      # Build Debug version
+      system ENV.cc, "-O0", "-g", "-DCONFIG_VAR_COOL", "-c", "mps.c", "-o", "mps-debug.o"
+      system "ar", "rvs", "libmps-debug.a", "mps-debug.o"
+      lib.install "libmps-debug.a"
+
+      # Install headers
+      include.install Dir["mps*.h"]
     end
   end