Skip to content

Commit

Permalink
Add Js binary linking mode
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
  • Loading branch information
nojb authored and rgrinberg committed Apr 5, 2019
1 parent 9f6daf1 commit 3eaac2f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/binary_kind.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type t =
| Exe
| Object
| Shared_object
| Js

let decode =
let open Dune_lang.Decoder in
Expand All @@ -13,18 +14,20 @@ 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
| C -> "c"
| Exe -> "exe"
| Object -> "object"
| Shared_object -> "shared_object"
| Js -> "js"

let pp fmt t =
Format.pp_print_string fmt (to_string 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]
1 change: 1 addition & 0 deletions src/binary_kind.mli
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type t =
| Exe
| Object
| Shared_object
| Js

include Dune_lang.Conv with type t := t

Expand Down
6 changes: 5 additions & 1 deletion src/exe.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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. *)
Expand All @@ -104,6 +106,8 @@ module Linkage = struct
@ so_flags
| Byte ->
so_flags
end
| Js -> []
in
{ ext
; mode = real_mode
Expand Down

0 comments on commit 3eaac2f

Please sign in to comment.