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 misses local C #includes #5107

Closed
vicuna opened this issue Jul 18, 2010 · 5 comments
Closed

ocamlbuild misses local C #includes #5107

vicuna opened this issue Jul 18, 2010 · 5 comments

Comments

@vicuna
Copy link

vicuna commented Jul 18, 2010

Original bug ID: 5107
Reporter: Camarade_Tux
Status: resolved (set by @damiendoligez on 2017-03-03T15:22:06Z)
Resolution: suspended
Priority: normal
Severity: feature
Version: 3.12.0+beta1 or 3.12.0+rc1
Category: -for ocamlbuild use https://github.com/ocaml/ocamlbuild/issues
Tags: patch
Monitored by: abdallah mehdi @hcarty

Bug description

When a .c or .h file uses '#include "foo.h"', ocamlbuild has to copy that file in the _build directory but currently it doesn't, making the build fail.

The attached patch (against today's svn) uses cpp to get these dependencies for .c and .h files: .c files are "allowed" to include .c and .h files while .h files can only include .h files.
The reason for this limitation is that the whole list would be: c, cpp, cxx, cp, C, h, hpp, hxx, hxp, H, CPP, HPP, c++, h++, tcc, hh, cc and I took a conservative approach.

The patch also changes Lexers.ocamldep_output to make it work with cpp's output (or ocamldep without -modules).

File attachments

@vicuna
Copy link
Author

vicuna commented Jul 19, 2010

Comment author: jm

Super, ça comble une grosse lacune lorsqu’on fait des liages ;)
Juste faudrait que tu hackes davantage ocamldep_output
car cpp met des \\n pour ne pas faire des lignes trop longue (pour make).

@vicuna
Copy link
Author

vicuna commented Jul 19, 2010

Comment author: Camarade_Tux

Thanks for the feedback. I've fixed it and have made a new patch.

For the record, cpp can output:
ml_a.o: src/ml_a.c src/ml_b.h src/foo.h bar.h src/plip.c src/plip1.h
src/plip2.h src/plip3.h src/plip4.h src/plip5.h

edit: you can test behaviour before and after with:
echo '#include "foo.h"' > ml_a.c
touch foo.h
ocamlbuild ml_a.o

@vicuna
Copy link
Author

vicuna commented Jul 23, 2010

Comment author: Camarade_Tux

I just found out that if there are two files "foo.c" and "foo.h", the .c file will never be picked up (internally, the extension is dropped).

There might be a very simple fix: try to copy both, if "foo.*" is being used, chances are both "foo.h" and "foo.c" are used. Unfortunately, but unfortunately I don't have the time to do it right now since I'm on the leave (for a place without a real internet access).

edit: that's a problem I had when using lablgtk's varcc, meaning at least one well-know app does that

@vicuna
Copy link
Author

vicuna commented Feb 20, 2017

Comment author: @xavierleroy

Un-assigning from xclerc

@vicuna
Copy link
Author

vicuna commented Mar 3, 2017

Comment author: @damiendoligez

ocamlbuild is now a separate project that lives on GitHub.
PR transferred to ocaml/ocamlbuild#220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant