Browse Source

F#: add MathNet.Numerics.fsx script to packages for simpler usage in scripts+FSI, with formatters

pull/225/head
Christoph Ruegg 12 years ago
parent
commit
701d5b6c3a
  1. 37
      build.fsx
  2. 27
      src/FSharp/FSharp-Portable344.fsproj
  3. 27
      src/FSharp/FSharp-Portable47.fsproj
  4. 15
      src/FSharp/FSharp.fsproj
  5. 8
      src/FSharp/MathNet.Numerics.fsx

37
build.fsx

@ -93,6 +93,8 @@ let fsharpPack =
Files = [ @"..\..\out\lib\Net40\MathNet.Numerics.FSharp.*", Some libnet40, None;
@"..\..\out\lib\Profile47\MathNet.Numerics.FSharp.*", Some libpcl47, None;
@"..\..\out\lib\Profile344\MathNet.Numerics.FSharp.*", Some libpcl344, None;
@"..\..\out\lib\Profile344\MathNet.Numerics.FSharp.*", Some libpcl344, None;
@"MathNet.Numerics.fsx", None, None;
@"..\..\src\FSharp\**\*.fs", Some "src/Common", None ] }
let numericsSignedPack =
@ -110,6 +112,7 @@ let fsharpSignedPack =
Tags = fsharpPack.Tags + " signed"
Dependencies = [ "MathNet.Numerics.Signed", packageVersion ]
Files = [ @"..\..\out\lib-signed\Net40\MathNet.Numerics.FSharp.*", Some libnet40, None;
@"MathNet.Numerics.fsx", None, None;
@"..\..\src\FSharp\**\*.fs", Some "src/Common", None ] }
@ -307,6 +310,20 @@ Target "DataTest" (fun _ -> test !! "out/Data/test/**/*UnitTests*.dll")
// PACKAGES
// --------------------------------------------------------------------------------------
let provideFsharpScript path =
// inspired by FsLab/tpetricek
let fullScript = ReadFile "src/FSharp/MathNet.Numerics.fsx" |> Array.ofSeq
let startIndex = fullScript |> Seq.findIndex (fun s -> s.Contains "***MathNet.Numerics.fsx***")
let extraScript = fullScript .[startIndex + 1 ..] |> List.ofSeq
let assemblies = [ "MathNet.Numerics.dll"; "MathNet.Numerics.FSharp.dll" ]
let packages = [ numericsPack; fsharpPack ]
let roots = [ ""; "../"; "../../"; "../../../" ]
let nowarn = ["#nowarn \"211\""]
let zipIncludes = [ for root in roots -> sprintf "#I \"%sNet40\"" root ]
let nugetIncludes = [ for root in roots do for package in packages -> sprintf "#I \"%spackages/%s.%s/lib/net40/\"" root package.Id package.Version ]
let references = [ for assembly in assemblies -> sprintf "#r \"%s\"" assembly ]
ReplaceFile (path @@ "MathNet.Numerics.fsx") (nowarn @ zipIncludes @ nugetIncludes @ references @ extraScript |> toLines)
let provideLicenseReadme title license releasenotes path =
let licensePath = path @@ "license.txt"
let readmePath = path @@ "readme.txt"
@ -316,9 +333,11 @@ let provideLicenseReadme title license releasenotes path =
String.concat Environment.NewLine [header; " " + title; ""; ReadFileAsString readmePath]
|> ConvertTextToWindowsLineBreaks
|> ReplaceFile readmePath
let provideCoreFiles = provideLicenseReadme (sprintf "Math.NET Numerics v%s" packageVersion) "LICENSE.md" "RELEASENOTES.md"
let provideNativeFiles = provideLicenseReadme (sprintf "Math.NET Numerics Native Providers v%s" nativePackageVersion) "LICENSE.md" "RELEASENOTES-Native.md"
let provideDataFiles = provideLicenseReadme (sprintf "Math.NET Numerics Data Extensions v%s" dataPackageVersion) "LICENSE.md" "RELEASENOTES-Data.md"
let provideCoreFiles = provideLicenseReadme (sprintf "Math.NET Numerics v%s" packageVersion) "LICENSE.md" "RELEASENOTES.md"
let provideCoreAndFsharpFiles path = provideCoreFiles path; provideFsharpScript path
// ZIP
@ -327,11 +346,11 @@ Target "Zip" (fun _ ->
CleanDir "obj/Zip"
if not (hasBuildParam "signed") || hasBuildParam "release" then
CopyDir "obj/Zip/MathNet.Numerics" "out/lib" (fun f -> f.Contains("MathNet.Numerics."))
provideCoreFiles "obj/Zip/MathNet.Numerics"
provideCoreAndFsharpFiles "obj/Zip/MathNet.Numerics"
Zip "obj/Zip/" (sprintf "out/packages/Zip/MathNet.Numerics-%s.zip" packageVersion) !! "obj/Zip/MathNet.Numerics/**/*.*"
if hasBuildParam "signed" || hasBuildParam "release" then
CopyDir "obj/Zip/MathNet.Numerics.Signed" "out/lib-signed" (fun f -> f.Contains("MathNet.Numerics."))
provideCoreFiles "obj/Zip/MathNet.Numerics.Signed"
provideCoreAndFsharpFiles "obj/Zip/MathNet.Numerics.Signed"
Zip "obj/Zip/" (sprintf "out/packages/Zip/MathNet.Numerics.Signed-%s.zip" packageVersion) !! "obj/Zip/MathNet.Numerics.Signed/**/*.*"
CleanDir "obj/Zip")
"Build" ==> "Zip"
@ -373,9 +392,9 @@ let updateNuspec pack outPath symbols updateFiles spec =
Files = updateFiles pack.Files
Publish = false }
let nugetPack pack outPath =
let nugetPack pack extraFiles outPath =
CleanDir "obj/NuGet"
provideCoreFiles "obj/NuGet"
extraFiles "obj/NuGet"
let withLicenseReadme f = [ "license.txt", None, None; "readme.txt", None, None; ] @ f
let withoutSymbolsSources f =
List.choose (function | (_, Some (target:string), _) when target.StartsWith("src") -> None
@ -396,11 +415,11 @@ Target "NuGet" (fun _ ->
let outPath = "out/packages/NuGet"
CleanDir outPath
if hasBuildParam "signed" || hasBuildParam "release" then
nugetPack numericsSignedPack outPath
nugetPack fsharpSignedPack outPath
nugetPack numericsSignedPack provideCoreFiles outPath
nugetPack fsharpSignedPack provideCoreAndFsharpFiles outPath
if hasBuildParam "all" || hasBuildParam "release" then
nugetPack numericsPack outPath
nugetPack fsharpPack outPath
nugetPack numericsPack provideCoreFiles outPath
nugetPack fsharpPack provideCoreAndFsharpFiles outPath
CleanDir "obj/NuGet")
"Build" ==> "NuGet"

27
src/FSharp/FSharp-Portable344.fsproj

@ -37,13 +37,13 @@
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="FSharp.Core">
<Name>FSharp.Core</Name>
<AssemblyName>FSharp.Core.dll</AssemblyName>
<HintPath>$(MSBuildExtensionsPath32)\..\Reference Assemblies\Microsoft\FSharp\.NETPortable\$(TargetFSharpCoreVersion)\FSharp.Core.dll</HintPath>
</Reference>
</ItemGroup>
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.Portable.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)' == '11.0' Or $(OS) != 'Windows_NT'">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.Portable.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="Statistics.fs" />
@ -59,18 +59,17 @@
<Compile Include="Fit.fs" />
<Compile Include="FindRoots.fs" />
<Compile Include="RandomVariable.fs" />
<None Include="MathNet.Numerics.fsx" />
</ItemGroup>
<ItemGroup>
<Reference Include="FSharp.Core">
<Name>FSharp.Core</Name>
<AssemblyName>FSharp.Core.dll</AssemblyName>
<HintPath>$(MSBuildExtensionsPath32)\..\Reference Assemblies\Microsoft\FSharp\.NETPortable\$(TargetFSharpCoreVersion)\FSharp.Core.dll</HintPath>
</Reference>
<ProjectReference Include="..\Numerics\Numerics-Portable344.csproj">
<Name>Numerics-Portable344</Name>
<Project>{1A3065FD-105D-4AF1-85B9-0A4A26FFB353}</Project>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.Portable.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)' == '11.0' Or $(OS) != 'Windows_NT'">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.Portable.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />
</Project>

