-
Notifications
You must be signed in to change notification settings - Fork 0
Reference | Rules
Rule is added by a rule directive in xake script body. "main" target is an entry point.
Similarly rules directive allows to add multiple rules passed as array. For example:
do xake ExecOptions.Default {
rules [
"main" <== ["hw.exe"]
"hw.dll" ..> recipe {
let! exe = getTargetFile()
do! Csc {
CscSettings with
Out = exe
TargetType = TargetType.Library
Src = !! "util.cs"
}
}
"hw.exe" ..> recipe {
do! Csc {
CscSettings with
// not defining the output file here, so that Csc will use artifact name (hw.exe in this code)
Src = !! "hw.cs"
Ref = !! "hw.dll"
}
}
]
}The script defines main rule is to build "hw.exe". <== operator (described in reference) defines a rule which requires other targets to complete. When build tool meet the Ref pointing to hw.dll it looks for rule matching the file name, starts the build step and waits until it completes.
..> operator defines a "file rule". The name of the file can be obtained via getTargetFullName function within recipe body.
Rule can be defined either for particular file of for a group files which path name matched the rule mask. For example the following code defines a rule for making any dll assembly from the .cs file with the same name:
"*.dll" ..> recipe {
let! asm = getTargetFullName()
do! Csc {
CscSettings with
Src = !! (asm <.-> ".cs")
}
}
}Mask can also contain the path fragment such as "bin/application.exe" or path mask" "bin/*/application.exe" which will define the rule both for "bin/release/application.exe" and "bin/debug/application.exe".
"**" matches nested folders similarly to fileset masks.
Xake script allows to get part of artifact name by defining matching groups in the rule:
rules [`"bin/(releaseType:*)/application.exe"` ..> recipe {
let! typ = getRuleMatch "releaseType"
// typ will contain "release" for artifact "bin/release/application.exe"
...
}]