-
Notifications
You must be signed in to change notification settings - Fork 43
Description
This feature request has been migrated from artifact #1660 on forge.ocamlcore.org. It was assigned to user102.
user116 posted on 2016-08-23 19:10:23:
Cannot figure if source_patterns can be used with atdgen which generates multiple ml files from single atd file.
Consider:
$ cat my.atd
type t = { x : int }
$ cat q.ml
let () = print_endline @@ My_j.string_of_t { My_t.x = 2 }
$ cat _oasis
OASISFormat: 0.4
Name: qqq
Version: q
Synopsis: q
Authors: q
License: WTFPL
Plugins: DevFiles (0.4)
BuildTools: ocamlbuild
OCamlVersion: >= 4.02
AlphaFeatures: source_patterns
Executable q
Path: .
BuildTools: ocamlbuild
MainIs: q.ml
BuildDepends: atdgen
Library qlib
Modules: My_j
ImplementationPatterns+: ${module}.atd
Path: .
$ cat myocamlbuild_config.ml
open Printf
open Ocamlbuild_plugin
let setup_ c =
let ml = sprintf "_%c.ml" c in
let prod = "%" ^ ml in
rule ("atdgen: .atd -> " ^ ml) ~dep:"%.atd" ~prods:[prod; prod^"i"] begin fun env _ ->
Cmd (S (
[ P "atdgen"; T (tags_of_pathname (env prod) ++ "atdgen");
A (sprintf "-%c" c)
] @
(if c = 'j' then [A "-j-std"] else []) @ (* better use _tags? *)
[A (env "%.atd"); ]
))
end
let setup () =
setup_ 't';
setup_ 'b';
setup_ 'j';
setup_ 'v';
pflag ["atdgen"] "atdgen" (fun s -> S [A s]);
()
let () = setup ()
oasis setup and make produce :
W: Cannot find source file matching module 'My_j' in library qlib.
W: Use InterfacePatterns or ImplementationPatterns to define this file with feature "source_patterns".
Any advice to get rid of these warnings?
user102 replied on 2016-08-23 19:44:38:
So it is not yet possible to do that yet with source pattern, because you need an extra function, like OASISString.strip_ends_with. If I add it, you will be able to do:
ImplementationPatterns: ${strip_ends_with "_j" module}.atd
user102 replied on 2016-08-23 19:44:38:
Moved from Bugs to Feature Requests
user116 replied on 2016-08-23 20:00:03:
Note that there are 4 extensions to strip, so will need 4 patterns. Guess it is still better than current hordes of warnings (btw is it really useful - maybe just give an option to switch it altogether?)
user102 replied on 2016-08-23 21:20:16:
is it really useful:
dunno.
It is really useful to copy the .mli files to the target directory and make the API readable through these files.
Now, you can argue that we can also generate a good doc...
Other point where it is really useful (but not yet done): restrict the use "*.mli" in _tags and prevent dependency leaks when everything in the same directory...