Skip to content

Commit 3273286

Browse files
committed
Merge branch 'dev'
2 parents 55c8128 + fd0fd34 commit 3273286

20 files changed

+649
-85
lines changed

XakeLibTests/CommandLineTests.fs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
namespace XakeLibTests
2+
3+
open System.IO
4+
open NUnit.Framework
5+
6+
open Xake
7+
8+
[<TestFixture (Description = "Command line tests")>]
9+
type CommandLineTests() =
10+
11+
let currentDir = Path.Combine (__SOURCE_DIRECTORY__, "..")
12+
13+
[<Test (Description = "Verifies reading common switches")>]
14+
member test.AcceptKnownSwitches() =
15+
16+
let scriptOptions = ref XakeOptions
17+
let args =
18+
["/t"; "33"; "/R"; currentDir; "/LL"; "Loud";
19+
"/FL"; "aaaaa"; "/D"; "AA=BBB"; "/D"; "AA1=CCC"; "/FLL"; "Silent"]
20+
21+
do xakeArgs args XakeOptions {
22+
wantOverride (["test"])
23+
24+
rules [
25+
"test" => action {
26+
let! opts = getCtxOptions()
27+
scriptOptions := opts
28+
}
29+
]
30+
}
31+
32+
let finalOptions = !scriptOptions
33+
Assert.AreEqual(33, finalOptions.Threads)
34+
Assert.AreEqual(currentDir, finalOptions.ProjectRoot)
35+
Assert.AreEqual("aaaaa", finalOptions.FileLog)
36+
Assert.AreEqual(Verbosity.Silent, finalOptions.FileLogLevel)
37+
Assert.AreEqual(Verbosity.Loud, finalOptions.ConLogLevel)
38+
Assert.AreEqual([("AA", "BBB"); ("AA1", "CCC")], finalOptions.Vars)
39+
40+
[<Test (Description = "Verifies reading target list")>]
41+
member test.ReadsTargets() =
42+
43+
let scriptOptions = ref XakeOptions
44+
let executed2 = ref false
45+
let args = ["/t"; "31"; "target1"; "target2"]
46+
47+
do xakeArgs args XakeOptions {
48+
49+
rules [
50+
"target1" => action {
51+
let! opts = getCtxOptions()
52+
scriptOptions := opts
53+
}
54+
"target2" => action {
55+
executed2 := true
56+
}
57+
]
58+
}
59+
60+
let finalOptions = !scriptOptions
61+
Assert.AreEqual(31, finalOptions.Threads)
62+
Assert.AreEqual(["target1"; "target2"], finalOptions.Targets)
63+
Assert.IsTrue !executed2
64+
65+
66+
[<Test (Description = "Verifies reading incorrect"); Ignore>]
67+
member test.WarnsOnIncorrectSwitch() =
68+
69+
do xakeArgs ["/xxx"] XakeOptions {
70+
want ["ss"]
71+
}
72+
73+
//raise <| new System.NotImplementedException()
74+
75+
[<Test (Description = "Verifies that command line is ignored when Ignore option is set")>]
76+
member test.IgnoresCommandLine() =
77+
78+
let scriptOptions = ref XakeOptions
79+
let args =
80+
["/t"; "33"; "/R"; currentDir; "/LL"; "Loud";
81+
"/FL"; "aaaaa"; "target"]
82+
83+
do xakeArgs args {XakeOptions with IgnoreCommandLine = true; Threads = 2; FileLog = "ss"; Targets = ["main"]} {
84+
rules [
85+
"main" => action {
86+
let! opts = getCtxOptions()
87+
scriptOptions := opts
88+
}
89+
]
90+
}
91+
92+
let finalOptions = !scriptOptions
93+
Assert.AreEqual(2, finalOptions.Threads)
94+
Assert.AreEqual("ss", finalOptions.FileLog)
95+
Assert.AreEqual(["main"], finalOptions.Targets)

XakeLibTests/FileTasksTests.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ open Xake.Storage
1212
[<TestFixture>]
1313
type FileTasksTests() =
1414

15-
let TestOptions = {XakeOptions with Threads = 1; Want = ["main"]; ConLogLevel = Chatty; FileLogLevel = Silent}
15+
let TestOptions = {XakeOptions with Threads = 1; Targets = ["main"]; ConLogLevel = Chatty; FileLogLevel = Silent}
1616

1717
[<Test>]
1818
member this.DeleteSimple() =

XakeLibTests/MiscTests.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ open Xake
77
open Storage
88
open BuildLog
99

10-
[<TestFixture (Description = "Verious tests")>]
10+
[<TestFixture (Description = "Various tests")>]
1111
type MiscTests() =
1212

1313
[<SetUp>]
@@ -326,7 +326,7 @@ type MiscTests() =
326326

327327
let count = ref 0
328328

