{"action":"created","issue":{"url":"https://api.github.com/repos/waf-project/waf/issues/1602","labels_url":"https://api.github.com/repos/waf-project/waf/issues/1602/labels{/name}","comments_url":"https://api.github.com/repos/waf-project/waf/issues/1602/comments","events_url":"https://api.github.com/repos/waf-project/waf/issues/1602/events","html_url":"https://github.com/waf-project/waf/issues/1602","id":96681788,"number":1602,"title":"gccdeps fails to handle some paths with .. components","user":{"login":"mattfischer","id":1407372,"avatar_url":"https://avatars.githubusercontent.com/u/1407372?v=3","gravatar_id":"","url":"https://api.github.com/users/mattfischer","html_url":"https://github.com/mattfischer","followers_url":"https://api.github.com/users/mattfischer/followers","following_url":"https://api.github.com/users/mattfischer/following{/other_user}","gists_url":"https://api.github.com/users/mattfischer/gists{/gist_id}","starred_url":"https://api.github.com/users/mattfischer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattfischer/subscriptions","organizations_url":"https://api.github.com/users/mattfischer/orgs","repos_url":"https://api.github.com/users/mattfischer/repos","events_url":"https://api.github.com/users/mattfischer/events{/privacy}","received_events_url":"https://api.github.com/users/mattfischer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-22T22:34:24Z","updated_at":"2015-07-24T22:30:38Z","closed_at":null,"body":"This is a very specific edge case, but it comes up quite a bit in some of the generated files that we use in our project, so it's a problem that I need to find a solution to.  When gccdeps is processing an include path which uses '..' to escape from the build directory and go down into the source directory, it's possible for the file lookup to fail.\r\n\r\nAs a concrete example, say we have a header file `foo/header.h`, and a generated .c file `build/foo/generated.c`, which says `#include \"../../foo/header.h\"` in it.  The dump from GCC will list the file dependency as `\"foo/../../foo/header.h\"`, since it is operating relative to the root of the build tree.  The code in gccdeps will then try to call bldnode.find_resource() on this string.\r\n\r\nHere's the problem:  since we're searching from the build node, find_resource() will do a simple search_node(), which doesn't actually check the disk, it assumes that the nodes are already in the node tree.  That's a good assumption for the build nodes, but since we ..'ed out to the source tree, it's possible that nobody put `foo/header.h` into the node tree yet.  To be sure that the lookup succeeds, we would instead need find_resource() to actually call find_node(), to go search disk for the file.\r\n\r\nMy immediate fix was just to change gccdeps to call find_node() instead of find_resource(), which guarantees that it will always search disk, and find any files that weren't already in the node tree.  I'm not sure if that is the correct fix or not--it seems like the real issue is that find_resource() should be smart enough to realize that it's actually looking in the source tree after processing all of the ..'s, and switch over to a mode where it actually examines the disk for files.  However, that would be a bigger change and I'm not sure if there would be any side effects from doing it.  Any thoughts on how best to solve this problem?"},"comment":{"url":"https://api.github.com/repos/waf-project/waf/issues/comments/124748779","html_url":"https://github.com/waf-project/waf/issues/1602#issuecomment-124748779","issue_url":"https://api.github.com/repos/waf-project/waf/issues/1602","id":124748779,"user":{"login":"ita1024","id":508304,"avatar_url":"https://avatars.githubusercontent.com/u/508304?v=3","gravatar_id":"","url":"https://api.github.com/users/ita1024","html_url":"https://github.com/ita1024","followers_url":"https://api.github.com/users/ita1024/followers","following_url":"https://api.github.com/users/ita1024/following{/other_user}","gists_url":"https://api.github.com/users/ita1024/gists{/gist_id}","starred_url":"https://api.github.com/users/ita1024/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ita1024/subscriptions","organizations_url":"https://api.github.com/users/ita1024/orgs","repos_url":"https://api.github.com/users/ita1024/repos","events_url":"https://api.github.com/users/ita1024/events{/privacy}","received_events_url":"https://api.github.com/users/ita1024/received_events","type":"User","site_admin":false},"created_at":"2015-07-24T22:30:38Z","updated_at":"2015-07-24T22:30:38Z","body":"Are you generating headers without declaring them to the build? Prepare a testcase first."}}