27
src/FSharp/FSharp-Portable47.fsproj

@ -37,13 +37,13 @@
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="FSharp.Core">
<Name>FSharp.Core</Name>
<AssemblyName>FSharp.Core.dll</AssemblyName>
<HintPath>$(MSBuildExtensionsPath32)\..\Reference Assemblies\Microsoft\FSharp\.NETPortable\$(TargetFSharpCoreVersion)\FSharp.Core.dll</HintPath>
</Reference>
</ItemGroup>
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.Portable.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)' == '11.0' Or $(OS) != 'Windows_NT'">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.Portable.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="Statistics.fs" />
@ -59,18 +59,17 @@
<Compile Include="Fit.fs" />
<Compile Include="FindRoots.fs" />
<Compile Include="RandomVariable.fs" />
<None Include="MathNet.Numerics.fsx" />
</ItemGroup>
<ItemGroup>
<Reference Include="FSharp.Core">
<Name>FSharp.Core</Name>
<AssemblyName>FSharp.Core.dll</AssemblyName>
<HintPath>$(MSBuildExtensionsPath32)\..\Reference Assemblies\Microsoft\FSharp\.NETPortable\$(TargetFSharpCoreVersion)\FSharp.Core.dll</HintPath>
</Reference>
<ProjectReference Include="..\Numerics\Numerics-Portable47.csproj">
<Name>Numerics-Portable47</Name>
<Project>{49205185-621E-FFB9-2104-887C9F1BBD13}</Project>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.Portable.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)' == '11.0' Or $(OS) != 'Windows_NT'">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.Portable.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />
</Project>

15
src/FSharp/FSharp.fsproj

@ -50,6 +50,13 @@
<!-- Conditional Strong Name: YES -->
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)' == '11.0' Or $(OS) != 'Windows_NT'">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="Statistics.fs" />
@ -65,6 +72,7 @@
<Compile Include="Fit.fs" />
<Compile Include="FindRoots.fs" />
<Compile Include="RandomVariable.fs" />
<None Include="MathNet.Numerics.fsx" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib" />
@ -77,11 +85,4 @@
</ProjectReference>
<Reference Include="FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</ItemGroup>
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)' == '11.0' Or $(OS) != 'Windows_NT'">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />
</Project>

8
src/FSharp/MathNet.Numerics.fsx

@ -0,0 +1,8 @@
#I "../../out/lib/Net40"
#r "MathNet.Numerics.dll"
#r "MathNet.Numerics.FSharp.dll"
// ***MathNet.Numerics.fsx*** (DO NOT REMOVE THIS COMMENT, everything below is copied to the output)
fsi.AddPrinter(fun (matrix:MathNet.Numerics.LinearAlgebra.Matrix<_>) -> matrix.ToString())
fsi.AddPrinter(fun (vector:MathNet.Numerics.LinearAlgebra.Vector<_>) -> vector.ToString())
Loading…
Cancel
Save