-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new cmd: nim r main [args...]
to compile & run, saving binary under $nimcache/main
#13382
Conversation
52ce36d
to
af93cf8
Compare
af93cf8
to
39c891f
Compare
I'm not sure I like this. When I compile something with the |
I know this is kinda WIP, but breakage that requires workarounds like this is really bad: https://github.com/jangko/msgpack4nim/pull/47/files#diff-742733ae27de3fec3ce193ca005475b5R26 |
7f866df
to
2ca2039
Compare
I know, and I've now fixed it in a better way, see jangko/msgpack4nim#48 note that I've noticed that
you can use One of the benefits of this PR is we now don't need to worry about adding some nontrivial platform specific logic (especially on posix with empty extensions; note that some source files may have no extensions) in .gitignore just to support binaries / generated js file generated by running test commands like:
which affects pretty much every nimble package. it also prevents clobbering your sources with temporary files (exe's + generated js files) |
Yeah, please do. |
I don't like this code breakage. Instead currently |
that's a good idea; I'll do the following: nim r foo.nim # means: nim c -r --outDir:$nimcache foo.nim where future PR's (maybe)
where
(EDIT: done in #14278) |
Please finish this PR. |
Better yet, decouple the concept of target from commands in the compiler, so we can finally have nimsuggest working on js projects. |
3c918a3
to
de05508
Compare
nim c -r main.nim
now outputs under $nimcache/mainnim r main
compiles & run, saving binary under $nimcache/main
nim r main
compiles & run, saving binary under $nimcache/mainnim r main [args...]
to compile & run, saving binary under $nimcache/main
de05508
to
17b7871
Compare
17b7871
to
0e7eb8f
Compare
@Araq PTAL. this now works, and is now the preferred way to write tests in nims/nimble files, avoiding the problem of clobbering your repo with binaries (or fighting gitignore on posix)
|
Can you update the PR description? This is no longer a breaking change to |
done |
(updated description)
new cmd:
nim r main [args...]
now outputs binary under$nimcache/main
and runs$nimcache/main [args...]
examples
benefits
--mode:js
is added in future PRs) don't clobber source dirs with generated js files (hard to gitignore because their filename looks exactly like a regular source js file)This can become the new preferred way to write tests in nims/nimble files, avoiding the problem of clobbering your repo with binaries (or fighting gitignore on posix)
related issues
nim c
output path RFCs#29 andnimble test
,nimble build
etc should build all artifacts under./build
nimble#787same as in some other languages
dmd -run main.d
=> outputs in some temp dirrdmd main.d
=> outputs in some temp dir hashed by all relevant optionstcc -run test.c
=> doesn't generate a binary (and perhaps does all in memory but that's besides the point)
python main.py
lua test.lua
future work
nim r --mode:cpp main
(EDIT: this was implemented by fix some issues with --backend #14363, via --backend)--usenimcache
(implied bynim r main
) now caches some compile options to avoid recompiling when project was previously compiled with such options. #17829links
nim r
? maybe recommend as an alternative for nim >= 1.4 in the readme? PMunch/nimcr#14