329-
do xake {XakeOptions with Want = ["xxx"]; Threads = 1; FileLog=""} { // one thread to avoid simultaneous access to 'wasExecuted'
329+
do xake {XakeOptions with Targets = ["xxx"]; Threads = 1; FileLog=""} { // one thread to avoid simultaneous access to 'wasExecuted'
330330
rules [
331331
"main" => action {
332332
count := !count + 1

XakeLibTests/XakeLibTests.fsproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@
4848
<Compile Include="MiscTests.fs" />
4949
<Compile Include="StorageTests.fs" />
5050
<Compile Include="FileTasksTests.fs" />
51-
<None Include="packages.config" />
5251
<Compile Include="ProgressTests.fs" />
52+
<Compile Include="CommandLineTests.fs" />
53+
<None Include="packages.config" />
5354
</ItemGroup>
5455
<ItemGroup>
5556
<ProjectReference Include="..\core\Xake.Core.fsproj">

build.fsx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// xake build file
2+
#r @"bin/Debug/Xake.Core.dll"
3+
4+
open Xake
5+
6+
let fsc = """C:\Program Files (x86)\Microsoft SDKs\F#\3.0\Framework\v4.0\fsc.exe"""
7+
8+
do xake {XakeOptions with FileLog = "build.log"; ConLogLevel = Verbosity.Chatty } {
9+
10+
rules [
11+
"main" <== ["build"]
12+
"build" <== ["bin/Xake.Core.dll"]
13+
14+
"clean" => action {
15+
do! rm ["bin/Xake.Core.dll"]
16+
}
17+
18+
"bin/Xake.Core.dll" *> fun file -> action {
19+
20+
// TODO --doc:..\bin\Xake.Core.XML --- multitarget rule!
21+
22+
let sources = fileset {
23+
basedir "core"
24+
includes "Logging.fs"
25+
includes "Pickler.fs"
26+
includes "Fileset.fs"
27+
includes "Types.fs"
28+
includes "ArtifactUtil.fs"
29+
includes "CommonLib.fs"
30+
includes "Database.fs"
31+
includes "Action.fs"
32+
includes "WorkerPool.fs"
33+
includes "Progress.fs"
34+
includes "XakeScript.fs"
35+
includes "CommonTasks.fs"
36+
includes "FileTasks.fs"
37+
includes "ResourceFileset.fs"
38+
includes "DotNetFwk.fs"
39+
includes "DotnetTasks.fs"
40+
includes "VersionInfo.fs"
41+
includes "AssemblyInfo.fs"
42+
includes "Program.fs"
43+
}
44+
45+
do! Fsc {
46+
FscSettings with
47+
Out = file
48+
Src = sources
49+
RefGlobal = ["System.dll"; "System.Core.dll"; "System.Windows.Forms.dll"]
50+
Define = ["TRACE"]
51+
CommandArgs = ["--optimize+"; "--warn:3"; "--warnaserror:76"; "--utf8output"]
52+
}
53+
54+
}
55+
]
56+
57+
}

core/CommonTasks.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ let system cmd args =
9191
do! writeLog Info "[system] starting '%s'" cmd
9292
let! exitCode = _system SystemOptions cmd (args |> String.concat " ")
9393
do! writeLog Info "[system] сompleted '%s' exitcode: %d" cmd exitCode
94+
9495
return exitCode
9596
}
9697

core/DotNetFwk.fs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ module DotNetFwk =
4444
AssemblyDirs: string list
4545
ToolDir: string
4646
CscTool: string
47+
FscTool: string option
4748
MsbuildTool: string
4849
EnvVars: (string* string) list
4950
}
@@ -107,6 +108,7 @@ module DotNetFwk =
107108
ToolDir = libdir </> "mono" </> libpath
108109
Version = ver
109110
CscTool = csc_tool
111+
FscTool = Some "fsharpi"
110112
MsbuildTool = "xbuild"
111113
EnvVars =["PATH", sdkroot </> "bin" + ";" + (%"PATH")]
112114
}
@@ -124,6 +126,12 @@ module DotNetFwk =
124126
module internal MsImpl =
125127
open registry
126128

129+
// TODO drop Wow node lookup
130+
let fscTool =
131+
registry.open_subkey registry.HKLM @"SOFTWARE\Wow6432Node\Microsoft\FSharp\3.0\Runtime\v4.0"
132+
|> Option.bind (registry.get_value_str "")
133+
|> Option.bind (fun p -> System.IO.Path.Combine (p, "fsc.exe") |> Some)
134+
127135
let tryLocateFwk fwk =
128136
let fwkKey = open_subkey HKLM @"SOFTWARE\Microsoft\.NETFramework"
129137
let installRoot_ = fwkKey |> Option.bind (get_value_str "InstallRoot")
@@ -163,6 +171,7 @@ module DotNetFwk =
163171
Version = version
164172
AssemblyDirs = asmpaths
165173
CscTool = fwkdir </> "csc.exe"
174+
FscTool = fscTool
166175
MsbuildTool = fwkdir </> "msbuild.exe"
167176
EnvVars = vars
168177
}, null

0 commit comments

Comments
 (0)