Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ManasJayanth committed Oct 21, 2020
1 parent 6d64e24 commit 9cf5b89
Showing 1 changed file with 74 additions and 35 deletions.
109 changes: 74 additions & 35 deletions lib/Executable.re
Original file line number Diff line number Diff line change
Expand Up @@ -132,44 +132,83 @@ let toDuneStanza = (common: Common.t, e) => {
) =
Common.toDuneStanzas(common);

/* TODO: hacky!
ocamlopt flags are not lists. They are s-expresions.
Each item in the list can a single item or another list of items.
And so on..
TODO: remodel some of the fields correctly as s-expressions
*/

let ocamloptFlags =
switch (static) {
| Some(static) when static =>
Sexplib.Sexp.(
switch (ocamloptFlags) {
| None =>
Some(
List([
Atom("ocamlopt_flags"),
List([Atom("-ccopt"), Atom("-static")]),
])
|> Stanza.ofSexp,
)
| Some(flags) =>
switch (Stanza.toSexp(flags)) {
| List(l) =>
switch (l) {
| [Atom("ocamlopt_flags"), ...rest] =>
Some(
List([
Atom("ocamlopt_flags"),
List(rest @ [Atom("-ccopt"), Atom("-static")]),
])
|> Stanza.ofSexp,
)
| [] =>
Some(
List([
Atom("ocamlopt_flags"),
List(l @ [Atom("-ccopt"), Atom("-static")]),
])
|> Stanza.ofSexp,
)
}
| _ =>
Some(
List([
Atom("ocamlopt_flags"),
List([Atom("-ccopt"), Atom("-static")]),
])
|> Stanza.ofSexp,
)
}
}
)
| Some(static) when !static => ocamloptFlags
| None => ocamloptFlags
};

/* TODO: hacky!
ocamlopt flags are not lists. They are s-expresions.
Each item in the list can a single item or another list of items.
And so on..
TODO: remodel some of the fields correctly as s-expressions
*/

let ocamloptFlags =
switch(static) {
| Some(static) =>
if(static) {
switch(ocamloptFlags) {
| None => Some(Sexplib.Sexp.(List([Atom("ocamlopt_flags"), List([Atom("-ccopt"), Atom("-static")])])) |> Stanza.ofSexp)
| Some(flags) => { switch(Stanza.toSexp(flags)) {
| Sexplib.Sexp.List(l) => Some(Sexplib.Sexp.(List([Atom("ocamlopt_flags"), List(l @ [Atom("-ccopt"), Atom("-static")])]) |> Stanza.ofSexp) )
| _ => Some(Sexplib.Sexp.(List([Atom("ocamlopt_flags"), List([Atom("-ccopt"), Atom("-static")])]) |> Stanza.ofSexp))
} }
}
} else {
ocamloptFlags;
}
| None => {

ocamloptFlags;
}
}


let path = Common.getPath(common);
let (mains, publicNames) = List.fold_right((tuple, acc) => {
let (main, publicName) = tuple;
let (mains, publicNames) = acc;
(mains @ [main], publicNames @ [publicName]);
}, binKVs,([], []));
let name = Stanza.createExpression([Stanza.createAtom("names"), ...(mains |> List.map(x => x|> moduleNameOf |> Stanza.createAtom))])
let public_name = Stanza.createExpression([Stanza.createAtom("public_names"), ...(publicNames |> List.map(Stanza.createAtom))]);
let (mains, publicNames) =
List.fold_right(
(tuple, acc) => {
let (main, publicName) = tuple;
let (mains, publicNames) = acc;
(mains @ [main], publicNames @ [publicName]);
},
binKVs,
([], []),
);
let name =
Stanza.createExpression([
Stanza.createAtom("names"),
...mains |> List.map(x => x |> moduleNameOf |> Stanza.createAtom),
]);
let public_name =
Stanza.createExpression([
Stanza.createAtom("public_names"),
...publicNames |> List.map(Stanza.createAtom),
]);

let modules =
Stanza.createExpression([
Expand Down

0 comments on commit 9cf5b89

Please sign in to comment.