{"action":"created","issue":{"url":"https://api.github.com/repos/ocaml/ocaml/issues/286","labels_url":"https://api.github.com/repos/ocaml/ocaml/issues/286/labels{/name}","comments_url":"https://api.github.com/repos/ocaml/ocaml/issues/286/comments","events_url":"https://api.github.com/repos/ocaml/ocaml/issues/286/events","html_url":"https://github.com/ocaml/ocaml/pull/286","id":116031442,"number":286,"title":"Ocamldep modalias","user":{"login":"garrigue","id":870242,"avatar_url":"https://avatars.githubusercontent.com/u/870242?v=3","gravatar_id":"","url":"https://api.github.com/users/garrigue","html_url":"https://github.com/garrigue","followers_url":"https://api.github.com/users/garrigue/followers","following_url":"https://api.github.com/users/garrigue/following{/other_user}","gists_url":"https://api.github.com/users/garrigue/gists{/gist_id}","starred_url":"https://api.github.com/users/garrigue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garrigue/subscriptions","organizations_url":"https://api.github.com/users/garrigue/orgs","repos_url":"https://api.github.com/users/garrigue/repos","events_url":"https://api.github.com/users/garrigue/events{/privacy}","received_events_url":"https://api.github.com/users/garrigue/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":18,"created_at":"2015-11-10T05:40:17Z","updated_at":"2015-11-11T23:51:22Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ocaml/ocaml/pulls/286","html_url":"https://github.com/ocaml/ocaml/pull/286","diff_url":"https://github.com/ocaml/ocaml/pull/286.diff","patch_url":"https://github.com/ocaml/ocaml/pull/286.patch"},"body":"This pull request adds module alias support to ocamldep.\r\nThe idea is not to support everything, but to allow users to build their libraries using -no-alias-deps without too much hassle.\r\n\r\nThere are 4 new options added to ocamldep:\r\n\r\n* `-map file.ml` <br>\r\nParse `file.ml` and build a dependency map used by other files.\r\n\r\n* `-oprefix str` <br>\r\nAdd `str` as prefix to the filename for the object files corresponding to the analyzed source files.\r\nThis is applied to all files and dependencies, except files registered with `-map`, or explicitly excluded by `-noprefix`\r\n\r\n* `-noprefix Module` <br>\r\nAdd `Module` to the list of files `-oprefix` shouldn't apply to.\r\n\r\n* `-no-alias-deps` <br>\r\nMake the behavior closer to ocamlc's -no-alias-deps. Note however that the impact is very limited, because this would only make sense if we distinguish between compile-time and link-time dependencies.\r\n\r\nThere is a small example in `testsuite/tests/no-alias-deps2`.\r\nIn particular, you can see there that a standard way to use it would be\r\n```\r\nocamldep -oprefix Lib -map lib.ml -open Lib A.ml B.ml C.ml\r\n```\r\nThis means that the object files are `LibA.cmo`, `LibB.cmo` and `LibC.cmo`, that the bindings in the file `lib.ml` are to be used as a map, and this map is enabled in all files by `-open Lib` (otherwise one would have to add `open Lib` manually to each file where it is needed).\r\nNote that the map file is not a special file. For instance in the above example, the contents are:\r\n```\r\nmodule Packed = struct\r\n  module A = LibA\r\n  module B = LibB\r\n  module C = LibC\r\nend\r\ninclude Packed\r\n```\r\nWhich demonstrates than `include` works properly.\r\n\r\nThis is preliminary, but does the job.\r\n\r\nThe main design problem is about `-oprefix`. Currently it applies to all files in the scanned directories, but those explicitly excluded. In practice, I'm not sure this is the best possible behavior. Another approach would be to give a list of files:\r\n```\r\nocamldep -with-prefix Lib A.ml B.ml C.ml -end-prefix\r\n```\r\nAnother would be to use the map file for this, but this doesn't work well if we use map-files for multiple libraries.\r\n\r\nIdeally, one would want a similar option for ocamlc, but there it would only apply to the file currently compiled, so there is no ambiguity."},"comment":{"url":"https://api.github.com/repos/ocaml/ocaml/issues/comments/155947336","html_url":"https://github.com/ocaml/ocaml/pull/286#issuecomment-155947336","issue_url":"https://api.github.com/repos/ocaml/ocaml/issues/286","id":155947336,"user":{"login":"garrigue","id":870242,"avatar_url":"https://avatars.githubusercontent.com/u/870242?v=3","gravatar_id":"","url":"https://api.github.com/users/garrigue","html_url":"https://github.com/garrigue","followers_url":"https://api.github.com/users/garrigue/followers","following_url":"https://api.github.com/users/garrigue/following{/other_user}","gists_url":"https://api.github.com/users/garrigue/gists{/gist_id}","starred_url":"https://api.github.com/users/garrigue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garrigue/subscriptions","organizations_url":"https://api.github.com/users/garrigue/orgs","repos_url":"https://api.github.com/users/garrigue/repos","events_url":"https://api.github.com/users/garrigue/events{/privacy}","received_events_url":"https://api.github.com/users/garrigue/received_events","type":"User","site_admin":false},"created_at":"2015-11-11T23:51:22Z","updated_at":"2015-11-11T23:51:22Z","body":"I have removed the -oprefix and -no-prefix options.\r\nSee `testsuite/tests/no-alias-deps2` for how to use this with make, with symbolic links.\r\nPrefixing should rather be handled by ocamlbuild, but I don't know that codebase."}}