Merge the fsharp recipe into the mono recipe
For reasons related to the way the mono runtime works, the installations must be "on top" of each other for the MSBuild compilation infrastructure to function properly. This change matches the official Mono installer. The fsharp installation is now optional (but defaults to on). This new formula overwrites old fsharp links. Fixes Homebrew/homebrew#36286 Closes Homebrew/homebrew#43719. Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
parent
5ed87b8354
commit
949ae5c935
2 changed files with 67 additions and 68 deletions
|
@ -1,67 +0,0 @@
|
|||
class Fsharp < Formula
|
||||
desc "F#, a functional-first programming language"
|
||||
homepage "http://fsharp.org/"
|
||||
url "https://github.com/fsharp/fsharp.git", :tag => "3.1.2.4",
|
||||
:revision => "8d02a54a75de362d6b649dcaaacfefe6db9caf41"
|
||||
|
||||
bottle do
|
||||
cellar :any_skip_relocation
|
||||
revision 1
|
||||
sha256 "97589b3e7d5ffa745bca99bd9af8b22bc235201533b4a0eaf837735d58ef322b" => :el_capitan
|
||||
sha256 "dcbb1135359e72ffdb76ce40a5b75bcea3e78083f56eb01c56186d007f37a3ce" => :yosemite
|
||||
sha256 "3d2ccce2f75a68cef19427407b4dc4bb4865bcfe1e7843810013f6fea07728a7" => :mavericks
|
||||
end
|
||||
|
||||
depends_on "automake" => :build
|
||||
depends_on "autoconf" => :build
|
||||
depends_on "pkg-config" => :build
|
||||
depends_on "mono"
|
||||
|
||||
def install
|
||||
system "./autogen.sh", "--prefix=#{prefix}"
|
||||
system "make"
|
||||
system "make", "install"
|
||||
end
|
||||
|
||||
def post_install
|
||||
mono_ver = Formula["mono"].version
|
||||
%w[3.0 3.1].each do |fsharp_ver|
|
||||
%w[Microsoft.Portable.FSharp.Targets
|
||||
Microsoft.FSharp.Targets].each do |fsharp_targ|
|
||||
tree_dir = "lib/mono/Microsoft\ SDKs/F\#/#{fsharp_ver}/Framework/v4.0"
|
||||
source_dir = File.expand_path "#{prefix}/../../mono/#{mono_ver}/#{tree_dir}"
|
||||
|
||||
# variables:
|
||||
# - tree_dir: the 'convoluted' non-absolute path the the installation, inside mono's prefix
|
||||
# - source_dir: tree_dir, inside mono's prefix, expanded to a full path
|
||||
# - fsharp_targ: the target file (for xbuild)
|
||||
mkdir_p source_dir
|
||||
ln_sf "#{prefix}/#{tree_dir}/#{fsharp_targ}", "#{source_dir}/#{fsharp_targ}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test do
|
||||
test_str = "Hello Homebrew"
|
||||
# fsharpi and fsharpc needs mono to be in the PATH
|
||||
ENV.prepend_path "PATH", Formula["mono"].bin
|
||||
|
||||
output = shell_output %(echo 'printfn "#{test_str}"; exit 0' | #{bin}/fsharpi)
|
||||
assert output.include? test_str
|
||||
|
||||
hello = (testpath/"hello.fs")
|
||||
hello.write("printfn \"#{test_str}\"\n")
|
||||
compiler_output = shell_output "#{bin}/fsharpc #{hello}"
|
||||
# make sure to find the fsharp assemblies even if the user has not set
|
||||
# MONO_GAC_PREFIX to HOMEBREW_PREFIX
|
||||
ENV["MONO_GAC_PREFIX"] = prefix
|
||||
output = shell_output "#{Formula["mono"].bin}/mono hello.exe"
|
||||
assert_match test_str, output.strip
|
||||
end
|
||||
|
||||
def caveats; <<-EOS.undent
|
||||
To run programs built with fsharpc you need to set:
|
||||
export MONO_GAC_PREFIX="#{HOMEBREW_PREFIX}"
|
||||
EOS
|
||||
end
|
||||
end
|
|
@ -15,11 +15,29 @@ class Mono < Formula
|
|||
sha256 "d3d9b118a27e3af2455925e83de0c44d4464660886c07fe5d21695f21471377a" => :mountain_lion
|
||||
end
|
||||
|
||||
option "without-fsharp", "Build without support for the F# language."
|
||||
|
||||
resource "monolite" do
|
||||
url "http://storage.bos.xamarin.com/mono-dist-4.2.0-release/9b/9b990f2b19b1a534925cce3ddaabb70654b76066/monolite-135-latest.tar.gz"
|
||||
sha256 "1529edbf34ebe498d315464e1211e65531ba25c492ba678a5bb079986a784131"
|
||||
end
|
||||
|
||||
resource "fsharp" do
|
||||
url "https://github.com/fsharp/fsharp.git", :tag => "3.1.2.5",
|
||||
:revision => "c5e345b194eaddad7f06d47cd944b098f3dbe325"
|
||||
end
|
||||
|
||||
depends_on "automake" => :build
|
||||
depends_on "autoconf" => :build
|
||||
depends_on "pkg-config" => :build
|
||||
|
||||
link_overwrite "bin/fsharpi"
|
||||
link_overwrite "bin/fsharpiAnyCpu"
|
||||
link_overwrite "bin/fsharpc"
|
||||
link_overwrite "bin/fssrgen"
|
||||
link_overwrite "lib/mono"
|
||||
link_overwrite "lib/cli"
|
||||
|
||||
def install
|
||||
# a working mono is required for the the build - monolite is enough
|
||||
# for the job
|
||||
|
@ -40,6 +58,17 @@ class Mono < Formula
|
|||
# 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"
|
||||
|
||||
# Now build and install fsharp as well
|
||||
if build.with? "fsharp"
|
||||
resource("fsharp").stage do
|
||||
ENV.prepend_path "PATH", bin
|
||||
ENV.prepend_path "PKG_CONFIG_PATH", lib/"pkgconfig"
|
||||
system "./autogen.sh", "--prefix=#{prefix}"
|
||||
system "make"
|
||||
system "make", "install"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test do
|
||||
|
@ -72,12 +101,49 @@ class Mono < Formula
|
|||
<Import Project="$(MSBuildBinPath)\\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
EOS
|
||||
shell_output "#{bin}/xbuild test.csproj"
|
||||
system "#{bin}/xbuild", "test.csproj"
|
||||
|
||||
if build.with? "fsharp"
|
||||
# Test that fsharpi is working
|
||||
ENV.prepend_path "PATH", bin
|
||||
output = pipe_output("#{bin}/fsharpi", "printfn \"#{test_str}\"; exit 0")
|
||||
assert_match test_str, output
|
||||
|
||||
# Tests that xbuild is able to execute fsc.exe
|
||||
(testpath/"test.fsproj").write <<-EOS.undent
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\FSharp\\Microsoft.FSharp.Targets</FSharpTargetsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.fs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="FSharp.Core" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
EOS
|
||||
(testpath/"Main.fs").write <<-EOS.undent
|
||||
[<EntryPoint>]
|
||||
let main _ = printfn "#{test_str}"; 0
|
||||
EOS
|
||||
system "#{bin}/xbuild", "test.fsproj"
|
||||
end
|
||||
end
|
||||
|
||||
def caveats; <<-EOS.undent
|
||||
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
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue