diff --git a/CHANGES.md b/CHANGES.md index 76d333f04d6..90fcc2ad271 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -75,6 +75,8 @@ unreleased - Fix `chdir` on external and source paths. Dune will also fail gracefully if the external or source path does not exist (#2165, fixes #2158, @rgrinberg) +- Support the `.cc` extension fro C++ sources (#2195, fixes #83, @rgrinberg) + 1.9.3 (06/05/2019) ------------------ diff --git a/src/c.ml b/src/c.ml index 27cfd1d59e6..35ca0024439 100644 --- a/src/c.ml +++ b/src/c.ml @@ -16,15 +16,20 @@ module Kind = struct | Not_allowed_until of Syntax.Version.t | Recognized of string * t + let cxx_version_introduced ~obj ~dune_version ~version_introduced = + if dune_version >= version_introduced then + Recognized (obj, Cxx) + else + Not_allowed_until version_introduced + let split_extension fn ~dune_version = match String.rsplit2 fn ~on:'.' with | Some (obj, "c") -> Recognized (obj, C) | Some (obj, "cpp") -> Recognized (obj, Cxx) | Some (obj, "cxx") -> - if dune_version >= (1, 8) then - Recognized (obj, Cxx) - else - Not_allowed_until (1, 8) + cxx_version_introduced ~obj ~dune_version ~version_introduced:(1, 8) + | Some (obj, "cc") -> + cxx_version_introduced ~obj ~dune_version ~version_introduced:(1, 10) | _ -> Unrecognized let possible_fns t fn ~dune_version = @@ -34,6 +39,8 @@ module Kind = struct let cxx = [fn ^ ".cpp"] in if dune_version >= (1, 8) then (fn ^ ".cxx") :: cxx + else if dune_version >= (1, 10) then + (fn ^ ".cxx") :: (fn ^ ".cc") :: cxx else cxx