|
| 1 | +import platform |
| 2 | +from distutils.version import StrictVersion |
| 3 | + |
1 | 4 | class FsharpPackage(GitHubTarballPackage): |
2 | 5 | def __init__(self): |
3 | 6 | GitHubTarballPackage.__init__(self, |
4 | | - 'fsharp', 'fsharp', |
5 | | - '4.5.0', |
6 | | - '3de387432de8d11a89f99d1af87aa9ce194fe21b', |
| 7 | + 'dotnet', 'fsharp', |
| 8 | + '5.0.0', |
| 9 | + '03283e07f6bd5717797acb288cf6044cedca2202', |
7 | 10 | configure='', |
8 | | - override_properties={ 'make': 'make all install PREFIX="%{package_prefix}" DESTDIR=%{stage_root}' }) |
| 11 | + override_properties={ 'make': 'version= ./build.sh -c Release && version= ./.dotnet/dotnet restore setup/Swix/Microsoft.FSharp.SDK/Microsoft.FSharp.SDK.csproj --packages fsharp-nugets' }) |
9 | 12 |
|
10 | | - self.extra_stage_files = ['lib/mono/xbuild/Microsoft/VisualStudio/v/FSharp/Microsoft.FSharp.Targets'] |
11 | | - self.sources.extend(['patches/fsharp-IsPathRooted-type-inference.patch', |
12 | | - 'patches/fsharp-portable-pdb.patch', |
13 | | - 'patches/fsharp-noinstall.patch', |
14 | | - 'patches/fsharp-GetFileNameWithoutExtension-type-inference.patch', |
15 | | - 'patches/fsharp-msbuild-16-0.patch', |
16 | | - 'patches/fsharp-custom-prefix.patch']) |
| 13 | + self.sources.extend(['patches/fsharp-netfx-multitarget.patch', |
| 14 | + 'patches/fsharp-portable-pdb.patch']) |
17 | 15 |
|
18 | 16 | def prep(self): |
19 | 17 | Package.prep(self) |
20 | 18 |
|
21 | 19 | for p in range(1, len(self.sources)): |
22 | 20 | self.sh('patch -p1 < "%{local_sources[' + str(p) + ']}"') |
23 | 21 |
|
| 22 | + # .NET Core 3.1 officially only supports macOS 10.13+ but we can get it to work on 10.12 by compiling our own System.Native.dylib |
| 23 | + if StrictVersion(platform.mac_ver()[0]) < StrictVersion("10.13.0"): |
| 24 | + self.sh('git clone --branch release/3.1 git://github.com/dotnet/corefx && git -C corefx checkout 1b5b5f0bf030bf7250c3258c140fa9e4214325c8') |
| 25 | + self.sh('echo \'\' > corefx/src/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt') |
| 26 | + self.sh('env -i HOME="$HOME" PATH="$PATH" USER="$USER" bash -c \'cd corefx && MACOSX_DEPLOYMENT_TARGET=10.12 src/Native/build-native.sh x64 Debug OSX outconfig netcoreapp-OSX-Debug-x64 -portable\'') |
| 27 | + self.sh('bash -c \'source eng/common/tools.sh && InitializeDotNetCli true\'') |
| 28 | + self.sh('cp corefx/artifacts/bin/native/netcoreapp-OSX-Debug-x64/System.Native.dylib .dotnet/shared/Microsoft.NETCore.App/3.1.6/System.Native.dylib') |
| 29 | + |
24 | 30 | def build(self): |
25 | 31 | Package.make(self) |
26 | 32 |
|
27 | 33 | def install(self): |
28 | | - pass |
| 34 | + fsharp_files = [ |
| 35 | + "artifacts/bin/fsc/Release/net472/fsc.exe", |
| 36 | + "artifacts/bin/fsc/Release/net472/fsc.exe.config", |
| 37 | + "artifacts/bin/fsc/Release/net472/FSharp.Build.dll", |
| 38 | + "artifacts/bin/fsc/Release/net472/FSharp.Build.xml", |
| 39 | + "artifacts/bin/fsc/Release/net472/FSharp.Compiler.Private.dll", |
| 40 | + "artifacts/bin/fsc/Release/net472/FSharp.Compiler.Private.xml", |
| 41 | + "artifacts/bin/fsc/Release/net472/FSharp.Core.dll", |
| 42 | + "artifacts/bin/fsc/Release/net472/FSharp.Core.xml", |
| 43 | + "artifacts/bin/fsc/Release/net472/Microsoft.FSharp.Targets", |
| 44 | + "artifacts/bin/fsc/Release/net472/Microsoft.Portable.FSharp.Targets", |
| 45 | + "artifacts/bin/fsc/Release/net472/Microsoft.Build.dll", |
| 46 | + "artifacts/bin/fsc/Release/net472/Microsoft.Build.Framework.dll", |
| 47 | + "artifacts/bin/fsc/Release/net472/Microsoft.Build.Tasks.Core.dll", |
| 48 | + "artifacts/bin/fsc/Release/net472/Microsoft.Build.Utilities.Core.dll", |
| 49 | + "artifacts/bin/fsc/Release/net472/System.Buffers.dll", |
| 50 | + "artifacts/bin/fsc/Release/net472/System.Collections.Immutable.dll", |
| 51 | + "artifacts/bin/fsc/Release/net472/System.Memory.dll", |
| 52 | + "artifacts/bin/fsc/Release/net472/System.Numerics.Vectors.dll", |
| 53 | + "artifacts/bin/fsc/Release/net472/System.Reflection.Metadata.dll", |
| 54 | + "artifacts/bin/fsc/Release/net472/System.Reflection.TypeExtensions.dll", |
| 55 | + "artifacts/bin/fsc/Release/net472/System.Resources.Extensions.dll", |
| 56 | + "artifacts/bin/fsc/Release/net472/System.Runtime.CompilerServices.Unsafe.dll", |
| 57 | + "artifacts/bin/fsc/Release/net472/System.Threading.Tasks.Dataflow.dll", |
| 58 | + "artifacts/bin/fsi/Release/net472/fsi.exe", |
| 59 | + "artifacts/bin/fsi/Release/net472/fsi.exe.config", |
| 60 | + "artifacts/bin/fsiAnyCpu/Release/net472/fsiAnyCpu.exe", |
| 61 | + "artifacts/bin/fsiAnyCpu/Release/net472/fsiAnyCpu.exe.config", |
| 62 | + "artifacts/bin/fsi/Release/net472/FSharp.Compiler.Interactive.Settings.dll", |
| 63 | + "artifacts/bin/fsi/Release/net472/FSharp.Compiler.Interactive.Settings.xml", |
| 64 | + "artifacts/bin/fsi/Release/net472/FSharp.Compiler.Server.Shared.dll", |
| 65 | + "artifacts/bin/fsi/Release/net472/FSharp.Compiler.Server.Shared.xml", |
| 66 | + "artifacts/bin/fsi/Release/net472/FSharp.DependencyManager.Nuget.dll", |
| 67 | + "artifacts/bin/fsi/Release/net472/FSharp.DependencyManager.Nuget.xml", |
| 68 | + "artifacts/bin/fsi/Release/net472/Microsoft.DotNet.DependencyManager.dll", |
| 69 | + "artifacts/bin/fsi/Release/net472/Microsoft.DotNet.DependencyManager.xml" |
| 70 | + ] |
| 71 | + |
| 72 | + self.copy_files_to_dir(fsharp_files, os.path.join(self.staged_prefix, 'lib/mono/fsharp')) |
| 73 | + |
| 74 | + self.copy_api_files("fsharp-nugets/microsoft.visualfsharp.core.redist/1.0.0/content/.NETFramework/v4.0/4.3.0.0", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETFramework/v4.0/4.3.0.0')) |
| 75 | + self.copy_api_files("fsharp-nugets/microsoft.visualfsharp.core.redist/1.0.0/content/.NETFramework/v4.0/4.3.1.0", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETFramework/v4.0/4.3.1.0')) |
| 76 | + self.copy_api_files("fsharp-nugets/microsoft.visualfsharp.core.redist/1.0.0/content/.NETFramework/v4.0/4.4.0.0", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETFramework/v4.0/4.4.0.0')) |
| 77 | + self.copy_api_files("fsharp-nugets/microsoft.portable.fsharp.core/10.1.0/lib/versions/4.4.1.0", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETFramework/v4.0/4.4.1.0')) |
| 78 | + self.copy_api_files("fsharp-nugets/fsharp.core/4.3.4/lib/net45", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETFramework/v4.0/4.4.3.0')) |
| 79 | + self.copy_api_files("fsharp-nugets/fsharp.core/4.3.4/lib/net45", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETFramework/v4.0/4.4.5.0')) |
| 80 | + |
| 81 | + self.copy_api_files("fsharp-nugets/microsoft.visualfsharp.core.redist/1.0.0/content/.NETCore/3.3.1.0", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETCore/3.3.1.0')) |
| 82 | + self.copy_api_files("fsharp-nugets/microsoft.visualfsharp.core.redist/1.0.0/content/.NETCore/3.7.4.0", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETCore/3.7.4.0')) |
| 83 | + self.copy_api_files("fsharp-nugets/microsoft.visualfsharp.core.redist/1.0.0/content/.NETCore/3.78.3.1", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETCore/3.78.3.1')) |
| 84 | + self.copy_api_files("fsharp-nugets/microsoft.visualfsharp.core.redist/1.0.0/content/.NETCore/3.78.4.0", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETCore/3.78.4.0')) |
| 85 | + self.copy_api_files("fsharp-nugets/microsoft.visualfsharp.core.redist/1.0.0/content/.NETCore/3.259.4.0", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETCore/3.259.4.0')) |
| 86 | + self.copy_api_files("fsharp-nugets/microsoft.portable.fsharp.core/10.1.0/lib/profiles/portable-net45+netcore45", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETCore/3.7.41.0')) |
| 87 | + self.copy_api_files("fsharp-nugets/microsoft.portable.fsharp.core/10.1.0/lib/profiles/portable-net45+netcore45+wp8", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETCore/3.78.41.0')) |
| 88 | + self.copy_api_files("fsharp-nugets/microsoft.portable.fsharp.core/10.1.0/lib/profiles/portable-net45+netcore45+wpa81+wp8", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETCore/3.259.41.0')) |
| 89 | + |
| 90 | + self.copy_api_files("fsharp-nugets/microsoft.visualfsharp.core.redist/1.0.0/content/.NETPortable/2.3.5.0", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETPortable/2.3.5.0')) |
| 91 | + self.copy_api_files("fsharp-nugets/microsoft.visualfsharp.core.redist/1.0.0/content/.NETPortable/2.3.5.1", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETPortable/2.3.5.1')) |
| 92 | + self.copy_api_files("fsharp-nugets/microsoft.visualfsharp.core.redist/1.0.0/content/.NETPortable/3.47.4.0", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETPortable/3.47.4.0')) |
| 93 | + self.copy_api_files("fsharp-nugets/microsoft.portable.fsharp.core/10.1.0/lib/profiles/portable-net45+sl5+netcore45", os.path.join(self.staged_prefix, 'lib/mono/fsharp/api/.NETPortable/3.47.41.0')) |
| 94 | + |
| 95 | + self.copy_netsdk_files("artifacts/bin/fsc/Release/net472", os.path.join(self.staged_prefix, "lib/mono/xbuild/Microsoft/VisualStudio/v/FSharp")) |
| 96 | + self.copy_netsdk_files("artifacts/bin/fsc/Release/net472", os.path.join(self.staged_prefix, "lib/mono/xbuild/Microsoft/VisualStudio/v11.0/FSharp")) |
| 97 | + self.copy_netsdk_files("artifacts/bin/fsc/Release/net472", os.path.join(self.staged_prefix, "lib/mono/xbuild/Microsoft/VisualStudio/v12.0/FSharp")) |
| 98 | + self.copy_netsdk_files("artifacts/bin/fsc/Release/net472", os.path.join(self.staged_prefix, "lib/mono/xbuild/Microsoft/VisualStudio/v14.0/FSharp")) |
| 99 | + self.copy_netsdk_files("artifacts/bin/fsc/Release/net472", os.path.join(self.staged_prefix, "lib/mono/xbuild/Microsoft/VisualStudio/v15.0/FSharp")) |
| 100 | + self.copy_netsdk_files("artifacts/bin/fsc/Release/net472", os.path.join(self.staged_prefix, "lib/mono/xbuild/Microsoft/VisualStudio/v16.0/FSharp")) |
| 101 | + |
| 102 | + self.write_targets_files(os.path.join(self.staged_prefix, "lib/mono/Microsoft F#/v4.0")) |
| 103 | + self.write_targets_files(os.path.join(self.staged_prefix, "lib/mono/Microsoft SDKs/F#/3.0/Framework/v4.0")) |
| 104 | + self.write_targets_files(os.path.join(self.staged_prefix, "lib/mono/Microsoft SDKs/F#/3.1/Framework/v4.0")) |
| 105 | + self.write_targets_files(os.path.join(self.staged_prefix, "lib/mono/Microsoft SDKs/F#/4.0/Framework/v4.0")) |
| 106 | + self.write_targets_files(os.path.join(self.staged_prefix, "lib/mono/Microsoft SDKs/F#/4.1/Framework/v4.0")) |
| 107 | + self.write_targets_files(os.path.join(self.staged_prefix, "lib/mono/xbuild/Microsoft/VisualStudio/v/FSharp")) |
| 108 | + self.write_targets_files(os.path.join(self.staged_prefix, "lib/mono/xbuild/Microsoft/VisualStudio/v11.0/FSharp")) |
| 109 | + self.write_targets_files(os.path.join(self.staged_prefix, "lib/mono/xbuild/Microsoft/VisualStudio/v12.0/FSharp")) |
| 110 | + self.write_targets_files(os.path.join(self.staged_prefix, "lib/mono/xbuild/Microsoft/VisualStudio/v14.0/FSharp")) |
| 111 | + self.write_targets_files(os.path.join(self.staged_prefix, "lib/mono/xbuild/Microsoft/VisualStudio/v15.0/FSharp")) |
| 112 | + self.write_targets_files(os.path.join(self.staged_prefix, "lib/mono/xbuild/Microsoft/VisualStudio/v16.0/FSharp")) |
| 113 | + |
| 114 | + self.write_script(os.path.join(self.staged_prefix, "bin"), "fsharpc", "fsc.exe") |
| 115 | + self.write_script(os.path.join(self.staged_prefix, "bin"), "fsharpi", "fsi.exe") |
| 116 | + self.write_script(os.path.join(self.staged_prefix, "bin"), "fsharpiAnyCpu", "fsiAnyCpu.exe") |
| 117 | + |
| 118 | + def copy_api_files(self, source_dir, target_dir): |
| 119 | + fsharpcore_files = [ |
| 120 | + os.path.join(source_dir, "FSharp.Core.dll"), |
| 121 | + os.path.join(source_dir, "FSharp.Core.xml"), |
| 122 | + os.path.join(source_dir, "FSharp.Core.sigdata"), |
| 123 | + os.path.join(source_dir, "FSharp.Core.optdata") |
| 124 | + ] |
| 125 | + self.copy_files_to_dir(fsharpcore_files, target_dir) |
| 126 | + |
| 127 | + def copy_netsdk_files(self, source_dir, target_dir): |
| 128 | + netsdk_files = [ |
| 129 | + os.path.join(source_dir, "Microsoft.FSharp.NetSdk.props"), |
| 130 | + os.path.join(source_dir, "Microsoft.FSharp.NetSdk.targets"), |
| 131 | + os.path.join(source_dir, "Microsoft.FSharp.Overrides.NetSdk.targets") |
| 132 | + ] |
| 133 | + self.copy_files_to_dir(netsdk_files, target_dir) |
| 134 | + |
| 135 | + def write_targets_files(self, target_dir): |
| 136 | + ensure_dir(target_dir) |
| 137 | + with open(os.path.join(target_dir, "Microsoft.FSharp.Targets"), "w") as output: |
| 138 | + output.write('<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n') |
| 139 | + output.write(' <Import Project="' + self.package_prefix + '/lib/mono/fsharp/Microsoft.FSharp.Targets" />\n') |
| 140 | + output.write('</Project>\n') |
| 141 | + with open(os.path.join(target_dir, "Microsoft.Portable.FSharp.Targets"), "w") as output: |
| 142 | + output.write('<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n') |
| 143 | + output.write(' <Import Project="' + self.package_prefix + '/lib/mono/fsharp/Microsoft.Portable.FSharp.Targets" />\n') |
| 144 | + output.write('</Project>\n') |
| 145 | + |
| 146 | + def write_script(self, target_dir, script_name, exe_name): |
| 147 | + ensure_dir(target_dir) |
| 148 | + wrapper = os.path.join(target_dir, script_name) |
| 149 | + with open(wrapper, "w") as output: |
| 150 | + output.write('#!/bin/sh\n') |
| 151 | + output.write('EXEC="exec "\n') |
| 152 | + output.write('\n') |
| 153 | + output.write('if test x"$1" = x--debug; then\n') |
| 154 | + output.write(' DEBUG=--debug\n') |
| 155 | + output.write(' shift\n') |
| 156 | + output.write('fi\n') |
| 157 | + output.write('\n') |
| 158 | + output.write('if test x"$1" = x--gdb; then\n') |
| 159 | + output.write(' shift\n') |
| 160 | + output.write(' EXEC="gdb --eval-command=run --args "\n') |
| 161 | + output.write('fi\n') |
| 162 | + output.write('\n') |
| 163 | + output.write('if test x"$1" = x--valgrind; then\n') |
| 164 | + output.write(' shift\n') |
| 165 | + output.write(' EXEC="valgrind $VALGRIND_OPTIONS" \n') |
| 166 | + output.write('fi\n') |
| 167 | + output.write('\n') |
| 168 | + output.write('$EXEC ' + self.package_prefix + '/bin/mono $DEBUG $MONO_OPTIONS ' + self.package_prefix + '/lib/mono/fsharp/' + exe_name + ' --exename:$(basename "$0") "$@"\n') |
| 169 | + os.chmod(wrapper, 0o755) |
| 170 | + |
| 171 | + def copy_files_to_dir(self, files, target_dir): |
| 172 | + ensure_dir(target_dir) |
| 173 | + |
| 174 | + for f in files: |
| 175 | + source = os.path.join(self.workspace, f) |
| 176 | + target = os.path.join(target_dir, os.path.basename(source)) |
| 177 | + shutil.copy(source, target) |
29 | 178 |
|
30 | 179 | FsharpPackage() |
0 commit comments