-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Feature Requst/Documentation Request: use build.ninja
stub to bootstrap ninja
#2562
Comments
On Tue, Jan 28, 2025 at 2:37 PM Jon Heinritz ***@***.***> wrote:
Why not have that part in an otherwise empty build.ninja, so that the
user can just run ninja the first time and the project bootstraps itself?
I can think of two reasons:
- It is critical to be able to rebuild Ninja *without* an existing Ninja
binary. This is what `configure.py --bootstrap` does and what you propose
cannot replace this.
- Having a build.ninja file in the git tree that gets rewritten every time
Ninja is rebuilt is an annoyance during development. It is possible to add
it to the project's .gitignore, but then you cannot do `git checkout HEAD
build.ninja`. This gets annoying really fast.
Does the build.ninja get *reloaded* by the running ninja process when it
changes?
Yes, that's what happens.
As in would running ninja manual succeed in generating doc/manual.html?
`./configure.py --bootstrap && ./ninja manual` doesn't seem much more
complex imho.
If the answer to these questions is "yes" it would be nice for those
details to be part of the manual and maybe documented as potential pattern
to use to bootstrap projects.
Yes, feel free to upload a PR for review.
Though arguably writing to a source-controlled file might be a bad idea,
instead one could write to an build.ninja file contained in the build
directory and include that? (Does changing *those* cause ninja re-source
them? And would ninja run when the file path doesn't exist currently, but
is defined as a build target?)
I don't understand what you are proposing. If you care about the
convenience of just invoking `ninja manual` directly, then the
`build.ninja` must be in the build directory which is the top-level source
directory.
… If the answer is "no", it would be good to document that as gotcha and
might be a potentially neat feature to consider in the future.
I would of cause be open to discuss this topic either here, or on the
mailing list.
—
Reply to this email directly, view it on GitHub
<#2562>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMNJ4HMCNKGFXP2FTC3ZH332M6B2DAVCNFSM6AAAAABWAPZ6HSVHI2DSMVQWIX3LMV43ASLTON2WKOZSHAYTKNZQGMYDQMA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
I'm having difficulties to express my proposal in details, but my main idea is basically that a typical contributor shouldn't have to think about the build system when they get started with a project. So my ideal workflow would be, if they see that the project is build with And if we can prove that works for As context I'm relatively new to C/C++ and with many projects I feel like before being able to even build a project, you have to carefully study the build instruction to make sure you don't do anything wrong, which is a big barrier of entry for C in general in my opinion. I know a lot of this complexity is somewhat inherent to C, but I feel a lot of them can also be solved with some good defaults.
I will. I think I will start with a basic Proof of Concept and see from there. |
So, I have written a basic POC of how self-bootstrapping ninja file could look like. (See #2563) It can be tested with rm -rf build && mkdir build # make sure build directory is empty
touch configure.py # force the `configure` rule to be run to generate ninja file
touch build/build.ninja # make sure include target exists so that ninja doesn't error out
ninja <some-target> The only thing missing to make it actually work is some way conditionally execute I think the best to achieve that is to allow for So that when (There might be other solutions to this problem, but this feels most natural) I think that considering changes of |
When reading about how
ninja
, one of my first thoughts was that why not use ninja itself bootstrap thebuild.ninja
file?I tried googling this topic, but haven't really found anything, other than some closed issues concerning problems when regenerating
build.ninja
, but nothing directly about using abuild.ninja
-stub to bootstrap the project.Looking at the
build.ninja
of this project, it at least contains a passage to regenerate its contents when./configure
is changed:So my questions are:
Why not have that part in an otherwise empty
build.ninja
, so that the user can just runninja
the first time and the project bootstraps itself?Does the
build.ninja
get reloaded by the runningninja
process when it changes?As in would running
ninja manual
succeed in generatingdoc/manual.html
?If the answer to these questions is "yes" it would be nice for those details to be part of the manual and maybe documented as potential pattern to use to bootstrap projects.
Though arguably writing to a source-controlled file might be a bad idea, instead one could write to an
build.ninja
file contained in the build directory andinclude
that? (Does changing those causeninja
re-source them? And wouldninja
run when the file path doesn't exist currently, but is defined as a build target?)If the answer is "no", it would be good to document that as gotcha and might be a potentially neat feature to consider in the future.
I would of cause be open to discuss this topic either here, or on the mailing list.
The text was updated successfully, but these errors were encountered: