{"action":"opened","number":326,"pull_request":{"url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/pulls/326","id":55927654,"html_url":"https://github.com/BinaryAnalysisPlatform/bap/pull/326","diff_url":"https://github.com/BinaryAnalysisPlatform/bap/pull/326.diff","patch_url":"https://github.com/BinaryAnalysisPlatform/bap/pull/326.patch","issue_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/issues/326","number":326,"state":"open","locked":false,"title":"Refine plugin system","user":{"login":"ivg","id":2336698,"avatar_url":"https://avatars.githubusercontent.com/u/2336698?v=3","gravatar_id":"","url":"https://api.github.com/users/ivg","html_url":"https://github.com/ivg","followers_url":"https://api.github.com/users/ivg/followers","following_url":"https://api.github.com/users/ivg/following{/other_user}","gists_url":"https://api.github.com/users/ivg/gists{/gist_id}","starred_url":"https://api.github.com/users/ivg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivg/subscriptions","organizations_url":"https://api.github.com/users/ivg/orgs","repos_url":"https://api.github.com/users/ivg/repos","events_url":"https://api.github.com/users/ivg/events{/privacy}","received_events_url":"https://api.github.com/users/ivg/received_events","type":"User","site_admin":false},"body":"This PR introduces some breaking changes, so read carefully.\r\n\r\nThe PR further decouples the notion of a plugin and a pass, as well as\r\nseparates a process of loading a plugin from its execution.\r\n\r\nA plugin, as it was always been, is a dynamically linked library, that\r\ncan be loaded by a bap fronted to perform some side-effectfull\r\ncomputation (usually to register itself in some plugin extension\r\npoint).\r\n\r\nTL;DR\r\n=====\r\n1. use `-l<file-name>` to load a plugin\r\n2. use `--<pass-name>` to run a pass.\r\n\r\nLoading plugins from command line\r\n=================================\r\n\r\nPreviously the `-l` option was used to load a plugin, that should be a\r\nprogram pass (or analysis in other words) and then executes it. Now this\r\noption only loads the plugin (that can be any plugin), but doesn't\r\nexecute it. To run a pass with name <name> use `--<name>` commandline\r\noption. For example, suppose you have file `mycode.ml` with the\r\nfollowing contents:\r\n\r\n```ocaml\r\nopen Bap.Std\r\n\r\nlet main project = print_endline \"Hello, World\"\r\nlet () = Project.register_pass' \"hello\" main\r\n```\r\n\r\nThen you can run this pass with the following command line sentence:\r\n\r\n```sh\r\n$ bapbuild mycode.plugin\r\n$ bap /bin/ls -lmycode --hello\r\n```\r\n\r\nGood news - you can now specify your pass several times, and it will be\r\nrun the same amount of times:\r\n\r\n```sh\r\n$ bap /bin/ls -lmycode --hello --hello --hello\r\n```\r\n\r\nWill print \"Hello, World\" three times. If your plugin has dependencies,\r\nthen they will be loaded once and executed as many times, as you run\r\nyour plugin.\r\n\r\nIf you need a more sophisticated control over running plugins, then you\r\ncan run any registered pass from your program directly, using\r\na `Project.run_pass` function.\r\n\r\nAlso, since this PR we totally separate a pass name from a filename,\r\nthat contains the pass. They still can be the same, of course. But in\r\ngeneral a name of the file is irrelevant and only used for `-l` option.\r\nThat also means, that your single plugin, can add more than one pass. It\r\nmay even generate passes dynamically based on command line.\r\n\r\nInstalling plugins\r\n==================\r\n\r\nIt was the same before, but still worthwhile to mention, that any\r\nplugins, that are installed into opam (more precisely findlib known\r\nlocation) will be loaded automatically. In particular that means, that\r\nwe can ship bap with a bunch of passes, that will be loaded\r\nautomatically, and can be run by using only the `--pass-name` option.\r\n\r\nP.S. I will provide some harness, that will simplify the installation\r\nseparately.","created_at":"2016-01-13T17:19:39Z","updated_at":"2016-01-13T17:19:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/pulls/326/commits","review_comments_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/pulls/326/comments","review_comment_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/pulls/comments{/number}","comments_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/issues/326/comments","statuses_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/statuses/a830576d18da69325c9ad0e925711d242a3577a7","head":{"label":"ivg:refine-plugin-system","ref":"refine-plugin-system","sha":"a830576d18da69325c9ad0e925711d242a3577a7","user":{"login":"ivg","id":2336698,"avatar_url":"https://avatars.githubusercontent.com/u/2336698?v=3","gravatar_id":"","url":"https://api.github.com/users/ivg","html_url":"https://github.com/ivg","followers_url":"https://api.github.com/users/ivg/followers","following_url":"https://api.github.com/users/ivg/following{/other_user}","gists_url":"https://api.github.com/users/ivg/gists{/gist_id}","starred_url":"https://api.github.com/users/ivg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivg/subscriptions","organizations_url":"https://api.github.com/users/ivg/orgs","repos_url":"https://api.github.com/users/ivg/repos","events_url":"https://api.github.com/users/ivg/events{/privacy}","received_events_url":"https://api.github.com/users/ivg/received_events","type":"User","site_admin":false},"repo":{"id":26191389,"name":"bap","full_name":"ivg/bap","owner":{"login":"ivg","id":2336698,"avatar_url":"https://avatars.githubusercontent.com/u/2336698?v=3","gravatar_id":"","url":"https://api.github.com/users/ivg","html_url":"https://github.com/ivg","followers_url":"https://api.github.com/users/ivg/followers","following_url":"https://api.github.com/users/ivg/following{/other_user}","gists_url":"https://api.github.com/users/ivg/gists{/gist_id}","starred_url":"https://api.github.com/users/ivg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivg/subscriptions","organizations_url":"https://api.github.com/users/ivg/orgs","repos_url":"https://api.github.com/users/ivg/repos","events_url":"https://api.github.com/users/ivg/events{/privacy}","received_events_url":"https://api.github.com/users/ivg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ivg/bap","description":"BAP Core Library","fork":true,"url":"https://api.github.com/repos/ivg/bap","forks_url":"https://api.github.com/repos/ivg/bap/forks","keys_url":"https://api.github.com/repos/ivg/bap/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ivg/bap/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ivg/bap/teams","hooks_url":"https://api.github.com/repos/ivg/bap/hooks","issue_events_url":"https://api.github.com/repos/ivg/bap/issues/events{/number}","events_url":"https://api.github.com/repos/ivg/bap/events","assignees_url":"https://api.github.com/repos/ivg/bap/assignees{/user}","branches_url":"https://api.github.com/repos/ivg/bap/branches{/branch}","tags_url":"https://api.github.com/repos/ivg/bap/tags","blobs_url":"https://api.github.com/repos/ivg/bap/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ivg/bap/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ivg/bap/git/refs{/sha}","trees_url":"https://api.github.com/repos/ivg/bap/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ivg/bap/statuses/{sha}","languages_url":"https://api.github.com/repos/ivg/bap/languages","stargazers_url":"https://api.github.com/repos/ivg/bap/stargazers","contributors_url":"https://api.github.com/repos/ivg/bap/contributors","subscribers_url":"https://api.github.com/repos/ivg/bap/subscribers","subscription_url":"https://api.github.com/repos/ivg/bap/subscription","commits_url":"https://api.github.com/repos/ivg/bap/commits{/sha}","git_commits_url":"https://api.github.com/repos/ivg/bap/git/commits{/sha}","comments_url":"https://api.github.com/repos/ivg/bap/comments{/number}","issue_comment_url":"https://api.github.com/repos/ivg/bap/issues/comments{/number}","contents_url":"https://api.github.com/repos/ivg/bap/contents/{+path}","compare_url":"https://api.github.com/repos/ivg/bap/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ivg/bap/merges","archive_url":"https://api.github.com/repos/ivg/bap/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ivg/bap/downloads","issues_url":"https://api.github.com/repos/ivg/bap/issues{/number}","pulls_url":"https://api.github.com/repos/ivg/bap/pulls{/number}","milestones_url":"https://api.github.com/repos/ivg/bap/milestones{/number}","notifications_url":"https://api.github.com/repos/ivg/bap/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ivg/bap/labels{/name}","releases_url":"https://api.github.com/repos/ivg/bap/releases{/id}","created_at":"2014-11-04T22:20:23Z","updated_at":"2015-05-05T21:48:34Z","pushed_at":"2016-01-13T17:19:06Z","git_url":"git://github.com/ivg/bap.git","ssh_url":"git@github.com:ivg/bap.git","clone_url":"https://github.com/ivg/bap.git","svn_url":"https://github.com/ivg/bap","homepage":null,"size":2704,"stargazers_count":0,"watchers_count":0,"language":"OCaml","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"BinaryAnalysisPlatform:master","ref":"master","sha":"a45cea90c224d365e0cb13cb8fb72b6b9ca0c87e","user":{"login":"BinaryAnalysisPlatform","id":8669375,"avatar_url":"https://avatars.githubusercontent.com/u/8669375?v=3","gravatar_id":"","url":"https://api.github.com/users/BinaryAnalysisPlatform","html_url":"https://github.com/BinaryAnalysisPlatform","followers_url":"https://api.github.com/users/BinaryAnalysisPlatform/followers","following_url":"https://api.github.com/users/BinaryAnalysisPlatform/following{/other_user}","gists_url":"https://api.github.com/users/BinaryAnalysisPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/BinaryAnalysisPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BinaryAnalysisPlatform/subscriptions","organizations_url":"https://api.github.com/users/BinaryAnalysisPlatform/orgs","repos_url":"https://api.github.com/users/BinaryAnalysisPlatform/repos","events_url":"https://api.github.com/users/BinaryAnalysisPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/BinaryAnalysisPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":25968851,"name":"bap","full_name":"BinaryAnalysisPlatform/bap","owner":{"login":"BinaryAnalysisPlatform","id":8669375,"avatar_url":"https://avatars.githubusercontent.com/u/8669375?v=3","gravatar_id":"","url":"https://api.github.com/users/BinaryAnalysisPlatform","html_url":"https://github.com/BinaryAnalysisPlatform","followers_url":"https://api.github.com/users/BinaryAnalysisPlatform/followers","following_url":"https://api.github.com/users/BinaryAnalysisPlatform/following{/other_user}","gists_url":"https://api.github.com/users/BinaryAnalysisPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/BinaryAnalysisPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BinaryAnalysisPlatform/subscriptions","organizations_url":"https://api.github.com/users/BinaryAnalysisPlatform/orgs","repos_url":"https://api.github.com/users/BinaryAnalysisPlatform/repos","events_url":"https://api.github.com/users/BinaryAnalysisPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/BinaryAnalysisPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BinaryAnalysisPlatform/bap","description":"BAP Core Library","fork":false,"url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap","forks_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/forks","keys_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/teams","hooks_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/hooks","issue_events_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/issues/events{/number}","events_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/events","assignees_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/assignees{/user}","branches_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/branches{/branch}","tags_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/tags","blobs_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/git/refs{/sha}","trees_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/statuses/{sha}","languages_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/languages","stargazers_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/stargazers","contributors_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/contributors","subscribers_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/subscribers","subscription_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/subscription","commits_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/commits{/sha}","git_commits_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/git/commits{/sha}","comments_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/comments{/number}","issue_comment_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/issues/comments{/number}","contents_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/contents/{+path}","compare_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/merges","archive_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/downloads","issues_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/issues{/number}","pulls_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/pulls{/number}","milestones_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/milestones{/number}","notifications_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/labels{/name}","releases_url":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/releases{/id}","created_at":"2014-10-30T11:59:43Z","updated_at":"2016-01-13T12:09:56Z","pushed_at":"2016-01-12T18:49:26Z","git_url":"git://github.com/BinaryAnalysisPlatform/bap.git","ssh_url":"git@github.com:BinaryAnalysisPlatform/bap.git","clone_url":"https://github.com/BinaryAnalysisPlatform/bap.git","svn_url":"https://github.com/BinaryAnalysisPlatform/bap","homepage":null,"size":3524,"stargazers_count":170,"watchers_count":170,"language":"OCaml","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":48,"mirror_url":null,"open_issues_count":31,"forks":48,"open_issues":31,"watchers":170,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/pulls/326"},"html":{"href":"https://github.com/BinaryAnalysisPlatform/bap/pull/326"},"issue":{"href":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/issues/326"},"comments":{"href":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/issues/326/comments"},"review_comments":{"href":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/pulls/326/comments"},"review_comment":{"href":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/pulls/326/commits"},"statuses":{"href":"https://api.github.com/repos/BinaryAnalysisPlatform/bap/statuses/a830576d18da69325c9ad0e925711d242a3577a7"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":153,"deletions":164,"changed_files":11}}