<commit_before>//  __  __       _   _       _   _ ______ _______
// |  \/  |     | | | |     | \ | |  ____|__   __|
// | \  / | __ _| |_| |__   |  \| | |__     | |
// | |\/| |/ _` | __| '_ \  | . ` |  __|    | |
// | |  | | (_| | |_| | | |_| |\  | |____   | |
// |_|  |_|\__,_|\__|_| |_(_)_| \_|______|  |_|
//
// Math.NET Symbolics - http://symbolics.mathdotnet.com
// Copyright (c) Math.NET - Open Source MIT/X11 License
//
// FAKE build script, see http://fsharp.github.io/FAKE
//

// --------------------------------------------------------------------------------------
// PRELUDE
// --------------------------------------------------------------------------------------

#I "packages/build/FAKE/tools"
#r "packages/build/FAKE/tools/FakeLib.dll"

open Fake
open Fake.DocuHelper
open Fake.AssemblyInfoFile
open Fake.ReleaseNotesHelper
open Fake.StringHelper
open Fake.Testing.NUnit3
open System
open System.IO

Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
let header = ReadFile(__SOURCE_DIRECTORY__ @@ "build.fsx") |> Seq.take 10 |> Seq.map (fun s -> s.Substring(2)) |> toLines
trace header


// --------------------------------------------------------------------------------------
// PROJECT INFO
// --------------------------------------------------------------------------------------

// VERSION OVERVIEW

let release = LoadReleaseNotes "RELEASENOTES.md"
let buildPart = "0"
let assemblyVersion = release.AssemblyVersion + "." + buildPart
let packageVersion = release.NugetVersion
let releaseNotes = release.Notes |> List.map (fun l -> l.Replace("*","").Replace("`","")) |> toLines
trace (sprintf " Math.NET Symbolics  v%s" packageVersion)
trace ""


// CORE PACKAGES

type Package =
    { Id: string
      Version: string
      Title: string
      Summary: string
      Description: string
      ReleaseNotes: string
      Tags: string
      Authors: string list
      Dependencies: (string*string) list
      Files: (string * string option * string option) list }

type Bundle =
    { Id: string
      Version: string
      Title: string
      ReleaseNotesFile: string
      FsLoader: bool
      Packages: Package list }

let summary = "Math.NET Symbolics is a basic open source computer algebra library for .Net and Mono. Written in F# but works well in C# as well."
let description = "Math.NET Symbolics is a basic open source computer algebra library. Written in F# but works well in C# as well. "
let support = "Supports .Net 4.0 and Mono on Windows, Linux and Mac."
let tags = "math symbolics algebra simplify solve cas fsharp parse"

let libnet40 = "lib/net40"
let libnet45 = "lib/net45"
let libpcl47 = "lib/portable-net45+sl5+netcore45+MonoAndroid1+MonoTouch1"
let libpcl344 = "lib/portable-net45+sl5+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1"

let symbolicsPack =
    { Id = "MathNet.Symbolics"
      Version = packageVersion
      Title = "Math.NET Symbolics"
      Summary = summary
      Description = description + support
      ReleaseNotes = releaseNotes
      Tags = tags
      Authors = [ "<NAME>" ]
      Dependencies =
        [ "FParsec", GetPackageVersion "packages" "FParsec"
          "FSharp.Core", GetPackageVersion "packages" "FSharp.Core"
          "MathNet.Numerics", GetPackageVersion "packages" "MathNet.Numerics"
          "MathNet.Numerics.FSharp", GetPackageVersion "packages" "MathNet.Numerics.FSharp" ]
      Files =
        [ @"..\..\out\lib\Net40\MathNet.Symbolics.*", Some libnet40, None;
          @"..\..\out\lib\Profile47\MathNet.Symbolics.*", Some libpcl47, None;
          @"..\..\out\lib\Profile344\MathNet.Symbolics.*", Some libpcl344, None;
          @"MathNet.Symbolics.fsx", None, None;
          @"..\..\src\Symbolics\**\*.fs", Some "src/Common", None ] }

let coreBundle =
    { Id = symbolicsPack.Id
      Version = packageVersion
      Title = symbolicsPack.Title
      ReleaseNotesFile = "RELEASENOTES.md"
      FsLoader = true
      Packages = [ symbolicsPack ] }


// --------------------------------------------------------------------------------------
// PREPARE
// --------------------------------------------------------------------------------------

Target "Start" DoNothing

Target "Clean" (fun _ ->
    CleanDirs [ "obj" ]
    CleanDirs [ "out/api"; "out/docs"; "out/packages" ]
    CleanDirs [ "out/lib/Net40"; "out/lib/Profile47"; "out/lib/Profile344" ]
    CleanDirs [ "out/test/Net40"; "out/test/Profile47"; "out/test/Profile344" ])

