How to get list of targets that depends on some file in ninja

4,951 views
Skip to first unread message

Alex A

unread,
Sep 12, 2016, 9:29:30 AM9/12/16
to ninja-build
Hi!

First of all, thanks for great tool!

Now I'm trying to build map "source file" -> "targets that I should update". I think that ninja knows everything that is needed for this.
But I'm stuck in one point... So, I created question on stack overflow ( http://stackoverflow.com/questions/39444962/how-to-get-list-of-targets-that-depends-on-some-file-in-ninja )

Here is a copy of question:

How to get list of targets that depends on some file in ninja

Right now I'm using: ninja -t targets all > targets.out

It returns something like this:

cmake_order_depends_target_ZZZ: phony
zzz/CMakeFiles/ZZZ.dir/src/File1.cpp.o: CXX_COMPILER__ZZZ
zzz/CMakeFiles/ZZZ.dir/src/File2.cpp.o: CXX_COMPILER__ZZZ
zzz/CMakeFiles/ZZZ.dir/src/File3.cpp.o: CXX_COMPILER__ZZZ

After that I'm parsing it with python script to create map source file -> original target

But how to understand that target ZZZ depends on target YYY and that target XXX depends on ZZZ itself?


Br, Alex

Nico Weber

unread,
Sep 12, 2016, 9:47:19 AM9/12/16
to Alex A, ninja-build
You can use `-t query` to query for this information, but what are you trying to do? It sounds like you're trying to implement something the build system is supposed to do outside of the build system.

--
You received this message because you are subscribed to the Google Groups "ninja-build" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ninja-build+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex A

unread,
Sep 12, 2016, 10:02:33 AM9/12/16
to ninja-build, mr.ak...@gmail.com
Thanks, I will give a try. Now it looks very promising.

Probably, you are right. But my idea is very-very simple. I have CI System that checks each commit from each developer independent. For example, we have master version, commit A that "changes" only targetA and commit B that "changes" only targetB.
So, right now I should test targetA and targetB for both changes because CI doesn't know what was affected - it knows only list of modified files. But ninja knows, because it has dependency graph from start (source file) to finish (targetA).
And my goal is to get this knowledge from ninja and run test only for "changed" target.

*"changed" in terms of "changed agains master".

Br, Alex
To unsubscribe from this group and stop receiving emails from it, send an email to ninja-build...@googlegroups.com.

Evan Martin

unread,
Sep 12, 2016, 12:59:21 PM9/12/16
to Alex A, ninja-build

Here's another approach that might work for you.

For each test, add a build rule like:

build test1.stamp: test1.exe
  cmd = $in && touch $out

And then one to gather them:

build tests: phony test1.stamp

And now "ninja tests" will build and run all modified tests.


To unsubscribe from this group and stop receiving emails from it, send an email to ninja-build+unsubscribe@googlegroups.com.

East Coast Boys

unread,
May 1, 2019, 10:32:27 AM5/1/19
to ninja-build
Hello I have a question with regards to MACPORT and NINJA can anyone help?

Nico Weber

unread,
May 1, 2019, 10:50:38 AM5/1/19
to East Coast Boys, ninja-build
Hello, please don't reply to unrelated threads. Start a new thread with your question. If it's about macports, some macports mailing list might be a better fit though; it depends on what exactly the question is.

--
Reply all
Reply to author
Forward
0 new messages