{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/buck/issues/560","labels_url":"https://api.github.com/repos/facebook/buck/issues/560/labels{/name}","comments_url":"https://api.github.com/repos/facebook/buck/issues/560/comments","events_url":"https://api.github.com/repos/facebook/buck/issues/560/events","html_url":"https://github.com/facebook/buck/issues/560","id":120920458,"number":560,"title":"How to use the outputs of genrule()?","user":{"login":"spierce7","id":871169,"avatar_url":"https://avatars.githubusercontent.com/u/871169?v=3","gravatar_id":"","url":"https://api.github.com/users/spierce7","html_url":"https://github.com/spierce7","followers_url":"https://api.github.com/users/spierce7/followers","following_url":"https://api.github.com/users/spierce7/following{/other_user}","gists_url":"https://api.github.com/users/spierce7/gists{/gist_id}","starred_url":"https://api.github.com/users/spierce7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spierce7/subscriptions","organizations_url":"https://api.github.com/users/spierce7/orgs","repos_url":"https://api.github.com/users/spierce7/repos","events_url":"https://api.github.com/users/spierce7/events{/privacy}","received_events_url":"https://api.github.com/users/spierce7/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-12-08T03:08:37Z","updated_at":"2015-12-13T21:25:54Z","closed_at":null,"body":"I'm using genrule to compile a java library to a directory structure of .m and .h files. I'm trying to find some way to use that with the buck build. \r\n\r\nFor instance I could use apple_library(), and I could list the genrule name as a dependency, but seeing as how genrule ends up placing the output in the buck-out folder, it's difficult to access it. How should I be accessing these files?\r\n\r\nThe apple_library rule requires headers and srcs to be separate. I could create a script to separate out the .h and .m files into separate directories, but how would I link those files to the apple_library srcs and headers array?\r\n\r\nOr perhaps apple_library isn't the best tool to use?"},"comment":{"url":"https://api.github.com/repos/facebook/buck/issues/comments/164299643","html_url":"https://github.com/facebook/buck/issues/560#issuecomment-164299643","issue_url":"https://api.github.com/repos/facebook/buck/issues/560","id":164299643,"user":{"login":"spierce7","id":871169,"avatar_url":"https://avatars.githubusercontent.com/u/871169?v=3","gravatar_id":"","url":"https://api.github.com/users/spierce7","html_url":"https://github.com/spierce7","followers_url":"https://api.github.com/users/spierce7/followers","following_url":"https://api.github.com/users/spierce7/following{/other_user}","gists_url":"https://api.github.com/users/spierce7/gists{/gist_id}","starred_url":"https://api.github.com/users/spierce7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spierce7/subscriptions","organizations_url":"https://api.github.com/users/spierce7/orgs","repos_url":"https://api.github.com/users/spierce7/repos","events_url":"https://api.github.com/users/spierce7/events{/privacy}","received_events_url":"https://api.github.com/users/spierce7/received_events","type":"User","site_admin":false},"created_at":"2015-12-13T21:25:54Z","updated_at":"2015-12-13T21:25:54Z","body":">The limitation is part of the design. We know how to change the design to support that by making it more like shake, but we haven't yet decided whether we want to.\r\n\r\nIs there any discussion around this, or way to track it so that I could follow it and see what's decided? I'd like to better understand the pros / cons.\r\n\r\n>Yeah it can be a reference to a target. It should work as you suggested.\r\n\r\nWhen I use the approach I listed above, it's trying to read the files in the wrong location. I get several errors when I try to use all these build targets in an `apple_library()`. I get the same error on each file. Here is an example:\r\n\r\n```\r\nerror: error reading 'buck-out/gen/rxjava/rx/Observable.m/rx/Observable.m'\r\n1 error generated.\r\n```\r\nIt's trying to read `buck-out/gen/rxjava/rx/Observable.m/rx/Observable.m` as the file, but that is actually the folder containing the file, which is what's causing the error. `buck-out/gen/rxjava/rx/Observable.m/rx/Observable.m/Observable.m` is actually the file that it needs to be reading.\r\n\r\nFor reference, here is my BUCK file. What am I still missing?\r\n```python\r\nRXJAVA_SRC_DIR = 'src-1.1.0'\r\nRXJAVA_JAVA_SRC = glob([RXJAVA_SRC_DIR + '/main/java/**/*.java'])\r\n\r\nOBJC_FILES = []\r\nOBJC_HEADERS = []\r\nfor javaPath in subdir_glob([(RXJAVA_SRC_DIR + '/main/java', '**/*.java')]):\r\n  javaPathNoSuffix = javaPath[:-4]\r\n  OBJC_FILES.append(javaPathNoSuffix + 'm')\r\n  OBJC_HEADERS.append(javaPathNoSuffix + 'h')\r\n\r\njava_library(\r\n  name = 'java',\r\n  srcs = RXJAVA_JAVA_SRC,\r\n  tests = [\r\n    ':java-tests'\r\n  ],\r\n  visibility = [\r\n    'PUBLIC'\r\n  ],\r\n)\r\n\r\njava_test(\r\n  name = 'java-tests',\r\n  srcs = glob(['src-1.1.0/test/java/**/*.java']),\r\n)\r\n\r\ngenrule(\r\n  name = 'objc-generate',\r\n  srcs = [\r\n    RXJAVA_SRC_DIR,\r\n  ],\r\n  cmd = '$(exe //scripts:Java2ObjC) ' + RXJAVA_SRC_DIR + '/main/java $OUT',\r\n  out = 'src-objc',\r\n)\r\n\r\ndef objcGenRule(objc_filename):\r\n  genrule(\r\n    name = objc_filename,\r\n    cmd = 'mkdir -p $OUT && cp $(location :objc-generate)/' + objc_filename + ' $OUT',\r\n    out = objc_filename,\r\n  )\r\n\r\nfor src in OBJC_FILES: \r\n  objcGenRule(src)\r\nfor header in OBJC_HEADERS:\r\n  objcGenRule(header)\r\n\r\nOBJC_HEADER_DICT = { header : (':' + header) for header in OBJC_HEADERS }\r\n\r\n# A sample of what the j2objcc command runs when running for osx\r\n# xcrun clang -fobjc-arc -I /j2objc/j2objc-0.9.8.2.1/include -Werror -Wno-parentheses -fno-strict-overflow -std=c11 -ljre_emul -l icucore -l z -l j2objc_main -l c++ -framework Foundation -framework Security -framework ExceptionHandling -L /j2objc/j2objc-0.9.8.2.1/lib/macosx\r\napple_library(\r\n  name = 'objc',\r\n  deps = [\r\n    ':objc-generate',\r\n    '//j2objc:include',\r\n    '//j2objc:jre_emul',\r\n  ],\r\n  preprocessor_flags = [\r\n    '-fobjc-arc', \r\n    '-fno-strict-overflow',\r\n    '-std=c11',\r\n    '-Werror', \r\n    '-Wno-parentheses',\r\n    '-c',\r\n  ],\r\n  headers = OBJC_HEADER_DICT  ,\r\n  srcs = [':' + x for x in OBJC_FILES],\r\n  exported_linker_flags = [\r\n    '-lc++',\r\n    '-licucore',\r\n    '-lz',\r\n  ],\r\n  frameworks = [\r\n    '$SDKROOT/System/Library/Frameworks/Foundation.framework',\r\n    '$SDKROOT/System/Library/Frameworks/Security.framework',\r\n  ],\r\n  visibility = [\r\n    'PUBLIC',\r\n  ],\r\n)\r\n\r\n```\r\n\r\n"}}