nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.55k stars 1.47k forks source link

--out option in .nimble file changes to --var at runtime #9172

Closed OldhamMade closed 6 years ago

OldhamMade commented 6 years ago

Given a nimble file containing the following:

task release, "Build an optimised release":
  --hints:off
  --define:release
  --opt:speed
  --nilseqs: on
  --path:"src"
  --out:"mybinary"
  setCommand "c", "src/main.nim"

When I run nimble release I see the following error:

command line(1, 2) Error: invalid command line option: '--var'
       Tip: 12 messages have been suppressed, use --verbose to show them.
     Error: nimble.nim(1106)         nimble
        ... nimble.nim(1092)         doAction
        ... nimble.nim(1066)         doAction
        ... nimble.nim(544)          execBackend
        ... tools.nim(28)            doCmd
        ... Execution failed with exit code 256
        ... Command: "/path/to/nim" c --noNimblePath --path:"~/.nimble/pkgs/tempfile-0.1.5" "--define:release" "--opt:speed" "--nilseqs:on" "--hints:off" "--var:"mybinary"" "--path:"src""  "src/main.nim"

This is with v0.19.0.

OldhamMade commented 6 years ago

Ah, this seems to be a duplicate of #6011, apologies.

kaushalmodi commented 6 years ago

Unrelated: --define:release does not work in NimScript (only that specific define). I'd assume the same applies to .nimble too.

alaviss commented 6 years ago

--define:release does not work in NimScript (only that specific define)

It doesn't work when the script is run by the Nim compiler specifically (probably since -d:release logic is in nim.cfg, which is parsed before the NimScript can define anything). Since nimble calls the nim compiler directly, I don't see why it wouldn't work.

dom96 commented 6 years ago

Duplicate of https://github.com/nim-lang/Nim/issues/6011

OldhamMade commented 6 years ago

@kaushalmodi please note that, in this case, it is correct since we're using the C compiler. The result (when omitting --out) is as expected. However, happy for this ticket to be closed since the issue is the same regardless of backend.