Target "ApplyVersion" (fun _ ->
    let patchAssemblyInfo path assemblyVersion packageVersion =
        BulkReplaceAssemblyInfoVersions path (fun f ->
            { f with
                AssemblyVersion = assemblyVersion
                AssemblyFileVersion = assemblyVersion
                AssemblyInformationalVersion = packageVersion })
    patchAssemblyInfo "src/Symbolics" assemblyVersion packageVersion
    patchAssemblyInfo "src/SymbolicsUnitTests" assemblyVersion packageVersion)

Target "Prepare" DoNothing
"Start"
  =?> ("Clean", not (hasBuildParam "incremental"))
  ==> "ApplyVersion"
  ==> "Prepare"


// --------------------------------------------------------------------------------------
// BUILD
// --------------------------------------------------------------------------------------

let buildConfig config subject = MSBuild "" (if hasBuildParam "incremental" then "Build" else "Rebuild") [ "Configuration", config ] subject |> ignore
let build subject = buildConfig "Release" subject

Target "BuildMain" (fun _ -> build !! "MathNet.Symbolics.sln")
Target "BuildAll" (fun _ -> build !! "MathNet.Symbolics.All.sln")

Target "Build" DoNothing
"Prepare"
  =?> ("BuildAll", hasBuildParam "all" || hasBuildParam "release")
  =?> ("BuildMain", not (hasBuildParam "all" || hasBuildParam "release"))
  ==> "Build"


// --------------------------------------------------------------------------------------
// TEST
// --------------------------------------------------------------------------------------

let test target =
    let quick p = if hasBuildParam "quick" then { p with Where="!~LongRunning" } else p
    NUnit3 (fun p ->
        { p with
            ShadowCopy = false
            TimeOut = TimeSpan.FromMinutes 30. } |> quick) target

Target "Test" (fun _ -> test !! "out/test/**/*UnitTests*.dll")
"Build" ?=> "Test"


// --------------------------------------------------------------------------------------
// PACKAGES<commit_msg>Build: fix 'test quick' test category filter<commit_after>//  __  __       _   _       _   _ ______ _______
// |  \/  |     | | | |     | \ | |  ____|__   __|
// | \  / | __ _| |_| |__   |  \| | |__     | |
// | |\/| |/ _` | __| '_ \  | . ` |  __|    | |
// | |  | | (_| | |_| | | |_| |\  | |____   | |
// |_|  |_|\__,_|\__|_| |_(_)_| \_|______|  |_|
//
// Math.NET Symbolics - http://symbolics.mathdotnet.com
// Copyright (c) Math.NET - Open Source MIT/X11 License
//
// FAKE build script, see http://fsharp.github.io/FAKE
//

// --------------------------------------------------------------------------------------
// PRELUDE
// --------------------------------------------------------------------------------------

#I "packages/build/FAKE/tools"
#r "packages/build/FAKE/tools/FakeLib.dll"

open Fake
open Fake.DocuHelper
open Fake.AssemblyInfoFile
open Fake.ReleaseNotesHelper
open Fake.StringHelper
open Fake.Testing.NUnit3
open System
open System.IO

Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
let header = ReadFile(__SOURCE_DIRECTORY__ @@ "build.fsx") |> Seq.take 10 |> Seq.map (fun s -> s.Substring(2)) |> toLines
trace header


// --------------------------------------------------------------------------------------
// PROJECT INFO
// --------------------------------------------------------------------------------------

// VERSION OVERVIEW

let release = LoadReleaseNotes "RELEASENOTES.md"
let buildPart = "0"
let assemblyVersion = release.AssemblyVersion + "." + buildPart
let packageVersion = release.NugetVersion
let releaseNotes = release.Notes |> List.map (fun l -> l.Replace("*","").Replace("`","")) |> toLines
trace (sprintf " Math.NET Symbolics  v%s" packageVersion)
trace ""


// CORE PACKAGES

type Package =
    { Id: string
      Version: string
      Title: string
      Summary: string
      Description: string
      ReleaseNotes: string
      Tags: string
      Authors: string list
      Dependencies: (string*string) list
      Files: (string * string option * string option) list }

type Bundle =
    { Id: string
      Version: string
      Title: string
      ReleaseNotesFile: string
      FsLoader: bool
      Packages: Package list }

let summary = "Math.NET Symbolics is a basic open source computer algebra library for .Net and Mono. Written in F# but works well in C# as well."
let description = "Math.NET Symbolics is a basic open source computer algebra library. Written in F# but works well in C# as well. "
let support = "Supports .Net 4.0 and Mono on Windows, Linux and Mac."
let tags = "math symbolics algebra simplify solve cas fsharp parse"

let libnet40 = "lib/net40"
let libnet45 = "lib/net45"
let libpcl47 = "lib/portable-net45+sl5+netcore45+MonoAndroid1+MonoTouch1"
let libpcl344 = "lib/portable-net45+sl5+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1"

let symbolicsPack =
    { Id = "MathNet.Symbolics"
      Version = packageVersion
      Title = "Math.NET Symbolics"
      Summary = summary
      Description = description + support
      ReleaseNotes = releaseNotes
      Tags = tags
      Authors = [ "<NAME>" ]
      Dependencies =
        [ "FParsec", GetPackageVersion "packages" "FParsec"
          "FSharp.Core", GetPackageVersion "packages" "FSharp.Core"
          "MathNet.Numerics", GetPackageVersion "packages" "MathNet.Numerics"
          "MathNet.Numerics.FSharp", GetPackageVersion "packages" "MathNet.Numerics.FSharp" ]
      Files =
        [ @"..\..\out\lib\Net40\MathNet.Symbolics.*", Some libnet40, None;
          @"..\..\out\lib\Profile47\MathNet.Symbolics.*", Some libpcl47, None;
          @"..\..\out\lib\Profile344\MathNet.Symbolics.*", Some libpcl344, None;
          @"MathNet.Symbolics.fsx", None, None;
          @"..\..\src\Symbolics\**\*.fs", Some "src/Common", None ] }

let coreBundle =
    { Id = symbolicsPack.Id
      Version = packageVersion
      Title = symbolicsPack.Title
      ReleaseNotesFile = "RELEASENOTES.md"
      FsLoader = true
      Packages = [ symbolicsPack ] }


// --------------------------------------------------------------------------------------
// PREPARE
// --------------------------------------------------------------------------------------

Target "Start" DoNothing

Target "Clean" (fun _ ->
    CleanDirs [ "obj" ]
    CleanDirs [ "out/api"; "out/docs"; "out/packages" ]
    CleanDirs [ "out/lib/Net40"; "out/lib/Profile47"; "out/lib/Profile344" ]
    CleanDirs [ "out/test/Net40"; "out/test/Profile47"; "out/test/Profile344" ])

Target "ApplyVersion" (fun _ ->
    let patchAssemblyInfo path assemblyVersion packageVersion =
        BulkReplaceAssemblyInfoVersions path (fun f ->
            { f with
                AssemblyVersion = assemblyVersion
                AssemblyFileVersion = assemblyVersion
                AssemblyInformationalVersion = packageVersion })
    patchAssemblyInfo "src/Symbolics" assemblyVersion packageVersion
    patchAssemblyInfo "src/SymbolicsUnitTests" assemblyVersion packageVersion)

Target "Prepare" DoNothing
"Start"
  =?> ("Clean", not (hasBuildParam "incremental"))
  ==> "ApplyVersion"
  ==> "Prepare"


// --------------------------------------------------------------------------------------
// BUILD
// --------------------------------------------------------------------------------------

let buildConfig config subject = MSBuild "" (if hasBuildParam "incremental" then "Build" else "Rebuild") [ "Configuration", config ] subject |> ignore
let build subject = buildConfig "Release" subject

Target "BuildMain" (fun _ -> build !! "MathNet.Symbolics.sln")
Target "BuildAll" (fun _ -> build !! "MathNet.Symbolics.All.sln")

Target "Build" DoNothing
"Prepare"
  =?> ("BuildAll", hasBuildParam "all" || hasBuildParam "release")
  =?> ("BuildMain", not (hasBuildParam "all" || hasBuildParam "release"))
  ==> "Build"


// --------------------------------------------------------------------------------------
// TEST
// --------------------------------------------------------------------------------------

let test target =
    let quick p = if hasBuildParam "quick" then { p with Where="cat!=LongRunning" } else p
    NUnit3 (fun p ->
        { p with
            ShadowCopy = false
            TimeOut = TimeSpan.FromMinutes 30. } |> quick) target

Target "Test" (fun _ -> test !! "out/test/**/*UnitTests*.dll")
"Build" ?=> "Test"


// --------------------------------------------------------------------------------------
// PACKAGES
{'fraction_non_alphanumeric': 0.266494684177611, 'fraction_numerical': 0.010944340212632896, 'mean_word_length': 1.7271370709869964, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6901087', 'n_tokens_mistral': 3712, 'n_tokens_neox': 3489, 'n_words': 861}