How do I build Nim library packages
Asked Answered
A

1

6

I've created a nimble library package as per the documentation. When I try to build it using nimble build I get the following error.

Error: Nothing to build. Did you specify a module to build using the bin key in your .nimble file?

I can do this and it does fix the error but according to the documentation adding the bin key to the .nimble file turns my package into a binary package.

Other things I have tried:

  • Use nimble install: This does not appear to verify that my code will actually compile and will happily install anything to the local package directory (I added a C# class to my .nim file, for example, and it was successfully installed).
  • Use nimble c: This works but I have to pass in the path to the nim file I want to compile and the binDir entry in the .nimble file is ignored resulting in the output being placed in the same directory as the file being built. This complicates the development cycle because I have to manually clean up after the compiler.
  • Use the compiler directly. This is pretty much the same as the previous option with the same flaws.

I guess I could also create a separate .nim file and import my library after it is installed but this is a big overhead for just wanting to verify that a package in the early stages of development will actually compile.

I just want to be able to verify that the source code in my library package is syntactically correct and will compile. How is this meant to be done for library packages?

Alegar answered 1/9, 2020 at 17:45 Comment(0)
F
3

From your provided link to the nimble package manager documentation I have the feeling that

https://github.com/nim-lang/nimble#tests

is what you are looking for. But I have never used the test command, so I am not sure. I do my test manually still, I read the nimble docs maybe 4 years ago and can not really remember. And currently there is much package manager related work going on, I heard there is a new, alternative package manager called nimph, and from a forum thread I think I read something that nimble is going to change and improve also. Maybe you should consider subscribing to the Nim forum, that is the place where the bright Nim devs are. Well, at least a few of them.

Friederike answered 1/9, 2020 at 18:26 Comment(1)
It's obvious now that you have pointed it out but I totally overlooked nimble test because my package didn't have any tests in it yet. Obviously the tests depend on the code so they will be built when the test suite is run. ThanksAlegar

© 2022 - 2024 — McMap. All rights reserved.