-
Notifications
You must be signed in to change notification settings - Fork 413
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
can cxx_files support a .cc extension? #83
can cxx_files support a .cc extension? #83
Comments
Sure, the fields |
Any progress on this? Having |
@rauanmayemir would you like to give this issue a try? It's not particularly difficult and I can give you a bit of info to get started. |
@rgrinberg Hey, why not? I'd love to try! |
Thinking about this a little more, I think that we could consider breaking compatibility here for dune 1.0. That is, we should reject @rauanmayemir These details regarding compatibility are not so important and you can get started without worrying about it. We'll help you polish this part if it's required for 1.0. For now you can just use add The change consists of doing 3 things:
This is a very rough guide so don't hesitate to ask more questions. Some open questions for our maintainers @diml @bobot @emillon @dra27 @avsm @Chris00 with c stubs experience:
|
There could be |
Okay. Even more of a reason to just specify extensions everywhere consistently. |
Replacing BTW, I'm not against adding support of |
Jérémie Dimino <notifications@github.com> writes:
Allowing arbitrary extensions seem incompatible with changing the meaning of `:standard`. If we don't know the extensions for C files, we can't know what are the C files in the directory.
BTW, I'm not against adding support of `c_files`, but I don't think we should get rid of `c_names` yet.
Hmm, good point. I suppose we could allow for globs in the specification
of c_files however, but this seems complicated.
I suppose we should allow both fields and take their union when both are
specified. Being careful to do some error checking that we don't allow
to list overlapping sources in both fields.
What do you think about the :standard proposal on its own however? I
think it still makes sense to reduce boilerplate here. Also, if we do
end up going down the glob route, :standard could simply mean *.c. This
would work nicely with env overridng standard, as it would allow people
to set their default list of extensions.
|
What is the use case BTW? |
After looking into relevant code and working on this for a bit, I've come to realise that simply adding If we'd specify all commonly used extensions (which, I'm guessing, there are not that much of) and split the Personally, I solved my problem by just renaming Unless I'm missing something here? |
We can also add an My thinking is that renaming here is quite pesky, because now your editor won't know it's objective C anymore for example. |
As a suggestion, would it make sense to make these extensions configurable in the |
@emillon I like this much better than adding a separate field per lang/'dialect'. @diml How do you like It will also be sort of consistent with |
I'm not very familiar with sexpr's, but would this fly?
|
Yes, that makes sense. To make this more future proof, let's call these
|
I'm surprised that |
I'm fine with either feature, but IMO it's a bit weird to make the default extension customizable rather than simply let users put full filenames. This seems to me like adding more code to fix a problem that we've created ourselves in the first place. |
Make the extensions customizable would allow to make @emillon the flags are a bit different between the two. See |
I think this can also be done by making |
The question is more what happens when there is no |
Yeah, the default would be all files with a .c extension. |
yes, but then we have the same question for C++ files. There are many different questions in this PR, I think at this point someone should write a concrete proposal that we can reason about. For instance even if we allow more extensions, it doesn't solve the problem regarding objective-C files that might require specific treatment. |
I don't quite understand this part. Does dune automatically scan the directory and compile whatever C files it finds in current directory? Or you want it to be that way? |
The current situation is that dune requires the stubs to be listed. What we'd like is a situation that is symmetric with the |
Sounds great. I'll start with basic |
I think I agree with @diml that we need a concrete proposal before committing to anything. You could help us by clarifying what kind of special treatment objective C needs here. I'm not really convinced that adding fields for default extensions is a good approach (see my previous comments). Further more, we should perhaps think about other languages as well here. I recall @Chris00 wanting some basic fortran support. Are there are other languages that are useful for adding fast support like this? Finally, what about jsoo? If we have auto discovery then it should be consistently be applied for jsoo stubs as well. |
My use case for Objective-C involves writing bindings for Cocoa to draw UI on OCaml side. It's a library that gets linked into a complete 'exe.o' and embedded as a dependency(along with If I were to run it outside of xcodebuild flow, all I'd need to do is to add So, practically, there are no problems except for |
@rauanmayemir Why can't you write a Anyway, I've went ahead and just fixed the original issue in #2195. I'm thinking that having all this generality for file extensions is a bit of overkill and we have bigger fish to fry. However, if you have an idea of how to better support this, feel free to come up with a proposal. |
I have to specify clang option to choose objc for .c files, plus there’s an extra hassle making an editor treat .c files as ObjC. It’s not a big deal and I agree that at the moment dune has other important things to deal with. We can circle back to this at some point in future. |
CHANGES: - Restricted the set of variables available for expansion in the destination filename of `install` stanza to simplify implementation and avoid dependency cycles. (ocaml/dune#2073, @aalekseyev, @diml) - [menhir] call menhir from context root build_dir (ocaml/dune#2067, @ejgallego, review by @diml, @rgrinberg) - [coq] Add `coq.pp` stanza to help with pre-processing of grammar files (ocaml/dune#2054, @ejgallego, review by @rgrinberg) - Add a new more generic form for the *promote* mode: `(promote (until-clean) (into <dir>))` (ocaml/dune#2068, @diml) - Allow to promote only a subset of the targets via `(promote (only <pred>))`. For instance: `(promote (only *.mli))` (ocaml/dune#2068, @diml) - Improve the behavior when a strict subset of the targets of a rule is already in the source tree for projects using the dune language < 1.10 (ocaml/dune#2068, fixes ocaml/dune#2061, @diml) - With lang dune >= 1.10, rules in standard mode are no longer allowed to produce targets that are present in the source tree. This has been a warning for long enough (ocaml/dune#2068, @diml) - Allow %{...} variables in pps flags (ocaml/dune#2076, @mlasson review by @diml and @aalekseyev). - Add a 'cookies' option to ppx_rewriter/deriver flags in library stanzas. This allow to specify cookie requests from variables expanded at each invocation of the preprocessor. (ocaml/dune#2106, @mlasson @diml) - Add more opam metadata and use it to generate `.opam` files. In particular, a `package` field has been added to specify package specific information. (ocaml/dune#2017, ocaml/dune#2091, @avsm, @jonludlam, @rgrinberg) - Clean up the special support for `findlib.dynload`. Before, Dune would simply match on the library name. Now, we only match on the findlib package name when the library doesn't come from Dune. Someone writing a library called `findlib.dynload` with Dune would have to add `(special_builtin_support findlib_dynload)` to trigger the special behavior. (ocaml/dune#2115, @diml) - Install the `future_syntax` preprocessor as `ocaml-syntax-shims.exe` (ocaml/dune#2125, @rgrinberg) - Hide full command on errors and warnings in development and show them in CI. (detected using the `CI` environment variable). Commands for which the invocation might be omitted must output an error prefixed with `File `. Add an `--always-show-command-line` option to disable this behavior and always show the full command. (ocaml/dune#2120, fixes ocaml/dune#1733, @rgrinberg) - In `dune-workspace` files, add the ability to choose the host context and to create duplicates of the default context with different settings. (ocaml/dune#2098, @TheLortex, review by @diml, @rgrinberg and @aalekseyev) - Add support for hg in `dune subst` (ocaml/dune#2135, @diml) - Don't build documentation for implementations of virtual libraries (ocaml/dune#2141, fixes ocaml/dune#2138, @jonludlam) - Fix generation of the `-pp` flag in .merlin (ocaml/dune#2142, @rgrinberg) - Make `dune subst` add a `(version ...)` field to the `dune-project` file (ocaml/dune#2148, @diml) - Add the `%{os_type}` variable, which is a short-hand for `%{ocaml-config:os_type}` (ocaml/dune#1764, @diml) - Allow `enabled_if` fields in `library` stanzas, restricted to the `%{os_type}`, `%{model}`, `%{architecture}`, `%{system}` variables (ocaml/dune#1764, ocaml/dune#2164 @diml, @rgrinberg) - Fix `chdir` on external and source paths. Dune will also fail gracefully if the external or source path does not exist (ocaml/dune#2165, fixes ocaml/dune#2158, @rgrinberg) - Support the `.cc` extension fro C++ sources (ocaml/dune#2195, fixes ocaml/dune#83, @rgrinberg) - Run `ocamlformat` relative to the context root. This improves the locations of errors. (ocaml/dune#2196, fixes ocaml/dune#1370, @rgrinberg) - Fix detection of `README`, `LICENSE`, `CHANGE`, and `HISTORY` files. These would be undetected whenever the project was nested in another workspace. (ocaml/dune#2194, @rgrinberg) - Fix generation of `.merlin` whenever there's more than one stanza with the same ppx preprocessing specification (ocaml/dune#2209 ,fixes ocaml/dune#2206, @rgrinberg) - Fix generation of `.meriln` in the presence of the `copy_files` stanza and preprocessing specifications of other stanazs. (ocaml/dune#2211, fixes ocaml/dune#2206, @rgrinberg)
CHANGES: - Restricted the set of variables available for expansion in the destination filename of `install` stanza to simplify implementation and avoid dependency cycles. (ocaml/dune#2073, @aalekseyev, @diml) - [menhir] call menhir from context root build_dir (ocaml/dune#2067, @ejgallego, review by @diml, @rgrinberg) - [coq] Add `coq.pp` stanza to help with pre-processing of grammar files (ocaml/dune#2054, @ejgallego, review by @rgrinberg) - Add a new more generic form for the *promote* mode: `(promote (until-clean) (into <dir>))` (ocaml/dune#2068, @diml) - Allow to promote only a subset of the targets via `(promote (only <pred>))`. For instance: `(promote (only *.mli))` (ocaml/dune#2068, @diml) - Improve the behavior when a strict subset of the targets of a rule is already in the source tree for projects using the dune language < 1.10 (ocaml/dune#2068, fixes ocaml/dune#2061, @diml) - With lang dune >= 1.10, rules in standard mode are no longer allowed to produce targets that are present in the source tree. This has been a warning for long enough (ocaml/dune#2068, @diml) - Allow %{...} variables in pps flags (ocaml/dune#2076, @mlasson review by @diml and @aalekseyev). - Add a 'cookies' option to ppx_rewriter/deriver flags in library stanzas. This allow to specify cookie requests from variables expanded at each invocation of the preprocessor. (ocaml/dune#2106, @mlasson @diml) - Add more opam metadata and use it to generate `.opam` files. In particular, a `package` field has been added to specify package specific information. (ocaml/dune#2017, ocaml/dune#2091, @avsm, @jonludlam, @rgrinberg) - Clean up the special support for `findlib.dynload`. Before, Dune would simply match on the library name. Now, we only match on the findlib package name when the library doesn't come from Dune. Someone writing a library called `findlib.dynload` with Dune would have to add `(special_builtin_support findlib_dynload)` to trigger the special behavior. (ocaml/dune#2115, @diml) - Install the `future_syntax` preprocessor as `ocaml-syntax-shims.exe` (ocaml/dune#2125, @rgrinberg) - Hide full command on errors and warnings in development and show them in CI. (detected using the `CI` environment variable). Commands for which the invocation might be omitted must output an error prefixed with `File `. Add an `--always-show-command-line` option to disable this behavior and always show the full command. (ocaml/dune#2120, fixes ocaml/dune#1733, @rgrinberg) - In `dune-workspace` files, add the ability to choose the host context and to create duplicates of the default context with different settings. (ocaml/dune#2098, @TheLortex, review by @diml, @rgrinberg and @aalekseyev) - Add support for hg in `dune subst` (ocaml/dune#2135, @diml) - Don't build documentation for implementations of virtual libraries (ocaml/dune#2141, fixes ocaml/dune#2138, @jonludlam) - Fix generation of the `-pp` flag in .merlin (ocaml/dune#2142, @rgrinberg) - Make `dune subst` add a `(version ...)` field to the `dune-project` file (ocaml/dune#2148, @diml) - Add the `%{os_type}` variable, which is a short-hand for `%{ocaml-config:os_type}` (ocaml/dune#1764, @diml) - Allow `enabled_if` fields in `library` stanzas, restricted to the `%{os_type}`, `%{model}`, `%{architecture}`, `%{system}` variables (ocaml/dune#1764, ocaml/dune#2164 @diml, @rgrinberg) - Fix `chdir` on external and source paths. Dune will also fail gracefully if the external or source path does not exist (ocaml/dune#2165, fixes ocaml/dune#2158, @rgrinberg) - Support the `.cc` extension fro C++ sources (ocaml/dune#2195, fixes ocaml/dune#83, @rgrinberg) - Run `ocamlformat` relative to the context root. This improves the locations of errors. (ocaml/dune#2196, fixes ocaml/dune#1370, @rgrinberg) - Fix detection of `README`, `LICENSE`, `CHANGE`, and `HISTORY` files. These would be undetected whenever the project was nested in another workspace. (ocaml/dune#2194, @rgrinberg) - Fix generation of `.merlin` whenever there's more than one stanza with the same ppx preprocessing specification (ocaml/dune#2209 ,fixes ocaml/dune#2206, @rgrinberg) - Fix generation of `.merlin` in the presence of the `copy_files` stanza and preprocessing specifications of other stanazs. (ocaml/dune#2211, fixes ocaml/dune#2206, @rgrinberg) - Run `refmt` from the context's root directory. This improves error messages in case of syntax errors. (ocaml/dune#2223, @rgrinberg) - In .merlin files, don't pass `-dump-ast` to the `future_syntax` preprocessor. Merlin doesn't seem to like it when binary AST is generated by a `-pp` preprocessor. (ocaml/dune#2236, @aalekseyev) - `dune install` will verify that all files mentioned in all .install files exist before trying to install anything. This prevents partial installation of packages (ocaml/dune#2230, @rgrinberg)
Currently assumes the file has a .cpp extension, though .cc is also pretty common.
The text was updated successfully, but these errors were encountered: