1 // --------------------------------------------------------------------------------------
3 // --------------------------------------------------------------------------------------
5 #r @"packages/FAKE/tools/FakeLib.dll"
8 open Fake.AssemblyInfoFile
9 open Fake.ReleaseNotesHelper
10 open Fake.UserInputHelper
14 open System.Diagnostics
16 // --------------------------------------------------------------------------------------
17 // START TODO: Provide project-specific details below
18 // --------------------------------------------------------------------------------------
20 // Information about the project are used
21 // - for version and project name in generated AssemblyInfo file
22 // - by the generated NuGet package
23 // - to run tests and to publish documentation on GitHub gh-pages
24 // - for documentation, you also need to edit info in "docs/tools/generate.fsx"
26 // The name of the project
27 // (used by attributes in AssemblyInfo, name of a NuGet package and directory in 'src')
28 let project = "OpenTK"
30 // Short summary of the project
31 // (used as description in AssemblyInfo and as a short summary for NuGet package)
32 let summary = "A set of fast, low-level C# bindings for OpenGL, OpenGL ES and OpenAL."
34 // Longer description of the project
35 // (used as a description for NuGet package; line breaks are automatically cleaned up)
36 let description = "The Open Toolkit is set of fast, low-level C# bindings for OpenGL, OpenGL ES and OpenAL. It runs on all major platforms and powers hundreds of apps, games and scientific research."
38 // List of author names (for NuGet package)
39 let authors = [ "Stefanos Apostolopoulos" ]
41 // Tags for your project (for NuGet package)
42 let tags = "OpenTK OpenGL OpenGLES GLES OpenAL C# F# VB .NET Mono Vector Math Game Graphics Sound"
44 let copyright = "Copyright (c) 2006 - 2016 Stefanos Apostolopoulos <stapostol@gmail.com> for the Open Toolkit library."
46 // File system information
47 let solutionFile = "OpenTK.sln"
49 // Pattern specifying assemblies to be tested using NUnit
50 let testAssemblies = "tests/**/bin/Release/*Tests*.dll"
52 // Git configuration (used for publishing documentation in gh-pages branch)
53 // The profile where the project is posted
54 let gitOwner = "opentk"
55 let gitHome = "https://github.com/" + gitOwner
57 // The name of the project on GitHub
58 let gitName = "opentk"
60 // The url for the raw files hosted
61 let gitRaw = environVarOrDefault "gitRaw" "https://raw.github.com/opentk"
63 // --------------------------------------------------------------------------------------
64 // END TODO: The rest of the file includes standard build steps
65 // --------------------------------------------------------------------------------------
67 // Read additional information from the release notes document
68 let release = LoadReleaseNotes "RELEASE_NOTES.md"
70 let isXamarinPlatform = false //EnvironmentHelper.isMacOS || Environment.OSVersion.Platform = PlatformID.Win32NT
73 // Helper active pattern for project types
74 let (|Fsproj|Csproj|Vbproj|) (projFileName:string) =
75 match projFileName with
76 | f when f.EndsWith "fsproj" -> Fsproj
77 | f when f.EndsWith "csproj" -> Csproj
78 | f when f.EndsWith "vbproj" -> Vbproj
79 | _ -> failwith (sprintf "Project file %s not supported. Unknown project type." projFileName)
83 !! "src/Generator.*/**.csproj"
87 if isXamarinPlatform then
91 -- "**/OpenTK.Android.csproj"
92 -- "**/OpenTK.iOS.csproj"
95 ++ "tests/**/OpenTK.Tests*.??proj"
96 -- "src/Generator.*/**.csproj"
100 Seq.concat [buildProjects; runtimeProjects]
103 // Generate assembly info files with the right version & up-to-date information
104 Target "AssemblyInfo" (fun _ ->
105 let getAssemblyInfoAttributes (projectName:string) =
107 if projectName.Contains(".iOS") || projectName.Contains(".Android") then
108 projectName.Split('.').[0]
111 [ Attribute.Title (projectName)
112 Attribute.Product project
113 Attribute.Description summary
114 Attribute.Version release.AssemblyVersion
115 Attribute.FileVersion release.AssemblyVersion
116 Attribute.CLSCompliant true
117 Attribute.Copyright copyright
120 let getProjectDetails projectPath =
121 let projectName = System.IO.Path.GetFileNameWithoutExtension(projectPath)
124 System.IO.Path.GetDirectoryName(projectPath),
125 (getAssemblyInfoAttributes projectName)
129 |> Seq.map getProjectDetails
130 |> Seq.iter (fun (projFileName, projectName, folderName, attributes) ->
131 match projFileName with
132 | Fsproj -> CreateFSharpAssemblyInfo (folderName @@ "AssemblyInfo.fs") attributes
133 | Csproj -> CreateCSharpAssemblyInfo ((folderName @@ "Properties") @@ "AssemblyInfo.cs") attributes
134 | Vbproj -> CreateVisualBasicAssemblyInfo ((folderName @@ "My Project") @@ "AssemblyInfo.vb") attributes
138 // Copies binaries from default VS location to expected bin folder
139 // But keeps a subdirectory structure for each project in the
140 // src folder to support multiple project outputs
141 Target "CopyBinaries" (fun _ ->
143 |> Seq.map (fun f -> ((System.IO.Path.GetDirectoryName f) @@ "bin/Release", "bin" @@ (System.IO.Path.GetFileNameWithoutExtension f)))
144 |> Seq.iter (fun (fromDir, toDir) -> CopyDir toDir fromDir (fun _ -> true))
147 // --------------------------------------------------------------------------------------
148 // Clean build results
150 Target "Clean" (fun _ ->
151 CleanDirs ["bin"; "temp"]
154 // --------------------------------------------------------------------------------------
155 // Build generator projects, and generate bindings if neccesary
156 Target "GenerateBindings" (fun _ ->
157 if not (File.Exists(".bindingsGenerated")) then
159 |> MSBuildRelease "" "Build"
161 let bindingProcess = new Process()
162 bindingProcess.StartInfo.FileName <- Path.Combine("src", "Generator.Bind", "bin", "Release", "Bind.exe")
163 if bindingProcess.Start() then
164 bindingProcess.WaitForExit()
165 File.Create(".bindingsGenerated").Close()
167 failwith "Could not start Bind.exe"
170 // --------------------------------------------------------------------------------------
171 // Build library & test project
173 Target "Build" (fun _ ->
175 |> MSBuildRelease "" "Build"
179 // --------------------------------------------------------------------------------------
180 // Run the unit tests using test runner
182 Target "RunTests" (fun _ ->
187 TimeOut = TimeSpan.FromMinutes 2.
188 XmlOutputPath = Some "TestResults.xml" })
191 // --------------------------------------------------------------------------------------
192 // Build a NuGet package
194 Target "NuGet" (fun _ ->
196 if isXamarinPlatform then
206 ExcludedTemplates = xamExcludes
207 Version = release.NugetVersion
208 ReleaseNotes = toLines release.Notes})
212 Target "BuildPackage" DoNothing
214 // --------------------------------------------------------------------------------------
215 // Run all targets by default. Invoke 'build <Target>' to override
217 Target "All" DoNothing
221 ==> "GenerateBindings"
231 RunTargetOrDefault "All"