Relative and absolute paths

220 views
Skip to first unread message

Fredrik Medley

unread,
Feb 19, 2015, 6:06:35 PM2/19/15
to ninja...@googlegroups.com
I cannot find any documentation about how paths should be specified: absolute or relative. The problem och mixing absolute and relative paths is not just in the build.ninja file, but also from the include header parsing in both the gcc and msvc case. Also, specifying a target output as relative in one rule and absolute in another will get through ninja even if the wanted behaviour is to abort.

What should be output from my generator into the build.ninja file, relative or absolute paths?
How to handle source files on other drives in Windows?
Why doesn't ninja just make absolute path for every file path?
The deps files may contain a mixture of relative and absolut paths. How to handle?

The attachment has test cases that show the specific problems.

Best regards,
Fredrik

ninja-dir-fail.tar

Fredrik Medley

unread,
Feb 20, 2015, 3:38:21 PM2/20/15
to ninja...@googlegroups.com
Basically, ninja breaks when specifying absolute paths to generated header files because the compiler (msvc) outputs relative paths to the included header files. Why should my ninja generator contain the knowledge about the format of the compiler dependency output?

I've tried changing all paths to absolute or relative when parsing the manifest files and deps files. If deciding for such solution, don't forget to keep the original path for use in the $in and $out variables.

/Fredrik

Scott Graham

unread,
Feb 20, 2015, 3:48:05 PM2/20/15
to Fredrik Medley, ninja-build
Could you provide a repro?

I think gyp generally uses relative paths, but I don't know of any specific problem in normalizing when absolute paths are involved.

--
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Fredrik Medley

unread,
Feb 20, 2015, 4:18:17 PM2/20/15
to ninja...@googlegroups.com, fredrik...@gmail.com
I can create a real repository the next week, if that helps. Otherwise, if you run windows/build.bat or linux/build.sh in the attached file, you will see that ninja has to be run twice to build all after updating the header_template.h. Adjust the absolute paths in the ninja files or just put the files in C:\Temp\ninja and /tmp/ninja respectively.

/Fredrik

Scott Graham

unread,
Feb 20, 2015, 4:40:33 PM2/20/15
to Fredrik Medley, ninja-build
I think you forgot the attachment (or maybe one of our clients stripped it).

Fredrik Medley

unread,
Feb 21, 2015, 3:45:12 AM2/21/15
to ninja...@googlegroups.com, fredrik...@gmail.com
There is an attachment in the first message in this thread, called ninja-dir-fail.tar.

Fredrik Medley

unread,
Feb 22, 2015, 4:55:28 PM2/22/15
to ninja...@googlegroups.com
I've created a branch at GitHub: https://github.com/moroten/ninja/tree/abspath-fail

Just build everything using the standard commands.
python configure.py --bootstrap
./ninja
touch src/util_template.h
./ninja

The first call to ninja should make sure everything has been build. The second call to ninja should update src/util.h followed by a rebuild of all source files of ninja. Instead, ninja thinks everything already is up to date because src/util.h exists and there is no edge to build src/util.h, just an unrelated edge to build abspath(src/util.h).
Reply all
Reply to author
Forward
0 new messages