Author Topic: C::B ignores object output path  (Read 1247 times)

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 101
C::B ignores object output path
« on: December 13, 2018, 06:50:33 pm »
Hi,

Recently I found a problem with C::B. In certain cases it seems to ignore "Objects output dir" of a build target and pollutes source paths with object files.
This is, however, related to the way I layout my projects that is a shared part of multiple projects (a common library) is introduced into project directory with a symlink to library root path.
In other words, the basic layout is

<project> -- project directory itself
<project>/lib <-- this is a symlink to common library
<project>/src <-- project sources path
<project>/obj/<target> <-- here must be all object files
<project>/bin/<target> <-- here must be all output binaries

If multiple libraries are used then "<project>/lib" is just a directory and symlinks to individual libraries are placed inside it.

The problem is, when the project is being compiled, object files for "lib/..." sources aren't put to the specified directory for a build target, instead they are dispersed among source files to the same location for all build targets.

I'm still using 16.01 build of C::B so this might be an old issue not relevant for the recent build.
Please confirm if this behavior is still in place. If it is, this needs to be fixed.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2150
Re: C::B ignores object output path
« Reply #1 on: December 13, 2018, 07:26:37 pm »
Confirmed.

This happens when the source files are outside of or on another path leg from the project directory. The code that calculates/uses the common top level path for the \obj files is incorrectly using too many '..'s) in the path. It produces, incorrectly, a path like .\obj\..\..\..\<objfilename>, causing the obj file to be placed outside the project dir.

I believe I have a fix for it and will test further.
« Last Edit: December 13, 2018, 07:30:15 pm by Pecan »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11817
    • Travis build status
Re: C::B ignores object output path
« Reply #2 on: December 14, 2018, 01:24:48 am »
Cmake fixes this by replacing '..' with '__' in paths.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: C::B ignores object output path
« Reply #3 on: December 14, 2018, 05:48:00 am »
Cmake fixes this by replacing '..' with '__' in paths.
Not only Cmake, in cbp2make I also do this. :)

AFAIR when the problem of path resolution came up, I found that a complete path calculation would be too complex and followed this kind of replacement too. On the one hand this practically mirrors all up-paths with down-paths which is consistent by itself (unless someone manually puts different files with same names both in up-path '..' and under-path '__' dirs just to break it, which is nonsense imo), but on the other hand if there are multiple ways to point to the same location they will be reflected differently. However, this is not a problem since there's only one object file per translation unit.

p.s. What about that old issue with unrolling symlinked paths in the project tree and putting that garbage back to project file? Is that thing still there?

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2150
Re: C::B ignores object output path
« Reply #4 on: December 18, 2018, 11:51:09 pm »
This problem appears to have been fixed in the nightlies.

The ".." references are now replaced by the directory name and post fixed to the object directory.
E.g., .obj\..\..\..\<objectfilename> now becomes .obj\dir1name\dir2name\dir3name\<objectfilename>
« Last Edit: December 19, 2018, 05:53:48 pm by Pecan »

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: C::B ignores object output path
« Reply #5 on: December 21, 2018, 11:23:34 pm »
This problem appears to have been fixed in the nightlies.
I'm glad to hear that. Does this affect the path unrolling in the project manager?

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2150
Re: C::B ignores object output path
« Reply #6 on: December 23, 2018, 05:29:49 pm »
This problem appears to have been fixed in the nightlies.
I'm glad to hear that. Does this affect the path unrolling in the project manager?

I found no references to unrolling symlinks in the project manager.

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: C::B ignores object output path
« Reply #7 on: March 05, 2019, 03:46:52 pm »
I found no references to unrolling symlinks in the project manager.
If you include in a project a directory which is a symlink to an upper level directory and then save this project, which path will be written to the project file? A path to the symlink or a path to a directory the symlink points to? In the old release 16.01 C::B was handling this the wrong way by substituting symlinks with their contents. Every time I update a project file by saving it I have to go and manually fix paths replacing ../../../<something> with just <something> as it should be in the first place.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11817
    • Travis build status
Re: C::B ignores object output path
« Reply #8 on: March 12, 2019, 10:04:00 am »
I doubt this has changed recently... I agree it is annoying...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]