forked from mono/monodevelop
-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathbuild.fsx
More file actions
executable file
·124 lines (101 loc) · 3.91 KB
/
Copy pathbuild.fsx
File metadata and controls
executable file
·124 lines (101 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#r @"./packages/FAKE/tools/FakeLib.dll"
#r "System.Xml"
#r "System.Xml.Linq"
open Fake
open System.IO
open System
open System.Linq
open System.Xml.Linq
let isWindows = (Path.DirectorySeparatorChar = '\\')
let config = "Release"
Target "Default" (fun _ ->
MSBuildWithDefaults "Build" ["./MonoDevelop.FSharp.sln"]
|> Log "AppBuild-Output: "
)
let mdpath = "../../build/bin/mdtool.exe"
let mdtool args =
let result =
if isWindows then
Shell.Exec (mdpath, args)
else
Shell.Exec ("mono64", mdpath + " " + args)
result |> ignore
let test() =
mdtool ("run-md-tests ../../build/tests/MonoDevelop.FSharp.Tests.dll -labels")
Target "Pack" (fun _ ->
let dir = "pack/" + config
if Directory.Exists dir then
Directory.Delete (dir, true)
Directory.CreateDirectory dir |> ignore
mdtool ("setup pack bin/FSharpBinding.dll -d:pack/" + config)
)
Target "Install" (fun _ ->
let versionConfig = File.ReadAllLines("../../../version.config")
let version = versionConfig.[0].Replace("Version=", "")
mdtool ("setup install -y pack/" + config + "/MonoDevelop.FSharpBinding_" + version + ".mpack")
)
Target "BuildAndTest" (fun _ ->
test()
)
Target "Test" (fun _ ->
test()
)
Target "Run" (fun _ ->
Shell.Exec ("make", "run", "../..") |> ignore
)
Target "GenerateFastBuildProjects" (fun _ ->
let (/) a b = Path.Combine(a, b)
let nsuri = "http://schemas.microsoft.com/developer/msbuild/2003"
let absoluteFromRelative (projectPath: string) relPath =
let projectFolder = Path.GetDirectoryName projectPath
let full = projectFolder / relPath
Uri(full).LocalPath |> Path.GetFullPath
let path = __SOURCE_DIRECTORY__
let projects =
Directory.GetFiles(path, "*.fsproj", SearchOption.AllDirectories)
|> Array.filter(fun p -> not (p.Contains "Samples" || p.Contains "fastbuild"))
for projectPath in projects do
printfn "Processing %s" projectPath
let projectFolderUri = Uri(projectPath)
let ns = XNamespace.Get nsuri
let doc = XDocument.Load projectPath
let references = doc.Descendants(ns + "ProjectReference").ToList()
let firstOrDefault seq = Enumerable.FirstOrDefault(seq)
for re in references do
let inc = re.Attribute(XName.Get "Include").Value
printfn "Processing %s" (inc.ToString())
let fullPath = absoluteFromRelative projectPath inc
let projectFolder = Path.GetDirectoryName fullPath
let referenced = XDocument.Load fullPath
let getDescendant name =
referenced.Descendants(ns + name)
|> Seq.tryHead
|> Option.map(fun d -> d.Value)
let assemblyName =
match getDescendant "AssemblyName" with
| Some name -> name
| None -> Path.GetFileNameWithoutExtension fullPath
let outputPath =
match Path.GetFileNameWithoutExtension(fullPath) with
| "MonoDevelop.PackageManagement.Tests" -> @"..\..\..\..\build\tests"
| "MonoDevelop.PackageManagement" -> @"..\..\..\build\AddIns\MonoDevelop.PackageManagement"
| _ -> (getDescendant "OutputPath").Value
let outputExtension = if getDescendant "OutputType" = (Some "Exe") then ".exe" else ".dll"
let hintPath = projectFolder/outputPath/(assemblyName + outputExtension)
let hintPathUri = Uri(hintPath)
let hintPathAbsolute = hintPathUri.LocalPath |> Path.GetFullPath
if not (File.Exists hintPathAbsolute) then
failwithf "Did not find %s" hintPathAbsolute
let relativeHintPath = projectFolderUri.MakeRelativeUri(hintPathUri).ToString().Replace("/", "\\")
let replacement = XElement(ns + "Reference", XAttribute((XName.Get "Include"), assemblyName), XElement(ns + "HintPath", relativeHintPath))
re.ReplaceWith replacement
let fastbuildPath = projectPath.Replace(".fsproj", ".fastbuild.fsproj")
printfn "Saving %s" fastbuildPath
doc.Save fastbuildPath)
"Default"
==> "BuildAndTest"
"Default"
==> "Run"
"Pack"
==> "Install"
RunTargetOrDefault "Default"