Are you sure you won't add a proc for that? I think that would be better @Araq. Something like setTarget("tests/all") or a global target maybe. I think a command is that "a command" and the parameters should go extra.

@andrea I think the was thinking loud that this would be a way to do this. Not that it currently works.

2015-09-25 13:36:53
rku

btw i think we also want to be able to ./project.nims target or even ./project.nims which would execute default target. half of it already works by adding shebang #!/usr/bin/env nim however we still need access to command line parameters from script to manually exec compiler with appropriate target set. can not import os because it pulls in times module that does some importc stuff which does not work. so thats that.

EDIT: Added this to scriptconfig.nim:

cbconf paramStr:
  setResult(a, os.paramStr(int(a.getInt(0))))
cbconf paramCount:
  setResult(a, os.paramCount())
And this to nims script of project:
if paramCount() >= 1:
    var target: string
    var script = paramStr(1)
    if script.ends_with(".nims"):
        if paramCount() == 2:
            target = paramStr(2)
        else:
            target = "default"
        exec "nim $1 $2" % [target, script.substr(0, script.len - 2)]

Now i can just ./project.nims target or ./project.nims for default target.

2015-09-28 15:43:56

Just some update:

setCommand now also takes an optional project filename. The compiler supports config.nims as a directory-wide configuration file.

2015-09-29 19:07:05
Great work, I have just tested it and works perfectly for my use case! 2015-09-29 19:54:43
@r-ku NimScript exposes paramStr and paramCount via system.nim for technical reasons. Instead of os.nim you can use the subset module ospaths.nim.
2015-09-29 20:15:38
rku
Could you explain more? I can not find paramCount and paramStr in system.nim so im confused.
2015-09-30 06:31:18

Actually, I have checked better and it seems to ignore --define: foo directives. For an example, see here

The task testscuda is ran via exec and the alternative way is commented out because the flag cublas set by --define: "cublas" is not seen by the compiler.

2015-09-30 07:42:11

The last devel is broken or what am I doing wrong? config.nims:

#!/usr/bin/env nim
mode = ScriptMode.Verbose

task build, "Build the application!!":
  setCommand "c src/portal-dividends-loader"

nim build:

build                Build the application!!
Error: invalid command: 'build'

Compiler test: ./koch tests c newconfig:

FAIL: tfoo.nim
Test "tests/newconfig/tfoo.nim" in category "newconfig"
Failure: reNimcCrash
Expected:


Gotten:
invalid command: 'default'

2015-09-30 08:17:09

@r-ku: It is an extension to system.nim, listed here:

http://nim-lang.org/0.11.3/nimscript.html#paramStr,int

@andrea: Fixed.

@vega: Works for me:

PASS: tfoo.nim

2015-09-30 09:08:13

@Araq: here is my steps to reproduce:

git clone https://github.com/nim-lang/Nim && cd Nim
./bootstrap.sh
sudo ./install.sh /usr/local/bin
./koch tests c newconfig

And it's fails:

/home/vega/work/nim/test/Nim/tests/testament/tester c newconfig
FAIL: tfoo.nim
Test "tests/newconfig/tfoo.nim" in category "newconfig"
Failure: reNimcCrash
Expected:


Gotten:
invalid command: 'default'

nim -v:

Nim Compiler Version 0.11.3 (2015-09-30) [Linux: amd64]
Copyright (c) 2006-2015 by Andreas Rumpf

git hash: d80f1633844597f3a8020fc156d2d889bf897d97
active boot switches: -d:release

What am I doing wrong

uname -a

Linux xvega 3.13.0-54-generic #91-Ubuntu SMP Tue May 26 19:15:08 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

2015-09-30 09:43:02