Skip to content

Commit fa03fcc

Browse files
committed
Another attempt to make pure build scripts (not using msbuild), rename cp function to copyFile, new copyFiles function (incomplete)
1 parent 5fe083c commit fa03fcc

File tree

14 files changed

+781
-680
lines changed

14 files changed

+781
-680
lines changed

XakeLibTests/ActionTests.fs

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
namespace XakeLibTests
1+
module ``action block allows``
22

33
open NUnit.Framework
4-
54
open Xake
65

7-
[<TestFixture>]
8-
type ``action block allows``() =
96

10-
let makeStringList() = new System.Collections.Generic.List<string>()
11-
let DebugOptions =
12-
{ExecOptions.Default with FailOnError = true; FileLog = ""}
7+
let makeStringList() = new System.Collections.Generic.List<string>()
8+
let DebugOptions = {ExecOptions.Default with FailOnError = true; FileLog = ""}
139

14-
[<Test>]
15-
member __.``executes the body``() =
10+
[<Test>]
11+
let ``executes the body``() =
1612

1713
let wasExecuted = ref false
1814

@@ -24,8 +20,8 @@ type ``action block allows``() =
2420

2521
Assert.IsTrue(!wasExecuted)
2622

27-
[<Test>]
28-
member __.``execution is ordered``() =
23+
[<Test>]
24+
let ``execution is ordered``() =
2925

3026
let wasExecuted = ref false
3127

@@ -45,8 +41,8 @@ type ``action block allows``() =
4541
Assert.IsTrue(!wasExecuted)
4642
Assert.That(errorlist, Is.EquivalentTo(["1"; "2"; "3"]))
4743

48-
[<Test>]
49-
member __.``allows async operations``() =
44+
[<Test>]
45+
let ``allows async operations``() =
5046

5147
let wasExecuted = ref false
5248

@@ -67,8 +63,8 @@ type ``action block allows``() =
6763
Assert.IsTrue(!wasExecuted)
6864
Assert.That(errorlist, Is.EqualTo(["1"; "2"; "3"; "4"]))
6965

70-
[<Test>]
71-
member __.``do! action``() =
66+
[<Test>]
67+
let ``do! action``() =
7268

7369
let wasExecuted = ref false
7470

@@ -92,8 +88,8 @@ type ``action block allows``() =
9288
Assert.That(errorlist, Is.EqualTo(["1"; "2"; "3"; "4"]))
9389

9490

95-
[<Test>]
96-
member __.``do! action with result ignored``() =
91+
[<Test>]
92+
let ``do! action with result ignored``() =
9793

9894
let wasExecuted = ref false
9995

@@ -121,8 +117,8 @@ type ``action block allows``() =
121117
Assert.That(errorlist, Is.EqualTo(["1"; "2"; "3"; "4"] |> List.toArray))
122118

123119

124-
[<Test>]
125-
member __.``let! returning value``() =
120+
[<Test>]
121+
let ``let! returning value``() =
126122

127123
let errorlist = makeStringList()
128124
let note = errorlist.Add
@@ -144,8 +140,8 @@ type ``action block allows``() =
144140

145141
Assert.That(errorlist, Is.EqualTo(["1"; "2+1"; "3"] |> List.toArray))
146142

147-
[<Test>]
148-
member __.``if of various kinds``() =
143+
[<Test>]
144+
let ``if of various kinds``() =
149145

150146
let errorlist = makeStringList()
151147
let note = errorlist.Add
@@ -176,8 +172,8 @@ type ``action block allows``() =
176172

177173
Assert.That(errorlist, Is.EqualTo(["i1-t"; "i2-f"; "2"; "3"] |> List.toArray))
178174

179-
[<Test>]
180-
member __.``if without else``() =
175+
[<Test>]
176+
let ``if without else``() =
181177

182178
let errorlist = makeStringList()
183179
let note = errorlist.Add
@@ -206,8 +202,8 @@ type ``action block allows``() =
206202

207203
Assert.That(errorlist, Is.EqualTo(["i1-t"; "3"; "4"] |> List.toArray))
208204

209-
[<Test>]
210-
member __.``for and while``() =
205+
[<Test>]
206+
let ``for and while``() =
211207

212208
let errorlist = makeStringList()
213209
let note = errorlist.Add
@@ -235,8 +231,8 @@ type ``action block allows``() =
235231

