Skip to content

Commit

Permalink
Fix flags for BuckleScript packages so that ppxs binaries can be found (
Browse files Browse the repository at this point in the history
#360)

* Fix FLG from Merlin for BuckleScript ppx-flags to point to node_modules/.bin

* Add example for bs 7.0.1

* Change ppx path to include package folder and remove node_modules/.bin prefixing

* use jsx3 and latest reason-react to see if this fixes windows ppx issues

* try building whole project before running bsc commands

* Revert "try building whole project before running bsc commands"

This reverts commit eea2b94.

* call npm install from outside ExampleTests + use script instead of bash in yaml template

* ggggaahhhhh

* try to debug some stuff

* add npm build and logging

* run

* try yarn

* revert changes and use node 12

* yarn

* namespace

* try different example

* appveyor simple

* remove more

* node 12

* y

* f

* n

* Revert "n"

This reverts commit d25fcf9.

* 64

* 2019

* roll back changes

* remove new example
  • Loading branch information
jchavarri authored Feb 25, 2020
1 parent 7b08d87 commit a50eae7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/analyze/Packages.re
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ let newBsPackage = (~overrideBuildSystem=?, ~reportDiagnostics, state, rootPath)
let ppxs = config |> Json.get("ppx-flags") |?> Json.array |?>> Utils.filterMap(Json.string) |? [];
Log.log("Getting hte ppxs yall");
let flags = flags @ (Belt.List.map(ppxs, name => {
MerlinFile.fixPpx("-ppx " ++ Filename.quote(name), rootPath)
MerlinFile.fixPpxBsNative("-ppx " ++ Filename.quote(name), rootPath)
}));
let flags = switch (config |> Json.get("warnings") |?> Json.get("number") |?> Json.string) {
| None => flags
Expand All @@ -171,7 +171,10 @@ let newBsPackage = (~overrideBuildSystem=?, ~reportDiagnostics, state, rootPath)
"-ppx " ++ bsPlatform /+ "lib" /+ "bsppx.exe"
], opens)
| _ => {
let flags = MerlinFile.getFlags(rootPath) |> RResult.withDefault([""]) |> List.map(escapePreprocessingFlags);
let flags =
MerlinFile.getFlags(rootPath)
|> RResult.withDefault([""])
|> List.map(escapePreprocessingFlags);
let opens = List.fold_left((opens, item) => {
let parts = Utils.split_on_char(' ', item);
let rec loop = items => switch items {
Expand Down
4 changes: 2 additions & 2 deletions util/MerlinFile.re
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let debug = ref(false);
let maybeLog = message => if (debug^) { Log.log("[MerlinFile]: " ++ message) };

/** This is a dirty hack to get around the bug in bsb native that doesn't do the proper ppx flags for ppxs */
let fixPpx = (flg, base) => {
let fixPpxBsNative = (flg, base) => {
switch (Str.split(Str.regexp_string(" "), flg)) {
| ["-ppx", ppx] when Str.string_match(Str.regexp("[a-zA-Z_]+"), ppx, 0) && !Str.string_match(Str.regexp("[a-zA-Z_]:"), ppx, 0) => {
"-ppx " ++ (base /+ "lib" /+ "bs" /+ "native" /+ String.lowercase_ascii(ppx) ++ ".native")
Expand All @@ -19,7 +19,7 @@ let parseMerlin = (base, text) => {
List.fold_left(
((source, build, flags), line) => {
if (Utils.startsWith(line, "FLG ")) {
(source, build, [fixPpx(Utils.chopPrefix(line, "FLG "), base), ...flags])
(source, build, [Utils.chopPrefix(line, "FLG "), ...flags])
} else if (Utils.startsWith(line, "S ")) {
([Utils.chopPrefix(line, "S "), ...source], build, flags)
} else if (Utils.startsWith(line, "B ")) {
Expand Down
4 changes: 2 additions & 2 deletions util/MerlinFile.rei
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let debug: ref(bool);
let fixPpx: (string, string) => string;
let fixPpxBsNative: (string, string) => string;
let parseMerlin:
(string, string) => (list(string), list(string), list(string));
let isRelativePath: string => bool;
Expand Down Expand Up @@ -45,4 +45,4 @@ let getModulesFromMerlin:
list(string),
);
let getFlags: string => RResult.result(list(string), string);
let getBackend: string => RResult.result(string, string);
let getBackend: string => RResult.result(string, string);

0 comments on commit a50eae7

Please sign in to comment.