class Mono < Formula desc "Cross platform, open source .NET development framework" homepage "https://www.mono-project.com/" url "https://download.mono-project.com/sources/mono/mono-5.12.0.226.tar.bz2" sha256 "f0636baa0c1399805526142e799cb697ddccf736e506cf1a30a870eaa2830a89" revision 1 bottle do sha256 "bd914502b997ba891e948791b4f9e4709ccab551c93f3f6389ebdd081a060b19" => :high_sierra sha256 "03bc79c25e36f17ae200a1ff9750e3bdc7e9bb7bbd4c823672b759be310a03fc" => :sierra sha256 "595d90ac60e236fdbb84ac6b6aed4f119e8e3d77c411b3cf727a833e0a6547ba" => :el_capitan end # xbuild requires the .exe files inside the runtime directories to # be executable skip_clean "lib/mono" link_overwrite "bin/fsharpi" link_overwrite "bin/fsharpiAnyCpu" link_overwrite "bin/fsharpc" link_overwrite "bin/fssrgen" link_overwrite "lib/mono" link_overwrite "lib/cli" option "without-fsharp", "Build without support for the F# language." depends_on "automake" => :build depends_on "autoconf" => :build depends_on "pkg-config" => :build depends_on "cmake" => :build conflicts_with "xsd", :because => "both install `xsd` binaries" resource "fsharp" do url "https://github.com/fsharp/fsharp.git", :tag => "4.1.33", :revision => "95b66263420b62ae0e246bd1bf3c2641e9fb9625" end # When upgrading Mono, make sure to use the revision from # https://github.com/mono/mono/blob/mono-#{version}/packaging/MacSDK/msbuild.py # NOTE: We're currently using a later revision than from the point release we're using; # the buildsystem changed between them, and 5.12.0.226's is broken. # Revisit this on the next release. resource "msbuild" do url "https://github.com/mono/msbuild.git", :revision => "49a614cda8cedbc6b42e37d49e40cc89fbdac4fd" end def install args = %W[ --prefix=#{prefix} --disable-dependency-tracking --disable-silent-rules --enable-nls=no ] args << "--build=" + (MacOS.prefer_64_bit? ? "x86_64": "i686") + "-apple-darwin" system "./configure", *args system "make" system "make", "install" # mono-gdb.py and mono-sgen-gdb.py are meant to be loaded by gdb, not to be # run directly, so we move them out of bin libexec.install bin/"mono-gdb.py", bin/"mono-sgen-gdb.py" # We'll need mono for msbuild, and then later msbuild for fsharp ENV.prepend_path "PATH", bin # Next build msbuild resource("msbuild").stage do system "./build.sh", "-host", "mono", "-configuration", "Release", "-skipTests" system "./artifacts/mono-msbuild/msbuild", "mono/build/install.proj", "/p:MonoInstallPrefix=#{prefix}", "/p:Configuration=Release-MONO", "/p:IgnoreDiffFailure=true" end # Finally build and install fsharp as well if build.with? "fsharp" resource("fsharp").stage do ENV.prepend_path "PKG_CONFIG_PATH", lib/"pkgconfig" system "./autogen.sh", "--prefix=#{prefix}" system "make" system "make", "install" end end end def caveats; <<~EOS To use the assemblies from other formulae you need to set: export MONO_GAC_PREFIX="#{HOMEBREW_PREFIX}" Note that the 'mono' formula now includes F#. If you have the 'fsharp' formula installed, remove it with 'brew uninstall fsharp'. EOS end test do test_str = "Hello Homebrew" test_name = "hello.cs" (testpath/test_name).write <<~EOS public class Hello1 { public static void Main() { System.Console.WriteLine("#{test_str}"); } } EOS shell_output("#{bin}/mcs #{test_name}") output = shell_output("#{bin}/mono hello.exe") assert_match test_str, output.strip # Tests that xbuild is able to execute lib/mono/*/mcs.exe (testpath/"test.csproj").write <<~EOS HomebrewMonoTest v4.5 EOS system bin/"xbuild", "test.csproj" if build.with? "fsharp" # Test that fsharpi is working ENV.prepend_path "PATH", bin (testpath/"test.fsx").write <<~EOS printfn "#{test_str}"; 0 EOS output = pipe_output("#{bin}/fsharpi test.fsx") assert_match test_str, output # Tests that xbuild is able to execute fsc.exe (testpath/"test.fsproj").write <<~EOS 8.0.30703 2.0 {B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E} Exe $(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\FSharp\\Microsoft.FSharp.Targets EOS (testpath/"Main.fs").write <<~EOS [] let main _ = printfn "#{test_str}"; 0 EOS system bin/"xbuild", "test.fsproj" end end end