236232
Assert.That(errorlist, Is.EqualTo(["1"; "i=1"; "i=2"; "i=3"; "j=3"; "j=4"; "4"] |> List.toArray))
237233

238-
[<Test; Explicit>]
239-
member __.``try catch finally``() =
234+
[<Test; Explicit>]
235+
let ``try catch finally``() =
240236

241237
let errorlist = makeStringList()
242238
let note = errorlist.Add

XakeLibTests/FileTasksTests.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ type ``File tasks module``() =
8787
"main" => action {
8888
do! trace Error "Running inside 'main' rule"
8989
do! need ["aaa"; "clean"]
90-
do! cp "aaa" "aaa-copy"
90+
do! copyFile "aaa" "aaa-copy"
9191
}
9292

9393
"clean" => action {

XakeLibTests/XakeLibTests.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<ItemGroup>
3535
<Reference Include="mscorlib" />
3636
<Reference Include="nunit.framework">
37-
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
37+
<HintPath>..\packages\NUnit\lib\nunit.framework.dll</HintPath>
3838
</Reference>
3939
<Reference Include="System" />
4040
<Reference Include="System.Core" />

XakeLibTests/paket.references

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
NUnit
1+
nunit

build.fsx

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ if not (System.IO.File.Exists file) then
1010
printfn ""
1111

1212
// xake build file body
13-
#r @"packages/Xake.Core.dll"
14-
//#r @"bin/Debug/Xake.Core.dll"
13+
//#r @"packages/Xake.Core.dll"
14+
#r @"bin/Debug/Xake.Core.dll"
1515

1616
open Xake
1717

@@ -24,7 +24,7 @@ let systemClr cmd args =
2424
let cmd',args' = if Xake.Env.isUnix then "mono", cmd::args else cmd,args
2525
in system cmd' args'
2626

27-
do xake {XakeOptions with FileLog = "build.log"; ConLogLevel = Verbosity.Chatty } {
27+
do xake {ExecOptions.Default with FileLog = "build.log"; ConLogLevel = Verbosity.Chatty } {
2828

2929
rules [
3030
"all" => action {
@@ -34,6 +34,7 @@ do xake {XakeOptions with FileLog = "build.log"; ConLogLevel = Verbosity.Chatty
3434
}
3535

3636
"build" => (build "Build")
37+
"bin" <== ["bin/XakeLibTests.dll"; "bin/FSharp.Core.dll"]
3738
"clean" => (build "Clean")
3839

3940
"get-deps" => action {
@@ -50,6 +51,88 @@ do xake {XakeOptions with FileLog = "build.log"; ConLogLevel = Verbosity.Chatty
5051
if exit_code <> 0 then
5152
failwith "Failed to test"
5253
}
54+
55+
("bin/FSharp.Core.dll") *> fun outfile -> action {
56+
do! copyFile @"packages\FSharp.Core\lib\net40\FSharp.Core.dll" outfile.FullName
57+
58+
let targetPath = "bin"
59+
do! copyFiles [@"packages\FSharp.Core\lib\net40\FSharp.Core.*data"] targetPath
60+
}
61+
62+
("bin/nunit.framework.dll") *> fun outfile -> action {
63+
do! copyFile @"packages\NUnit\lib\nunit.framework.dll" outfile.FullName
64+
}
65+
66+
"bin/Xake.Core.dll" *> fun file -> action {
67+
68+
// TODO --doc:..\bin\Xake.Core.XML --- multitarget rule!
69+
70+
let sources = fileset {
71+
basedir "core"
72+
includes "Logging.fs"
73+
includes "Pickler.fs"
74+
includes "Fileset.fs"
75+
includes "Types.fs"
76+
includes "ArtifactUtil.fs"
77+
includes "CommonLib.fs"
78+
includes "Database.fs"
79+
includes "Action.fs"
80+
includes "WorkerPool.fs"
81+
includes "Progress.fs"
82+
includes "XakeScript.fs"
83+
includes "Env.fs"
84+
includes "CommonTasks.fs"
85+
includes "FileTasks.fs"
86+
includes "ResourceFileset.fs"
87+
includes "DotNetFwk.fs"
88+
includes "DotnetTasks.fs"
89+
includes "VersionInfo.fs"
90+
includes "AssemblyInfo.fs"
91+
includes "Program.fs"
92+
}
93+
94+
do! Fsc {
95+
FscSettings with
96+
Out = file
97+
Src = sources
98+
Ref = !! "bin/FSharp.Core.dll"
99+
TargetFramework = "4.0"
100+
RefGlobal = ["System.dll"; "System.Core.dll"; "System.Windows.Forms.dll"]
101+
Define = ["TRACE"]
102+
CommandArgs = ["--optimize+"; "--warn:3"; "--warnaserror:76"; "--utf8output"]
103+
}
104+
105+
}
106+
107+
"bin/XakeLibTests.dll" *> fun file -> action {
108+
109+
// TODO --doc:..\bin\Xake.Core.XML --- multitarget rule!
110+
111+
let sources = fileset {
112+
basedir "XakeLibTests"
113+
includes "ActionTests.fs"
114+
includes "FilesetTests.fs"
115+
includes "ScriptErrorTests.fs"
116+
includes "XakeScriptTests.fs"
117+
includes "MiscTests.fs"
118+
includes "StorageTests.fs"
119+
includes "FileTasksTests.fs"
120+
includes "ProgressTests.fs"
121+
includes "CommandLineTests.fs"
122+
}
123+
124+
do! Fsc {
125+
FscSettings with
126+
Out = file
127+
Src = sources
128+
Ref = !! "bin/FSharp.Core.dll" + "bin/nunit.framework.dll" + "bin/Xake.Core.dll"
129+
TargetFramework = "4.0"
130+
RefGlobal = ["System.dll"; "System.Core.dll"]
131+
Define = ["TRACE"]
132+
CommandArgs = ["--optimize+"; "--warn:3"; "--warnaserror:76"; "--utf8output"]
133+
}
134+
135+
}
53136
]
54137

55138
}

core/DotnetTasks.fs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ module DotNetTaskTypes =
9494
Resources: ResourceFileset list
9595
/// Defines conditional compilation symbols.
9696
Define: string list
97-
/// Allows unsafe code.
98-
Unsafe: bool
9997
/// Target .NET framework
10098
TargetFramework: string
10199
/// Custom command-line arguments
102100
CommandArgs: string list
103101
/// Build fails on compile error.
104102
FailOnError: bool
103+
/// Do not reference the default CLI assemblies by default
104+
NoFramework: bool
105105

106106
Tailcalls: bool
107107
}
@@ -491,10 +491,10 @@ module DotnetTasks =
491491
RefGlobal = []
492492
Resources = []
493493
Define = []
494-
Unsafe = false
495494
TargetFramework = null
496495
CommandArgs = []
497496
FailOnError = true
497+
NoFramework = false
498498

499499
Tailcalls = true
500500
}
@@ -530,35 +530,30 @@ module DotnetTasks =
530530
| _, Some s when s <> "" -> s
531531
| _ -> null
532532

533-
let (globalRefs,nostdlib,noconfig) =
533+
let (globalRefs,noframework) =
534534
match targetFramework with
535535
| null ->
536536
let mapfn = (+) "/r:"
537537
// TODO provide an option for user to explicitly specify all grefs (currently csc.rsp is used)
538-
(settings.RefGlobal |> List.map mapfn), false, false
538+
(settings.RefGlobal |> List.map mapfn), false
539539
| tgt ->
540540
let fwk = Some tgt |> DotNetFwk.locateFramework in
541541
let lookup = DotNetFwk.locateAssembly fwk
542542
let mapfn = (fun name -> "/r:" + (lookup name))
543543

544544
//do! writeLog Info "Using libraries from %A" fwk.AssemblyDirs
545545

546-
("mscorlib.dll" :: settings.RefGlobal |> List.map mapfn), true, true
546+
("mscorlib.dll" :: settings.RefGlobal |> List.map mapfn), true
547547

548548
let args =
549549
seq {
550-
if noconfig then
551-
yield "/noconfig"
552550
yield "/nologo"
553551

554552
yield "/target:" + Impl.targetStr outFile.Name settings.Target
555553
//yield "/platform:" + Impl.platformStr settings.Platform
556554

557-
if settings.Unsafe then
558-
yield "/unsafe"
559-
560-
if nostdlib then
561-
yield "/nostdlib+"
555+
if settings.NoFramework || noframework then
556+
yield "--noframework"
562557

563558
if not outFile.IsUndefined then
564559
yield sprintf "/out:%s" outFile.FullName

0 commit comments

Comments
 (0)