|
| 1 | +F# 2.0 Compiler + Library Source Code Drop, matching April 2010 binary releases |
| 2 | +=== |
| 3 | + |
| 4 | +This directory contains a drop of the source code for an F# 2.0 compiler and core library. The code has been cleaned up "a little" to try to help ensure better stability as more development is done on the codebase. |
| 5 | + |
| 6 | +**Before we start, are sure you're in the right place?** |
| 7 | + |
| 8 | +* To get an F# compiler, go to[http://fsharp.net](fsharp.net) or[http://tryfsharp.org](tryfsharp.org) |
| 9 | +* To learn F#, go to[http://fsharp.net](fsharp.net) or[http://tryfsharp.org](tryfsharp.org) |
| 10 | +* To learn what F# is and why it's interesting, go to[http://fsharp.net](fsharp.net) or[http://tryfsharp.org](tryfsharp.org) |
| 11 | +* To download and install an F# compiler, go to[http://fsharp.net](fsharp.net) or[http://tryfsharp.org](tryfsharp.org) |
| 12 | +* If you want to to use F# in Visual Studio 2008 (R) or Visual Studio 2010 (R), go to[http://fsharp.net](fsharp.net). |
| 13 | +* Looking for F# coding samples? Go to[http://fsharp.net](fsharp.net) or search elsewhere. |
| 14 | + This code is not a model F# codebase and should not be used as guidance for F# coding style - there are plenty of things we would change if we had all the time in the world. |
| 15 | + |
| 16 | +To emphasize, this distribution should not be seen as a way to "get" an F# compiler for immediate use. For that you're better going to fsharp.net or tryfsharp.org |
| 17 | + |
| 18 | +**Copyright:** Copyright 2002-2010 (c) Microsoft Corporation. |
| 19 | + |
| 20 | +**License:** subject to terms and conditions of the Apache License, Version 2.0. A copy of the license can be found in the License.html file at the root of this distribution. By using this source code in any fashion, you are agreeing to be bound by the terms of the Apache License, Version 2.0. |
| 21 | + |
| 22 | +You must not remove this notice, or any other, from this software. |
| 23 | + |
| 24 | +**Questions?** If you have questions about the source code, please ask on a forum, or start a forum for community discussions, or post to the forum on fsharppowerpack.codeplex.com. Please do not ask the F# team at Microsoft for help with this source code: they like to be friendly, but they are very busy working on improving F# and need to focus on that. |
| 25 | + |
| 26 | +**Updates?** The F# team do not do active development in this repository, though some changes such as cleanup or additional tools may be submitted. They aspire to update the tree as and when future versions of F# compilers are released from Microsoft. |
| 27 | + |
| 28 | + |
| 29 | +##What do I get when I compile? |
| 30 | + |
| 31 | +When you compile, you get fsc.exe, fsi.exe, FSharp.Core.dll and some related DLLs. |
| 32 | + |
| 33 | + |
| 34 | +##How do I compile? |
| 35 | + |
| 36 | +The prerequisites and build command line for compiling the source (on Windows) are shown later in this README. Here's the logic of the build: |
| 37 | + |
| 38 | +* We first need an existing F# compiler, usually the one available from fsharp.net, although it could also be another. Let's assume this compiler has an FSharp.Core.dll with version X. |
| 39 | +* We use this compiler to compile the source in this distribution, to produce a "proto" compiler, in the Proto directory. When run, this compiler still relies on the FSharp.Core.dll with version X. |
| 40 | +* We use the proto compiler to compile the source for FSharp.Core.dll in this distribution, producing an FSharp.Core.dll with the version identified in src\source-build-version, usually 1.9.999. |
| 41 | +* We use the proto compiler to compile the source for FSharp.Compiler.dll, fsc.exe, fsi.exe and other binaries found in this distribution. When run, these binaries will rely on the FSharp.Core.dll with version 1.9.999. This is good, since it means the 1.9.999 binaries now form a consistent, bootstrapped compiler. If you like you should now be able to throw away the compiler with version X. |
| 42 | + |
| 43 | +Some additional tools are required to build the compiler, notably fslex.exe, fsyacc.exe, FSharp.PowerPack.Build.Tasks.dll, FsSrGen.exe, FSharp.SRGen.Build.Tasks.dll and the other tools found in the lkg directory. These are "Last Known Good" binaries created from a version of the F# Power Pack on CodePlex. If you like you can throw away these binaries and use your own compiled versions of these. tools. |
| 44 | + |
| 45 | + |
| 46 | +##Strong names and versions |
| 47 | + |
| 48 | +When you build the compiler using the instructions below, the compiler and library binaries produced are not strong-named or signed, and use CLI assembly version nunmber 1.9.9.999. Without a strong-name you will not be able to add FSharp.Core.dll to the GAC, though that is not a problem for most purposes since the FSharp.Core.dll you compile can be copied as part of your application. |
| 49 | + |
| 50 | +Once you have an F# compiler, you will normally be able to reference another or an existing FSharp.Core.dll and matching mscorlib.dll explicitly to target that profile. |
| 51 | + |
| 52 | +To add strong names you would need to adjust the build settings. Our recommendation is not to use the version number 2.0 on your binaries, since that can get confusing if you already have an installation of an F# 2.0 compiler. |
| 53 | + |
| 54 | + |
| 55 | +##Building on Windows using MSBuild from the Command Linees |
| 56 | + |
| 57 | +* Both .NET 2.0 and .NET 4.0 |
| 58 | +* Visual Studio 2010 Shell (Integrated Edition, with F# CTP MSI added), OR Visual Studio Professional 2010, OR another non-Express version of Visual Studio 2010 OR the F# CTP MSI installed as a standlone compiler. |
| 59 | + |
| 60 | + |
| 61 | +##Steps - Cleaning (if needed) |
| 62 | + |
| 63 | +cd src |
| 64 | +rmdir /s /q ..\Proto |
| 65 | +rmdir /s /q ..\Debug |
| 66 | +rmdir /s /q ..\Release |
| 67 | + |
| 68 | + |
| 69 | +##Steps - Building a Proto Compiler for Mono or .NET 2.0 using .NET 2.0/4.0 tools |
| 70 | + |
| 71 | +cd src |
| 72 | +msbuild fsharp-proto-build.proj /p:TargetFramework=cli\2.0 |
| 73 | + |
| 74 | +Note: Make sure you run the .NET 4.0 msbuild.exe, e.g. C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe. |
| 75 | + |
| 76 | + |
| 77 | +##Steps - NGEN the Proto Compiler for faster future startup (optional) |
| 78 | + |
| 79 | +ngen install ..\Proto\cli\2.0\bin\fsi.exe |
| 80 | + |
| 81 | + |
| 82 | +##Steps - Building the F# core library and unittests for running on Mono or .NET 2.0-4.0, using the Proto compiler |
| 83 | + |
| 84 | +msbuild fsharp-library-build.proj /p:TargetFramework=cli\2.0 |
| 85 | + |
| 86 | +**Note:** Make sure you run the .NET 4.0 msbuild.exe, e.g. C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe. |
| 87 | + |
| 88 | + |
| 89 | +##Steps - Building a bootstrapped F# Compiler for running on Mono or .NET 2.0-4.0, using the Proto Compiler |
| 90 | + |
| 91 | +msbuild fsharp-compiler-build.proj /p:TargetFramework=cli\2.0 |
| 92 | + |
| 93 | +**Note:** Make sure you run the .NET 4.0 msbuild.exe, e.g. C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe. |
| 94 | + |
| 95 | + |
| 96 | +##Steps - Building a F# Compiler unit tests for NUnit for running on Mono or .NET 2.0-4.0, using the Proto Compiler |
| 97 | + |
| 98 | +msbuild fsharp-library-unittests-build.proj /p:TargetFramework=cli\2.0 |
| 99 | +msbuild fsharp-compiler-unittests-build.proj /p:TargetFramework=cli\2.0 |
| 100 | + |
| 101 | +**Note:** You must have NUnit installed. |
| 102 | + |
| 103 | + |
| 104 | +##Validation and Use |
| 105 | + |
| 106 | +ngen install ..\Debug\cli\2.0\bin\fsi.exe |
| 107 | +..\Debug\cli\2.0\bin\fsi.exe |
| 108 | +1 + 1;; |
| 109 | +#q;; |
| 110 | +..\Debug\cli\2.0\bin\fsi.exe /help |
| 111 | +..\Debug\cli\2.0\bin\fsc.exe /help |
| 112 | +echo printfn "hello world" > hello.fs |
| 113 | +..\Debug\cli\2.0\bin\fsc.exe hello.fs |
| 114 | +copy ..\Debug\cli\2.0\bin\FSharp.Core.dll . |
| 115 | +hello.exe |
| 116 | +del /q FSharp.Core.dll |
| 117 | + |
| 118 | + |
| 119 | +##Some alternative Steps - Building the F# core library and unittests for alternative CLI/.NET/CIL implementations, using the Proto compiler |
| 120 | + |
| 121 | +msbuild fsharp-library-build.proj /p:TargetFramework=Silverlight\3.0 |
| 122 | +msbuild fsharp-library-build.proj /p:TargetFramework=Silverlight\4.0 |
| 123 | +msbuild fsharp-library-build.proj /p:TargetFramework=WindowsPhone7\Silverlight\4.0 |
| 124 | +msbuild fsharp-library-build.proj /p:TargetFramework=CompactFramework\2.0 |
| 125 | +msbuild fsharp-library-build.proj /p:TargetFramework=CompactFramework\3.5 |
| 126 | + |
| 127 | +##Some alternative Steps - Building for .NET 4.0 profile |
| 128 | + |
| 129 | +cd src |
| 130 | +msbuild fsharp-proto-build.proj /p:TargetFramework=cli\4.0 |
| 131 | +msbuild fsharp-library-build.proj /p:TargetFramework=cli\4.0 |
| 132 | +msbuild fsharp-compiler-build.proj /p:TargetFramework=cli\4.0 |
| 133 | +msbuild fsharp-library-unittests-build.proj /p:TargetFramework=cli\4.0 |
| 134 | +msbuild fsharp-compiler-unittests-build.proj /p:TargetFramework=cli\4.0 |
| 135 | + |
| 136 | +ngen install ..\Debug\cli\4.0\bin\fsi.exe |
| 137 | +..\Debug\cli\4.0\bin\fsi.exe |
| 138 | +1 + 1;; |
| 139 | +#q;; |
| 140 | +..\Debug\cli\4.0\bin\fsi.exe /help |
| 141 | +..\Debug\cli\4.0\bin\fsc.exe /help |
| 142 | +echo printfn "hello world" > hello.fs |
| 143 | +..\Debug\cli\4.0\bin\fsc.exe hello.fs |
| 144 | +copy ..\Debug\cli\4.0\bin\FSharp.Core.dll . |
| 145 | +hello.exe |
| 146 | +del /q FSharp.Core.dll |
| 147 | + |
| 148 | +msbuild fsharp-compiler-build.proj /p:TargetFramework=cli\4.0 /p:Configuration=Release |
| 149 | + |
| 150 | +ngen install ..\Release\cli\4.0\bin\fsi.exe |
| 151 | +..\Release\cli\4.0\bin\fsi.exe |
| 152 | +1 + 1;; |
| 153 | +#q;; |
| 154 | +..\Release\cli\4.0\bin\fsi.exe /help |
| 155 | +..\Release\cli\4.0\bin\fsc.exe /help |
| 156 | +echo printfn "hello world" > hello.fs |
| 157 | +..\Release\cli\4.0\bin\fsc.exe hello.fs |
| 158 | +copy ..\Release\cli\4.0\bin\FSharp.Core.dll . |
| 159 | +hello.exe |
| 160 | +del /q FSharp.Core.dll |
| 161 | + |
| 162 | + |
| 163 | +##Some alternative Steps - Building Release mode (choose some of these as you need) |
| 164 | + |
| 165 | +msbuild fsharp-library-build.proj /p:Configuration=Release |
| 166 | +msbuild fsharp-library-build.proj /p:TargetFramework=cli\2.0 /p:Configuration=Release |
| 167 | +msbuild fsharp-library-build.proj /p:TargetFramework=cli\4.0 /p:Configuration=Release |
| 168 | +msbuild fsharp-library-build.proj /p:TargetFramework=Silverlight\3.0 /p:Configuration=Release |
| 169 | +msbuild fsharp-library-build.proj /p:TargetFramework=Silverlight\4.0 /p:Configuration=Release |
| 170 | +msbuild fsharp-library-build.proj /p:TargetFramework=WindowsPhone7\Silverlight\4.0 /p:Configuration=Release |
| 171 | +msbuild fsharp-library-build.proj /p:TargetFramework=CompactFramework\2.0 /p:Configuration=Release |
| 172 | +msbuild fsharp-library-build.proj /p:TargetFramework=CompactFramework\3.5 /p:Configuration=Release |
| 173 | + |
| 174 | +msbuild fsharp-compiler-build.proj /p:TargetFramework=cli\2.0 /p:Configuration=Release |
| 175 | + |
| 176 | +ngen install ..\Release\cli\2.0\bin\fsi.exe |
| 177 | +..\Release\cli\2.0\bin\fsi.exe |
| 178 | +1 + 1;; |
| 179 | +#q;; |
| 180 | +..\Release\cli\2.0\bin\fsi.exe /help |
| 181 | +..\Release\cli\2.0\bin\fsc.exe /help |
| 182 | +echo printfn "hello world" > hello.fs |
| 183 | +..\Release\cli\2.0\bin\fsc.exe hello.fs |
| 184 | +copy ..\Release\cli\2.0\bin\FSharp.Core.dll . |
| 185 | +hello.exe |
| 186 | +del /q FSharp.Core.dll |
| 187 | +"c:\Program Files\Mono-2.8\bin\mono.exe" ..\Release\cli\2.0\bin\Fsi.exe /help |
| 188 | +"c:\Program Files\Mono-2.8\bin\mono.exe" ..\Release\cli\2.0\bin\Fsc.exe /help |
| 189 | +"c:\Program Files\Mono-2.8\bin\mono.exe" ..\Release\cli\2.0\bin\Fsi.exe < hello.fs |
| 190 | +"c:\Program Files\Mono-2.8\bin\mono.exe" ..\Release\cli\2.0\bin\Fsc.exe hello.fs |
| 191 | + |
| 192 | +##Editing and Building on Windows using Visual Studio 2010 |
| 193 | +###Prerequisites |
| 194 | + |
| 195 | +* Visual Studio Shell 2010 (with F# CTP MSI added), Visual Studio Professional 2010 or another non-Express version of Visual Studio 2010. |
| 196 | + |
| 197 | +###Editing and Building |
| 198 | + |
| 199 | +Open all-vs2010.sln, and edit in modes Debug or Release. The compiler takes a long time to compile and that can be a bit invasive to the work flow, so it's normally better to do the actual compilation from the command line, see above. |
| 200 | + |
| 201 | +##Building where a Proto compiler is run on Mono 2.8, Windows |
| 202 | + |
| 203 | +This can be useful if you want to prove to yourself that it's possible to build without running the base compiler using .NET CLR. At the moment however the steps below still use MSBuild and compile against the .NET 2.0 reference assemblies. It would need more work to get the build going against the Mono libraries. |
| 204 | + |
| 205 | +###Prerequisites |
| 206 | + |
| 207 | +* An existing F# compiler to start the bootstrap. You can start with the Microsoft F# release, then build a new compiler using that, then throw away the former and just use the compiler(s) you've built from then on. |
| 208 | +* Mono 2.9 for Windows |
| 209 | + |
| 210 | +###Building |
| 211 | + |
| 212 | +See below for some of the sample steps. On Windows it is best to use fsc-mono.bat files to act as a "compiler that just happens to run using Mono". |
| 213 | + |
| 214 | +###Steps - Building a Proto Compiler for Mono or .NET 2.0 (either one) |
| 215 | + |
| 216 | +cd src |
| 217 | +REM Prepare driver batch files that run the corresponding exe using Mono |
| 218 | +copy /y setups\run-as-mono.bat ..\lkg\bin\fsc-mono.bat |
| 219 | +copy /y setups\run-as-mono.bat ..\lkg\FSharp-2.0.50726.900\bin\fslex-mono.bat |
| 220 | +copy /y setups\run-as-mono.bat ..\lkg\FSharp-2.0.50726.900\bin\fsyacc-mono.bat |
| 221 | +msbuild fsharp-proto-build.proj /p:TargetFramework=mono\2.0 |
| 222 | + |
| 223 | +###Steps - Prepare proto compiler for execution on Mono by registering FSharp.Core.dll for the base compiler |
| 224 | + |
| 225 | + |
| 226 | +copy /y "C:\Program Files\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v2.0\FSharp.Core.dll" setups\FSharp.Core.dll |
| 227 | +"C:\Program Files\Mono-2.8\bin\sn" -R setups\FSharp.Core.dll setups\mono.snk |
| 228 | +"C:\Program Files\Mono-2.8\bin\gacutil" /i setups\FSharp.Core.dll |
| 229 | +del setups\FSharp.Core.dll |
| 230 | + |
| 231 | +###Steps - Prepare driver batch files that run the corresponding exe with mono |
| 232 | + |
| 233 | +copy /y setups\run-as-mono.bat ..\Proto\cli\2.0\bin\fsc-proto-mono.bat |
| 234 | +copy /y setups\run-as-mono.bat ..\lkg\FSharp-2.0.50726.900\bin\fslex-mono.bat |
| 235 | +copy /y setups\run-as-mono.bat ..\lkg\FSharp-2.0.50726.900\bin\fsyacc-mono.bat |
| 236 | + |
| 237 | +###Steps - Build the core library using the proto compiler, running the proto with Mono on Windows |
| 238 | + |
| 239 | +msbuild fsharp-library-build.proj /p:TargetFramework=mono\2.0 |
| 240 | + |
| 241 | +###Steps - Bootstrap the compiler using the proto compiler, running the proto with Mono on Windows |
| 242 | + |
| 243 | +msbuild fsharp-compiler-build.proj /p:TargetFramework=mono\2.0 |
| 244 | + |
| 245 | +###Validation and Use |
| 246 | + |
| 247 | +"c:\Program Files\Mono-2.8\bin\mono.exe" ..\Debug\mono\2.0\bin\fsi.exe |
| 248 | +1 + 1;; |
| 249 | +#q;; |
| 250 | +"c:\Program Files\Mono-2.8\bin\mono.exe" ..\Debug\mono\2.0\bin\fsi.exe /help |
| 251 | +"c:\Program Files\Mono-2.8\bin\mono.exe" ..\Debug\mono\2.0\bin\fsc.exe /help |
| 252 | +echo printfn "hello world" > hello.fs |
| 253 | +"c:\Program Files\Mono-2.8\bin\mono.exe" ..\Debug\mono\2.0\bin\fsc.exe hello.fs |
| 254 | +copy ..\Debug\mono\2.0\bin\FSharp.Core.dll . |
| 255 | +"c:\Program Files\Mono-2.8\bin\mono.exe" hello.exe |
| 256 | +del /q FSharp.Core.dll |
| 257 | + |
| 258 | + |
| 259 | +###Building on Unix with Mono |
| 260 | + |
| 261 | +Because of some issues with xbuild, some shell scripts are provided to build the compiler on Unix. You may need to adapt the paths in config.sh first. |
| 262 | + |
| 263 | +./make_proto.sh |
| 264 | +./make_library.sh |
| 265 | +./make_compiler.sh |