-
Notifications
You must be signed in to change notification settings - Fork 23
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
compiler: Option to produce a depfile from target dependencies #463
Comments
So write (and contribute!) a tool that translates the json file into whatever format that you need. |
So write (and contribute!) a tool that translates the json file into
whatever format that you need.
I haven't found a command that generates file's dependencies. Does it
exist?
|
The json file is always produced in nimcache. |
Hmm. `nim c --genScript:on main` generates such list of files
(`main.depend`). So I guess a tool can be used to convert it to a
depfile and we call it a day.
However if its format was standard depfile and it was allowed to set a
custom output path for that file, things would be simpler.
|
Nonstandard formats will not be understood by ninja / cmake / meson unless you "write (and contribute!) a tool" that both runs the compiler and converts the nonstandard format. Makefile rules are inherently embedded shell scripts, so you can write an inline Makefile wrapper script that first runs the compiler, then runs the tool, which isn't as bad. But this doesn't work generically. If the goal is for the compiler to support "all common build systems" then there is no alternative and no half measure -- you need the compiler itself to support the standard format. If the goal is for "all common build systems" to specifically support the compiler, then each build system would need to have a feature request opened + accepted + implemented to have the build system support the nonstandard format. This might prove challenging.
While it is more flexible to support a custom output path for the depfile, it isn't really required. Neither ninja nor make nor cmake nor meson require that the depfile path appear as part of the compiler rule -- they merely require that the rule ultimately creates the depfile, and that the build system knows which path to look for the depfile at. For example,
So:
|
It is used to produce a GCC-style depfile from target dependencies. Closes: nim-lang/RFCs#463
Implemented in PR
nim-lang/Nim#19960
|
It is used to produce a GCC-style depfile from target dependencies. Closes: nim-lang/RFCs#463
It is used to produce a GCC-style depfile from target dependencies. Closes: nim-lang/RFCs#463
It is used to produce a GCC-style depfile from target dependencies. Closes: nim-lang/RFCs#463
It is used to produce a GCC-style depfile from target dependencies. See nim-lang/RFCs#463
uninteresting, per comment below |
There seems to be a misunderstanding here. The |
I've just learned that the |
It is used to produce a GCC-style depfile from target dependencies. Closes: nim-lang/RFCs#463
It is used to produce a GCC-style depfile from target dependencies. Closes: nim-lang/RFCs#463
@zah Hi, |
Title
Depfile
Abstract
Add a new command-line option (e.g.
--depfile
) for thenim compile
command. It accepts an argument (output path for a depfile, generated for a given target).Motivation
This change would improve Nim integrations with language-independent build
systems. Particularly, get better edit-compile cycle times.
Currently a build system needs to rebuild a binary if any of source files has
been changed, even if they aren't used by the binary. The full list of files
that a given source file depends on can only be discovered by the compiler.
It doesn't need to be a standalone command because if the file has never been
compiled, it must be built anyway, generating dependencies as a side effect.
Description
Downside: growing number of command-line flags :)
Similar proposal: #412. However custom JSON format will not be understood by
build systems.
Depfile file format
From GCC manual (
-M
option):Or, in the BNF notation:
https://cmake.org/cmake/help/latest/command/add_custom_command.html
It is recognized by all common build systems.
Code Examples
Before
(no command to produce a depfile)
After
$ nim c --depfile main.d main $ head -4 main.d # system imports not shown main: \ /home/project/main.nim \ /home/project/src/file1.nim \ /home/project/src/file2.nim \
Use the depfile in Makefile
Use the depfile in Ninja
Use the depfile in CMake
Use the depfile in Meson
Backwards Compatibility
This RFC introduces no backward-incompatible changes.
The text was updated successfully, but these errors were encountered: