diff options
author | Dominik Picheta <dominikpicheta@googlemail.com> | 2018-08-28 22:05:46 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-08-28 23:05:46 +0200 |
commit | 9ad17091cc3c9b3f1dd7fd877ebe8555020fa4f9 (patch) | |
tree | 0e48abbad2bcf0ecdf8777f2dcc618512c4d4791 /lib/system | |
parent | 5cd152bfda29adefc8ba6eb72117c91dbc2e9d7f (diff) | |
download | Nim-9ad17091cc3c9b3f1dd7fd877ebe8555020fa4f9.tar.gz |
Allow Nimble to override the ``task`` template in nimscript. (#8798)
Diffstat (limited to 'lib/system')
-rw-r--r-- | lib/system/nimscript.nim | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/system/nimscript.nim b/lib/system/nimscript.nim index 3aafaa8d1..64d6255da 100644 --- a/lib/system/nimscript.nim +++ b/lib/system/nimscript.nim @@ -305,7 +305,6 @@ template withDir*(dir: string; body: untyped): untyped = finally: cd(curDir) -template `==?`(a, b: string): bool = cmpIgnoreStyle(a, b) == 0 proc writeTask(name, desc: string) = if desc.len > 0: @@ -313,29 +312,30 @@ proc writeTask(name, desc: string) = for i in 0 ..< 20 - name.len: spaces.add ' ' echo name, spaces, desc -template task*(name: untyped; description: string; body: untyped): untyped = - ## Defines a task. Hidden tasks are supported via an empty description. - ## Example: - ## - ## .. code-block:: nim - ## task build, "default build is via the C backend": - ## setCommand "c" - proc `name Task`*() = body - - let cmd = getCommand() - if cmd.len == 0 or cmd ==? "help": - setCommand "help" - writeTask(astToStr(name), description) - elif cmd ==? astToStr(name): - setCommand "nop" - `name Task`() - proc cppDefine*(define: string) = ## tell Nim that ``define`` is a C preprocessor ``#define`` and so always ## needs to be mangled. builtin when not defined(nimble): + template `==?`(a, b: string): bool = cmpIgnoreStyle(a, b) == 0 + template task*(name: untyped; description: string; body: untyped): untyped = + ## Defines a task. Hidden tasks are supported via an empty description. + ## Example: + ## + ## .. code-block:: nim + ## task build, "default build is via the C backend": + ## setCommand "c" + proc `name Task`*() = body + + let cmd = getCommand() + if cmd.len == 0 or cmd ==? "help": + setCommand "help" + writeTask(astToStr(name), description) + elif cmd ==? astToStr(name): + setCommand "nop" + `name Task`() + # nimble has its own implementation for these things. var packageName* = "" ## Nimble support: Set this to the package name. It |