From 8d7db4efa7a5abae4e317edb2f2f6e482ba662ec Mon Sep 17 00:00:00 2001 From: nailuoGG Date: Tue, 21 Jan 2025 08:36:17 +0800 Subject: [PATCH] libmps: build Release version with system Clang (cc) --- Formula/lib/libmps.rb | 43 +++++++++++++++---------------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/Formula/lib/libmps.rb b/Formula/lib/libmps.rb index e4207133b28c1a..e326451683f5ae 100755 --- a/Formula/lib/libmps.rb +++ b/Formula/lib/libmps.rb @@ -6,8 +6,7 @@ class Libmps < Formula license "BSD-2-Clause" head "https://github.com/Ravenbrook/mps.git", branch: "master" - # Add --with-debug option to build both Release and Debug versions - option "with-debug", "Build with debugging symbols and generate both Release (libmps.a) and Debug (libmps-debug.a) versions" + option "with-debug", "Build debug version (libmps-debug.a) alongside release version" bottle do sha256 cellar: :any_skip_relocation, arm64_sequoia: "c651514f2ee9c277517272b328db0e41ab0cc06b3998302e591db274dc70f104" @@ -20,47 +19,35 @@ class Libmps < Formula sha256 cellar: :any_skip_relocation, x86_64_linux: "c54043c0fcf718172a1d9f20e9eae7287180d26f4306f652c19f3d460faf68e9" end - depends_on xcode: :build - def install if OS.mac? - # Always build Release version - system "xcodebuild", "-scheme", "mps", - "-configuration", "Release", - "-project", "code/mps.xcodeproj", - "OTHER_CFLAGS=-Wno-error=unused-but-set-variable -Wno-unused-but-set-variable", - "SYMROOT=#{buildpath}/build" - - # Install Release library - lib.install "build/Release/libmps.a" + cd "code" do + # Build Release version with system Clang (cc) + system ENV.cc, "-O2", "-c", "mps.c", "-o", "mps.o" + system "ar", "rvs", "libmps.a", "mps.o" + lib.install "libmps.a" - # Build Debug version if --with-debug is specified - if build.with? "debug" - system "xcodebuild", "-scheme", "mps", - "-configuration", "Debug", - "-project", "code/mps.xcodeproj", - "OTHER_CFLAGS=-O0 -g -DCONFIG_VAR_COOL", - "SYMROOT=#{buildpath}/build-debug" + # Build Debug version if requested + if build.with? "debug" + 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" + end - # Install Debug library with different name - lib.install "build-debug/Debug/libmps.a" => "libmps-debug.a" + # Install headers + include.install Dir["mps*.h"] end - - # Install header files - include.install Dir["code/mps*.h"] else + # Keep original Linux build method ENV.deparallelize - # Build Release version for Linux system "./configure", "--prefix=#{prefix}", "CFLAGS=-O2" system "make" system "make", "install" - # Build Debug version if --with-debug is specified if build.with? "debug" system "make", "clean" system "./configure", "--prefix=#{prefix}", "CFLAGS=-O0 -g -DCONFIG_VAR_COOL" system "make" - # Install Debug library with different name lib.install "libmps.a" => "libmps-debug.a" end end