This repository has been archived by the owner on Feb 16, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
build.fsx
237 lines (189 loc) · 6.6 KB
/
build.fsx
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
// --------------------------------------------------------------------------------------
// FAKE build script
// --------------------------------------------------------------------------------------
#I "packages/FAKE/tools"
#r "packages/FAKE/tools/FakeLib.dll"
open System
open System.Diagnostics
open System.IO
open Fake
open Fake.Git
open Fake.ProcessHelper
open Fake.ReleaseNotesHelper
open Fake.ZipHelper
#if MONO
#else
#load "src/atom-bindings.fsx"
"src/Core/Control.fs"
"src/Core/DTO.fs"
"src/Core/Logging.fs"
"src/Core/LanguageService.fs"
"src/Components/Parser.fs"
"src/Components/CompletionHelpers.fs"
"src/Components/UnicodeGlyphs.fs"
"src/Components/Autocomplete.fs"
"src/Components/Tooltips.fs"
"src/Components/HighlightUse.fs"
"src/Components/Toolbar.fs"
"src/Components/Errors.fs"
"src/Components/FindDeclaration.fs"
"src/Components/Format.fs"
"src/FSharpIDE.fs"
"src/main.fs"
#endif
// Git configuration (used for publishing documentation in gh-pages branch)
// The profile where the project is posted
let gitOwner = "ionide"
let gitHome = "https://github.com/" + gitOwner
// The name of the project on GitHub
let gitName = "ionide-fsharp"
// The url for the raw files hosted
let gitRaw = environVarOrDefault "gitRaw" "https://raw.github.com/ionide"
let tempReleaseDir = "temp/release"
// Read additional information from the release notes document
let releaseNotesData =
File.ReadAllLines "RELEASE_NOTES.md"
|> parseAllReleaseNotes
let release = List.head releaseNotesData
let msg = release.Notes |> List.fold (fun r s -> r + s + "\n") ""
let releaseMsg = (sprintf "Release %s\n" release.NugetVersion) + msg
let run cmd args dir =
if execProcess( fun info ->
info.FileName <- cmd
if not( String.IsNullOrWhiteSpace dir) then
info.WorkingDirectory <- dir
info.Arguments <- args
) System.TimeSpan.MaxValue = false then
traceError <| sprintf "Error while running '%s' with args: %s" cmd args
let atomPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) </> "atom" </> "bin"
let apmTool, atomTool =
#if MONO
"apm", "atom"
#else
atomPath </> "apm.cmd" , atomPath </> "atom.cmd"
#endif
// --------------------------------------------------------------------------------------
// Build the Generator project and run it
// --------------------------------------------------------------------------------------
Target "Clean" (fun _ ->
CopyFiles "release" ["README.md"; "LICENSE"; "RELEASE_NOTES.md"]
CleanDir tempReleaseDir
)
let fsgrammarDir = "paket-files/github.com/ionide/ionide-fsgrammar/grammar"
let fsgrammarRelease = "release/grammars"
Target "CopyGrammar" (fun _ ->
ensureDirectory fsgrammarRelease
CleanDir fsgrammarRelease
CopyFiles fsgrammarRelease [
fsgrammarDir </> "fsharp.fsi.json"
fsgrammarDir </> "fsharp.fsl.json"
fsgrammarDir </> "fsharp.fsx.json"
fsgrammarDir </> "fsharp.json"
]
)
let fantomasBin = "release/bin-fantomas"
let fantomasPkgDir = "packages/FantomasCLI/lib"
Target "CopyFantomas" (fun _ ->
ensureDirectory fantomasBin
CleanDir fantomasBin
CopyFiles fantomasBin [
fantomasPkgDir </> "Fantomas.exe"
fantomasPkgDir </> "FantomasLib.dll"
fantomasPkgDir </> "FSharp.Core.dll"
fantomasPkgDir </> "FSharp.Compiler.Service.dll"
]
)
let releaseBin = "release/bin"
let fsacBin = "paket-files/github.com/ionide/FsAutoComplete/bin/release"
Target "CopyFSAC" (fun _ ->
ensureDirectory releaseBin
CleanDir releaseBin
!! (fsacBin + "/*")
|> CopyFiles releaseBin
)
Target "BuildGenerator" (fun () ->
[ __SOURCE_DIRECTORY__ @@ "src" @@ "Ionide.FSharp.fsproj" ]
|> MSBuildDebug "" "Rebuild"
|> Log "AppBuild-Output: "
)
Target "RunGenerator" (fun () ->
(TimeSpan.FromMinutes 5.0)
|> ProcessHelper.ExecProcess (fun p ->
p.FileName <- __SOURCE_DIRECTORY__ @@ "src" @@ "bin" @@ "Debug" @@ "Ionide.FSharp.exe" )
|> ignore
)
#if MONO
#else
Target "RunScript" (fun () ->
Atom.FSharp.Generator.translateModules "../release/lib/fsharp.js"
)
#endif
// Installs npm dependencies defined in "release\package.json" to "release\node_modules"
Target "InstallDependencies" (fun _ ->
run apmTool "install" "release"
)
// Creates symbolic link between "release" folder and `Users\XXX\.atom\packages" for the Ionide-FSharp plugin
Target "ApmLink"(fun _ ->
run apmTool "link" "releases"
)
// This should not be the long term way to test out our packages
// TODO switch this target to install to dev and launch atom in dev mode
Target "TryPackage"( fun _ ->
killProcess "atom"
run apmTool "uninstall ionide-fsharp" ""
run apmTool "link" "release"
run atomTool __SOURCE_DIRECTORY__ ""
)
Target "TagDevelopBranch" (fun _ ->
StageAll ""
Git.Commit.Commit "" releaseMsg
Branches.pushBranch "" "origin" "develop"
let tagName = "develop-" + release.NugetVersion
Branches.tag "" tagName
Branches.pushTag "" "origin" tagName
)
Target "PushToMaster" (fun _ ->
CleanDir tempReleaseDir
Repository.cloneSingleBranch "" (gitHome + "/" + gitName + ".git") "master" tempReleaseDir
let cleanEverythingFromLastCheckout() =
let tempGitDir = Path.GetTempPath() </> "gitrelease"
CleanDir tempGitDir
CopyRecursive (tempReleaseDir </> ".git") tempGitDir true |> ignore
CleanDir tempReleaseDir
CopyRecursive tempGitDir (tempReleaseDir </> ".git") true |> ignore
cleanEverythingFromLastCheckout()
CopyRecursive "release" tempReleaseDir true |> tracefn "%A"
StageAll tempReleaseDir
Git.Commit.Commit tempReleaseDir releaseMsg
Branches.push tempReleaseDir
)
Target "Release" (fun _ ->
let args = sprintf "publish %s" release.NugetVersion
run apmTool args tempReleaseDir
DeleteDir tempReleaseDir
)
// --------------------------------------------------------------------------------------
// Run generator by default. Invoke 'build <Target>' to override
// --------------------------------------------------------------------------------------
Target "Default" DoNothing
#if MONO
"Clean"
==> "BuildGenerator"
==> "RunGenerator"
==> "InstallDependencies"
#else
"Clean"
==> "RunScript"
==> "CopyGrammar"
==> "CopyFantomas"
// ==> "CopyFSAC"
==> "InstallDependencies"
#endif
"InstallDependencies"
==> "Default"
==> "TagDevelopBranch"
==> "PushToMaster"
==> "Release"
"InstallDependencies"
==> "TryPackage"
RunTargetOrDefault "Default"