Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ocamlbuild, problems with %(name) syntax in the rules ~prod argument #5102

Closed
vicuna opened this issue Jul 10, 2010 · 2 comments
Closed

ocamlbuild, problems with %(name) syntax in the rules ~prod argument #5102

vicuna opened this issue Jul 10, 2010 · 2 comments

Comments

@vicuna
Copy link

@vicuna vicuna commented Jul 10, 2010

Original bug ID: 5102
Reporter: @dbuenzli
Assigned to: @xclerc
Status: closed (set by @xavierleroy on 2015-12-11T18:08:14Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.12.0+beta1 or 3.12.0+rc1
Target version: 4.01.0+dev
Fixed in version: 4.00.2+dev
Category: -for ocamlbuild use https://github.com/ocaml/ocamlbuild/issues
Monitored by: @dbuenzli

Bug description

The %(name) syntax doesn't work when there's only %(name) used in ~prod see the examples below.

Thanks,

Daniel

Steps to reproduce


Bug (single %(file) in ~prod):

cat myocamlbuild.ml
open Ocamlbuild_plugin;;

dispatch begin function
| Before_rules ->
rule "test: %.test -> %"
~dep:"%(file).%(suff).test"
~prod: "%(file)"
begin fun env build ->
cp (env "%(file).%(suff).test") (env "%(file)")
end
| _ -> ()
end

touch file.suff.test
ocamlbuild -classic-display file
/usr/local/bin/ocamlopt.opt -I /usr/local/lib/ocaml/ocamlbuild unix.cmxa /usr/local/lib/ocaml/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /usr/local/lib/ocaml/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
Exception Not_found.


No bug (more than one %(arg) in ~prod):

cat myocamlbuild.ml

cat myocamlbuild.ml
open Ocamlbuild_plugin;;

dispatch begin function
| Before_rules ->
rule "test: %.test -> %"
~dep:"%(file).%(suff).test"
~prod: "%(file).%(suff)"
begin fun env build ->
cp (env "%(file).%(suff).test") (env "%(file).%(suff)")
end
| _ -> ()
end

touch file.suff.test
ocamlbuild -classic-display file.suff
/usr/local/bin/ocamlopt.opt -I /usr/local/lib/ocaml/ocamlbuild unix.cmxa /usr/local/lib/ocaml/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /usr/local/lib/ocaml/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
cp file.suff.test file.suff

@vicuna
Copy link
Author

@vicuna vicuna commented Jul 10, 2010

Comment author: @dbuenzli

The following is also strange. With this plugin trying to build anything that doesn't exist hangs forever.

cat myocamlbuild.ml
open Ocamlbuild_plugin;;

dispatch begin function
| Before_rules ->
rule "test: %.test -> %"
~dep:"%.test"
~prod: "%"
begin fun env build ->
cp (env "%.test") (env "%")
end
| _ -> ()
end

ocamlbuild -classic-display asldkfaslfjk
/usr/local/bin/ocamlopt.opt -I /usr/local/lib/ocaml/ocamlbuild unix.cmxa /usr/local/lib/ocaml/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /usr/local/lib/ocaml/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
^CException Sys.Break.

touch bla.test
ocamlbuild -classic-display bla
cp bla.test bla

@vicuna
Copy link
Author

@vicuna vicuna commented Oct 10, 2012

Comment author: @xclerc

Fixed in trunk (revision 13002) and 4.00 (revision 13003) branches.

The "Not_found" exception was caused by the use of an unbound
variable in the dependency. Now, unbound variables are replaced
by empty strings.

The non-terminating behavior is not an ocamlbuild bug. Indeed,
if one has the rule "%(x).test -> %(x)" and asks to build "foo", then
a try will be made to create "foo.test" which in turn will try to create
"foo.test.test", and so on... thus looping unless one of these "*.test"
file already exists.

@vicuna vicuna closed this Dec 11, 2015
@vicuna vicuna added this to the 4.01.0 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant