From 3eaac2f19c3dcbca758aabfaf4c290f476871d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= Date: Wed, 13 Mar 2019 15:10:21 +0100 Subject: [PATCH] Add Js binary linking mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicolás Ojeda Bär --- src/binary_kind.ml | 5 ++++- src/binary_kind.mli | 1 + src/exe.ml | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/binary_kind.ml b/src/binary_kind.ml index e267fb80ef1..aa57ab65764 100644 --- a/src/binary_kind.ml +++ b/src/binary_kind.ml @@ -5,6 +5,7 @@ type t = | Exe | Object | Shared_object + | Js let decode = let open Dune_lang.Decoder in @@ -13,6 +14,7 @@ let decode = ; "exe" , return Exe ; "object" , return Object ; "shared_object" , return Shared_object + ; "js" , Syntax.since Stanza.syntax (1, 9) >>> return Js ] let to_string = function @@ -20,6 +22,7 @@ let to_string = function | Exe -> "exe" | Object -> "object" | Shared_object -> "shared_object" + | Js -> "js" let pp fmt t = Format.pp_print_string fmt (to_string t) @@ -27,4 +30,4 @@ let pp fmt t = let encode t = Dune_lang.unsafe_atom_of_string (to_string t) -let all = [C; Exe; Object; Shared_object] +let all = [C; Exe; Object; Shared_object; Js] diff --git a/src/binary_kind.mli b/src/binary_kind.mli index c7f70f1c44b..dd5300b11e1 100644 --- a/src/binary_kind.mli +++ b/src/binary_kind.mli @@ -7,6 +7,7 @@ type t = | Exe | Object | Shared_object + | Js include Dune_lang.Conv with type t := t diff --git a/src/exe.ml b/src/exe.ml index 365923d7bc8..595d67726ce 100644 --- a/src/exe.ml +++ b/src/exe.ml @@ -77,6 +77,8 @@ module Linkage = struct | Native , Object -> ".exe" ^ ctx.ext_obj | Byte , Shared_object -> ".bc" ^ ctx.ext_dll | Native , Shared_object -> ctx.ext_dll + | Byte , Js -> ".bc.js" + | Native , Js -> Errors.fail m.loc "Javascript generation only supports bytecode!" in let flags = match m.kind with @@ -95,7 +97,7 @@ module Linkage = struct else so_flags_unix in - match real_mode with + begin match real_mode with | Native -> (* The compiler doesn't pass these flags in native mode. This looks like a bug in the compiler. *) @@ -104,6 +106,8 @@ module Linkage = struct @ so_flags | Byte -> so_flags + end + | Js -> [] in { ext ; mode = real_mode