{"action":"created","issue":{"url":"https://api.github.com/repos/ninja-build/ninja/issues/1070","labels_url":"https://api.github.com/repos/ninja-build/ninja/issues/1070/labels{/name}","comments_url":"https://api.github.com/repos/ninja-build/ninja/issues/1070/comments","events_url":"https://api.github.com/repos/ninja-build/ninja/issues/1070/events","html_url":"https://github.com/ninja-build/ninja/issues/1070","id":121546414,"number":1070,"title":"add cwd variable to specify working directory of rule/build","user":{"login":"NiklasRosenstein","id":1318438,"avatar_url":"https://avatars.githubusercontent.com/u/1318438?v=3","gravatar_id":"","url":"https://api.github.com/users/NiklasRosenstein","html_url":"https://github.com/NiklasRosenstein","followers_url":"https://api.github.com/users/NiklasRosenstein/followers","following_url":"https://api.github.com/users/NiklasRosenstein/following{/other_user}","gists_url":"https://api.github.com/users/NiklasRosenstein/gists{/gist_id}","starred_url":"https://api.github.com/users/NiklasRosenstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NiklasRosenstein/subscriptions","organizations_url":"https://api.github.com/users/NiklasRosenstein/orgs","repos_url":"https://api.github.com/users/NiklasRosenstein/repos","events_url":"https://api.github.com/users/NiklasRosenstein/events{/privacy}","received_events_url":"https://api.github.com/users/NiklasRosenstein/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-10T18:15:21Z","updated_at":"2015-12-16T15:16:30Z","closed_at":null,"body":"I want to suggest supporting a `cwd` variable to specify the working directory for a rule or a single build. `build` will have to translate relative `$in` and `$out` filenames respectively. Meta build systems will know the behaviour of specifying `cwd` and can make sure to transform relative paths used in `command` respectively.\r\n\r\n__Example__\r\n\r\n```\r\nrule echo:\r\n  command = echo $in --> $out\r\n\r\nbuild resources/some_res.txt: echo obj/some_res.o\r\n  cwd = resources\r\n```\r\n\r\nI would expect the following output\r\n\r\n    some_res.txt --> ../obj/some_res.o\r\n\r\n__Possible Application__\r\n\r\nUsing `objcopy` to create an object file which embeds resources and binary data will create a symbol based on the input filename, including the directory! Eg. the file `resources/some_res.txt` would get the symbol `_resources_some_res_txt_start`. Switching to the `resources` directory would allow us to pass only the filename and get `_some_res_txt_start` as the symbol.\r\n\r\n```\r\nrule embed:\r\n  command = objcopy -I binary -O elf32-i386 -B i386 $in $out'\r\n\r\nbuild resources/some_res.txt: embed obj/some_res.o\r\n  cwd = resources\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ninja-build/ninja/issues/comments/165137769","html_url":"https://github.com/ninja-build/ninja/issues/1070#issuecomment-165137769","issue_url":"https://api.github.com/repos/ninja-build/ninja/issues/1070","id":165137769,"user":{"login":"martine","id":3847,"avatar_url":"https://avatars.githubusercontent.com/u/3847?v=3","gravatar_id":"","url":"https://api.github.com/users/martine","html_url":"https://github.com/martine","followers_url":"https://api.github.com/users/martine/followers","following_url":"https://api.github.com/users/martine/following{/other_user}","gists_url":"https://api.github.com/users/martine/gists{/gist_id}","starred_url":"https://api.github.com/users/martine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martine/subscriptions","organizations_url":"https://api.github.com/users/martine/orgs","repos_url":"https://api.github.com/users/martine/repos","events_url":"https://api.github.com/users/martine/events{/privacy}","received_events_url":"https://api.github.com/users/martine/received_events","type":"User","site_admin":false},"created_at":"2015-12-16T15:16:30Z","updated_at":"2015-12-16T15:16:30Z","body":"In what way does it fail?\nOn Dec 16, 2015 6:39 AM, \"Niklas Rosenstein\" <notifications@github.com>\nwrote:\n\n> rule dtschump.CImg.run_edge_explorer2d\n>   command = cd c:\\users\\niklas\\desktop\\cimg\\examples && c:\\users\\niklas\\desktop\\cimg\\build\\dtschump.cimg\\edge_explorer2d.exe\n>   pool = console\n> build dtschump.CImg.run_edge_explorer2d: dtschump.CImg.run_edge_explorer2d c$:\\users\\niklas\\desktop\\cimg\\build\\dtschump.cimg\\edge_explorer2d.exe\n>\n> That doesn't seem to work, at least on Windows. :(\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/ninja-build/ninja/issues/1070#issuecomment-165108293>.\n>\n"}}