{"action":"created","comment":{"url":"https://api.github.com/repos/facebook/buck/pulls/comments/54332908","id":54332908,"diff_hunk":"@@ -252,40 +223,125 @@ private static Path extractTestMainGenerator() {\n     }\n   }\n \n-  static Tool getTestMainGenerator(\n-      GoBuckConfig goBuckConfig,\n-      BuildRuleParams sourceParams,\n-      BuildRuleResolver resolver,\n-      CxxPlatform cxxPlatform,\n-      ProjectFilesystem projectFilesystem) {\n-    Optional<Tool> configTool = goBuckConfig.getGoTestMainGenerator(resolver);\n-    if (configTool.isPresent()) {\n-      return configTool.get();\n+  private static BuildTarget createSymlinkTreeTarget(BuildTarget source) {\n+    return BuildTarget.builder(source)\n+        .addFlavors(ImmutableFlavor.of(\"symlink-tree\"))\n+        .build();\n+  }\n+\n+  private static BuildTarget createTransitiveSymlinkTreeTarget(BuildTarget source) {\n+    return BuildTarget.builder(source)\n+        .addFlavors(ImmutableFlavor.of(\"transitive-symlink-tree\"))\n+        .build();\n+  }\n+\n+  private static GoLinkable requireGoLinkable(\n+      BuildTarget sourceRule, BuildRuleResolver resolver, GoPlatform platform, BuildTarget target)\n+      throws NoSuchBuildTargetException {\n+    Optional<GoLinkable> linkable = resolver.requireMetadata(\n+        BuildTarget.builder(target)\n+            .addFlavors(platform.getFlavor())\n+            .build(), GoLinkable.class);\n+    if (!linkable.isPresent()) {\n+      throw new HumanReadableException(\n+          \"%s (needed for %s) is not an instance of go_library!\",\n+          target.getFullyQualifiedName(),\n+          sourceRule.getFullyQualifiedName());\n     }\n+    return linkable.get();\n+  }\n \n-    // TODO(mikekap): Make a single test main gen, rather than one per test. The generator itself\n-    // doesn't vary per test.\n+  private static ImmutableSet<GoLinkable> requireGoLinkables(\n+      final BuildTarget sourceTarget, final BuildRuleResolver resolver, final GoPlatform platform,\n+      ImmutableSet<BuildRule> rules)\n+      throws NoSuchBuildTargetException {\n+    return FluentIterable.from(rules).transform(new Function<BuildRule, GoLinkable>() {\n+      @Override\n+      public GoLinkable apply(BuildRule input) {\n+        try {\n+          return requireGoLinkable(sourceTarget, resolver, platform, input.getBuildTarget());\n+        } catch (NoSuchBuildTargetException e) {\n+          throw Throwables.propagate(e);\n+        }\n+      }\n+    }).toSet();\n+  }\n \n-    BuildRuleParams params = sourceParams.copyWithChanges(\n-        BuildTarget.builder(sourceParams.getBuildTarget())\n-            .addFlavors(ImmutableFlavor.of(\"make-test-main-gen\"))\n-            .build(),\n-        Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>of()),\n-        Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>of())\n-    );\n+  private static ImmutableSet<GoLinkable> requireTransitiveGoLinkables(\n+      final BuildTarget sourceTarget, final BuildRuleResolver resolver, final GoPlatform platform,\n+      ImmutableSet<BuildRule> rules)\n+      throws NoSuchBuildTargetException {\n+    final ImmutableSet.Builder<GoLinkable> linkables = ImmutableSet.builder();\n+    new AbstractBreadthFirstTraversal<BuildRule>(rules) {","path":"src/com/facebook/buck/go/GoDescriptors.java","position":396,"original_position":396,"commit_id":"d10f6b90b139bf55251fc39d9e18904d2c596af1","original_commit_id":"d10f6b90b139bf55251fc39d9e18904d2c596af1","user":{"login":"Coneko","id":1614903,"avatar_url":"https://avatars.githubusercontent.com/u/1614903?v=3","gravatar_id":"","url":"https://api.github.com/users/Coneko","html_url":"https://github.com/Coneko","followers_url":"https://api.github.com/users/Coneko/followers","following_url":"https://api.github.com/users/Coneko/following{/other_user}","gists_url":"https://api.github.com/users/Coneko/gists{/gist_id}","starred_url":"https://api.github.com/users/Coneko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Coneko/subscriptions","organizations_url":"https://api.github.com/users/Coneko/orgs","repos_url":"https://api.github.com/users/Coneko/repos","events_url":"https://api.github.com/users/Coneko/events{/privacy}","received_events_url":"https://api.github.com/users/Coneko/received_events","type":"User","site_admin":false},"body":"Can you replace this traversal with `requireMetadata` as well? You might need to add a recursive component where every description returns the transitive set of `GoLinkable` that target depends on.","created_at":"2016-02-27T12:43:23Z","updated_at":"2016-02-27T12:43:23Z","html_url":"https://github.com/facebook/buck/pull/666#discussion_r54332908","pull_request_url":"https://api.github.com/repos/facebook/buck/pulls/666","_links":{"self":{"href":"https://api.github.com/repos/facebook/buck/pulls/comments/54332908"},"html":{"href":"https://github.com/facebook/buck/pull/666#discussion_r54332908"},"pull_request":{"href":"https://api.github.com/repos/facebook/buck/pulls/666"}}},"pull_request":{"url":"https://api.github.com/repos/facebook/buck/pulls/666","id":60443991,"html_url":"https://github.com/facebook/buck/pull/666","diff_url":"https://github.com/facebook/buck/pull/666.diff","patch_url":"https://github.com/facebook/buck/pull/666.patch","issue_url":"https://api.github.com/repos/facebook/buck/issues/666","number":666,"state":"open","locked":false,"title":"Add platform via flavor to Go","user":{"login":"mikekap","id":43191,"avatar_url":"https://avatars.githubusercontent.com/u/43191?v=3","gravatar_id":"","url":"https://api.github.com/users/mikekap","html_url":"https://github.com/mikekap","followers_url":"https://api.github.com/users/mikekap/followers","following_url":"https://api.github.com/users/mikekap/following{/other_user}","gists_url":"https://api.github.com/users/mikekap/gists{/gist_id}","starred_url":"https://api.github.com/users/mikekap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikekap/subscriptions","organizations_url":"https://api.github.com/users/mikekap/orgs","repos_url":"https://api.github.com/users/mikekap/repos","events_url":"https://api.github.com/users/mikekap/events{/privacy}","received_events_url":"https://api.github.com/users/mikekap/received_events","type":"User","site_admin":false},"body":"This restructures how go rules build to be a bit more similar to Cxx rules with a noop rule that picks the flavor depending on the platform. This will later help Go<->Cxx interop, but short-term this properly includes GOOS & GOARCH in the rule key.\r\n\r\nGOOS & GOARCH values are also needed to properly implement build tag filtering & go asm compilation.","created_at":"2016-02-24T01:57:49Z","updated_at":"2016-02-27T12:43:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1246458c70d83ed43afc53927bf90c8f2b7aa12a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/facebook/buck/pulls/666/commits","review_comments_url":"https://api.github.com/repos/facebook/buck/pulls/666/comments","review_comment_url":"https://api.github.com/repos/facebook/buck/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/buck/issues/666/comments","statuses_url":"https://api.github.com/repos/facebook/buck/statuses/d10f6b90b139bf55251fc39d9e18904d2c596af1","head":{"label":"mikekap:go_platform","ref":"go_platform","sha":"d10f6b90b139bf55251fc39d9e18904d2c596af1","user":{"login":"mikekap","id":43191,"avatar_url":"https://avatars.githubusercontent.com/u/43191?v=3","gravatar_id":"","url":"https://api.github.com/users/mikekap","html_url":"https://github.com/mikekap","followers_url":"https://api.github.com/users/mikekap/followers","following_url":"https://api.github.com/users/mikekap/following{/other_user}","gists_url":"https://api.github.com/users/mikekap/gists{/gist_id}","starred_url":"https://api.github.com/users/mikekap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikekap/subscriptions","organizations_url":"https://api.github.com/users/mikekap/orgs","repos_url":"https://api.github.com/users/mikekap/repos","events_url":"https://api.github.com/users/mikekap/events{/privacy}","received_events_url":"https://api.github.com/users/mikekap/received_events","type":"User","site_admin":false},"repo":{"id":31528386,"name":"buck","full_name":"mikekap/buck","owner":{"login":"mikekap","id":43191,"avatar_url":"https://avatars.githubusercontent.com/u/43191?v=3","gravatar_id":"","url":"https://api.github.com/users/mikekap","html_url":"https://github.com/mikekap","followers_url":"https://api.github.com/users/mikekap/followers","following_url":"https://api.github.com/users/mikekap/following{/other_user}","gists_url":"https://api.github.com/users/mikekap/gists{/gist_id}","starred_url":"https://api.github.com/users/mikekap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikekap/subscriptions","organizations_url":"https://api.github.com/users/mikekap/orgs","repos_url":"https://api.github.com/users/mikekap/repos","events_url":"https://api.github.com/users/mikekap/events{/privacy}","received_events_url":"https://api.github.com/users/mikekap/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mikekap/buck","description":"A build system that encourages the creation of small, reusable modules.","fork":true,"url":"https://api.github.com/repos/mikekap/buck","forks_url":"https://api.github.com/repos/mikekap/buck/forks","keys_url":"https://api.github.com/repos/mikekap/buck/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mikekap/buck/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mikekap/buck/teams","hooks_url":"https://api.github.com/repos/mikekap/buck/hooks","issue_events_url":"https://api.github.com/repos/mikekap/buck/issues/events{/number}","events_url":"https://api.github.com/repos/mikekap/buck/events","assignees_url":"https://api.github.com/repos/mikekap/buck/assignees{/user}","branches_url":"https://api.github.com/repos/mikekap/buck/branches{/branch}","tags_url":"https://api.github.com/repos/mikekap/buck/tags","blobs_url":"https://api.github.com/repos/mikekap/buck/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mikekap/buck/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mikekap/buck/git/refs{/sha}","trees_url":"https://api.github.com/repos/mikekap/buck/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mikekap/buck/statuses/{sha}","languages_url":"https://api.github.com/repos/mikekap/buck/languages","stargazers_url":"https://api.github.com/repos/mikekap/buck/stargazers","contributors_url":"https://api.github.com/repos/mikekap/buck/contributors","subscribers_url":"https://api.github.com/repos/mikekap/buck/subscribers","subscription_url":"https://api.github.com/repos/mikekap/buck/subscription","commits_url":"https://api.github.com/repos/mikekap/buck/commits{/sha}","git_commits_url":"https://api.github.com/repos/mikekap/buck/git/commits{/sha}","comments_url":"https://api.github.com/repos/mikekap/buck/comments{/number}","issue_comment_url":"https://api.github.com/repos/mikekap/buck/issues/comments{/number}","contents_url":"https://api.github.com/repos/mikekap/buck/contents/{+path}","compare_url":"https://api.github.com/repos/mikekap/buck/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mikekap/buck/merges","archive_url":"https://api.github.com/repos/mikekap/buck/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mikekap/buck/downloads","issues_url":"https://api.github.com/repos/mikekap/buck/issues{/number}","pulls_url":"https://api.github.com/repos/mikekap/buck/pulls{/number}","milestones_url":"https://api.github.com/repos/mikekap/buck/milestones{/number}","notifications_url":"https://api.github.com/repos/mikekap/buck/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mikekap/buck/labels{/name}","releases_url":"https://api.github.com/repos/mikekap/buck/releases{/id}","deployments_url":"https://api.github.com/repos/mikekap/buck/deployments","created_at":"2015-03-02T07:29:32Z","updated_at":"2016-01-13T04:12:40Z","pushed_at":"2016-02-27T03:25:13Z","git_url":"git://github.com/mikekap/buck.git","ssh_url":"git@github.com:mikekap/buck.git","clone_url":"https://github.com/mikekap/buck.git","svn_url":"https://github.com/mikekap/buck","homepage":"http://facebook.github.io/buck/","size":365340,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"facebook:master","ref":"master","sha":"086741f8e93986bf7c3bfceafc85a6339461629c","user":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":9504214,"name":"buck","full_name":"facebook/buck","owner":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebook/buck","description":"A fast build system that encourages the creation of small, reusable modules over a variety of platforms and languages.","fork":false,"url":"https://api.github.com/repos/facebook/buck","forks_url":"https://api.github.com/repos/facebook/buck/forks","keys_url":"https://api.github.com/repos/facebook/buck/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/buck/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/buck/teams","hooks_url":"https://api.github.com/repos/facebook/buck/hooks","issue_events_url":"https://api.github.com/repos/facebook/buck/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/buck/events","assignees_url":"https://api.github.com/repos/facebook/buck/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/buck/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/buck/tags","blobs_url":"https://api.github.com/repos/facebook/buck/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/buck/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/buck/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/buck/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/buck/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/buck/languages","stargazers_url":"https://api.github.com/repos/facebook/buck/stargazers","contributors_url":"https://api.github.com/repos/facebook/buck/contributors","subscribers_url":"https://api.github.com/repos/facebook/buck/subscribers","subscription_url":"https://api.github.com/repos/facebook/buck/subscription","commits_url":"https://api.github.com/repos/facebook/buck/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/buck/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/buck/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/buck/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/buck/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/buck/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/buck/merges","archive_url":"https://api.github.com/repos/facebook/buck/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/buck/downloads","issues_url":"https://api.github.com/repos/facebook/buck/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/buck/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/buck/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/buck/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/buck/labels{/name}","releases_url":"https://api.github.com/repos/facebook/buck/releases{/id}","deployments_url":"https://api.github.com/repos/facebook/buck/deployments","created_at":"2013-04-17T18:12:18Z","updated_at":"2016-02-27T08:39:46Z","pushed_at":"2016-02-27T03:25:13Z","git_url":"git://github.com/facebook/buck.git","ssh_url":"git@github.com:facebook/buck.git","clone_url":"https://github.com/facebook/buck.git","svn_url":"https://github.com/facebook/buck","homepage":"https://buckbuild.com","size":401286,"stargazers_count":2355,"watchers_count":2355,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":399,"mirror_url":null,"open_issues_count":106,"forks":399,"open_issues":106,"watchers":2355,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/buck/pulls/666"},"html":{"href":"https://github.com/facebook/buck/pull/666"},"issue":{"href":"https://api.github.com/repos/facebook/buck/issues/666"},"comments":{"href":"https://api.github.com/repos/facebook/buck/issues/666/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/buck/pulls/666/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/buck/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/buck/pulls/666/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/buck/statuses/d10f6b90b139bf55251fc39d9e18904d2c596af1"}}}}