Comments (7)
Pathname.pwd
is the project path, how does it not work for you? Note that ocamlbuild is designed to only write files in the build directory, not in the source directory, except for explicitly named targets for which links in the source directory are created. You have the expressive power to get out of that model (define a rule "project files" that creates a fixed list of files in _build
and links them in the source directory¹), but this should be done rather carefully.
¹: I think it is better to create in the build dir and then link than to create in pwd
directly, because ocamlbuild will look in the build dir to see if the target has already been built, etc.
from manual-ocamlbuild.
Pathname.pwd is the project path, how does it not work for you?
I set ~prod
to Filename.concat Pathname.pwd ".merlin"
, thinking that I'm now specifying an absolute path, so that maybe ocamlbuild would disregard _build
. However, it doesn't recognize the request at all now.
$ ocamlbuild .merlin
Finished, 1 target (0 cached) in 00:00:00.
Solver failed:
Ocamlbuild knows of no rules that apply to a target named .merlin. This can happen if you ask Ocamlbuild to build a target with the wrong extension (e.g. .opt instead of .native) or if the source files live in directories that have not been specified as include directories.
Compilation unsuccessful after building 0 targets (0 cached) in 00:00:00.
from manual-ocamlbuild.
Trying your suggestion to define a "project files" rule, I have this:
$ cat myocamlbuild.ml
open Ocamlbuild_plugin
let () = dispatch (function
| After_rules -> (
rule ".merlin"
~prod:".merlin"
(fun env _ -> Echo (["S ./src/**"], ".merlin"))
;
rule "project files"
~stamp:"project_files.stamp"
(fun _ build ->
let project_files = [[".merlin"]] in
List.map Outcome.good (build project_files) |>
List.map (fun result ->
Cmd (S [A "ln"; A "-sf";
P (!Options.build_dir/result);
P Pathname.pwd] )
) |>
fun l -> Seq l
)
)
| _ -> ()
)
The "project files" rule has no prod
, so how do you invoke it? Doing ocamlbuild .merlin
only produces _build/.merlin
, and understandably not the link that "project files" creates.
from manual-ocamlbuild.
You have the expressive power to get out of that model
Building in _build is of course good; it should be the default but I shouldn't be disallowed from creating a file elsewhere. Your suggestion to link files is a hack because the link isn't a first class entity of the build DAG.
A better solution would be: relative paths should by default be assumed to be relative to _build, but it should be possible to give repo_root
as an alternative.
from manual-ocamlbuild.
I still don't know how to invoke the "project rules" rule, so I thought a workaround is to do ocamlbuild .merlin
. I thought explicit targets to ocamlbuild are symlinked, but no symlink is created in this case. This doesn't work for cma's either so perhaps the automatic linking is only done for executables, which would actually make sense.
from manual-ocamlbuild.
I thought I had answered already, sorry. Just request the stamp as target: ocamlbuild project_files.stamp
will run the rule.
(Yes, automatic linking is kind of flaky right now, and I'm not sure exactly how to specify it and whether making it more uniform is a good idea.)
from manual-ocamlbuild.
Thanks. I thought I had tried that, but must have done something wrong. This works.
Another thing I noticed is that one cannot create the symlink and git commit it because ocamlbuild deletes the symlink!
from manual-ocamlbuild.
Related Issues (19)
- Is it possible to control where ocamlbuild outputs the binary symlink? HOT 2
- Restrict to packed usage. HOT 2
- Examples we should have in the documentation HOT 10
- Syntax for union patterns: {..} or \{..\}? HOT 1
- Provide a Unix manual page HOT 3
- Document invocation, options, and target arguments
- how to mimic _tags file within myocamlbuild.ml HOT 10
- how to use package during plugin compilation HOT 2
- how to split plugin into multiple files
- explain .itarget/.otarget more HOT 4
- Merging the new manual with the new ocamlbuild repo HOT 4
- Outline
- Example of custom utop build
- Is there any reason to no integrate this in the ocamlbuild project ? HOT 17
- new optimization tags for flambda HOT 1
- -cflags, -lflags HOT 2
- `-plugin-tag` not available on my ocamlbuild HOT 2
- list of available tags HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from manual-ocamlbuild.