Skip to content

Commit a50eae7

Browse files
authored
Fix flags for BuckleScript packages so that ppxs binaries can be found (#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 eea2b94dc937eec86efed07b8f5349a64bff20c6. * 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 d25fcf97ba9037839c33c9e617ba5ca9e6c1a4a8. * 64 * 2019 * roll back changes * remove new example
1 parent 7b08d87 commit a50eae7

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/analyze/Packages.re

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ let newBsPackage = (~overrideBuildSystem=?, ~reportDiagnostics, state, rootPath)
161161
let ppxs = config |> Json.get("ppx-flags") |?> Json.array |?>> Utils.filterMap(Json.string) |? [];
162162
Log.log("Getting hte ppxs yall");
163163
let flags = flags @ (Belt.List.map(ppxs, name => {
164-
MerlinFile.fixPpx("-ppx " ++ Filename.quote(name), rootPath)
164+
MerlinFile.fixPpxBsNative("-ppx " ++ Filename.quote(name), rootPath)
165165
}));
166166
let flags = switch (config |> Json.get("warnings") |?> Json.get("number") |?> Json.string) {
167167
| None => flags
@@ -171,7 +171,10 @@ let newBsPackage = (~overrideBuildSystem=?, ~reportDiagnostics, state, rootPath)
171171
"-ppx " ++ bsPlatform /+ "lib" /+ "bsppx.exe"
172172
], opens)
173173
| _ => {
174-
let flags = MerlinFile.getFlags(rootPath) |> RResult.withDefault([""]) |> List.map(escapePreprocessingFlags);
174+
let flags =
175+
MerlinFile.getFlags(rootPath)
176+
|> RResult.withDefault([""])
177+
|> List.map(escapePreprocessingFlags);
175178
let opens = List.fold_left((opens, item) => {
176179
let parts = Utils.split_on_char(' ', item);
177180
let rec loop = items => switch items {

util/MerlinFile.re

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let debug = ref(false);
55
let maybeLog = message => if (debug^) { Log.log("[MerlinFile]: " ++ message) };
66

77
/** This is a dirty hack to get around the bug in bsb native that doesn't do the proper ppx flags for ppxs */
8-
let fixPpx = (flg, base) => {
8+
let fixPpxBsNative = (flg, base) => {
99
switch (Str.split(Str.regexp_string(" "), flg)) {
1010
| ["-ppx", ppx] when Str.string_match(Str.regexp("[a-zA-Z_]+"), ppx, 0) && !Str.string_match(Str.regexp("[a-zA-Z_]:"), ppx, 0) => {
1111
"-ppx " ++ (base /+ "lib" /+ "bs" /+ "native" /+ String.lowercase_ascii(ppx) ++ ".native")
@@ -19,7 +19,7 @@ let parseMerlin = (base, text) => {
1919
List.fold_left(
2020
((source, build, flags), line) => {
2121
if (Utils.startsWith(line, "FLG ")) {
22-
(source, build, [fixPpx(Utils.chopPrefix(line, "FLG "), base), ...flags])
22+
(source, build, [Utils.chopPrefix(line, "FLG "), ...flags])
2323
} else if (Utils.startsWith(line, "S ")) {
2424
([Utils.chopPrefix(line, "S "), ...source], build, flags)
2525
} else if (Utils.startsWith(line, "B ")) {

util/MerlinFile.rei

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
let debug: ref(bool);
2-
let fixPpx: (string, string) => string;
2+
let fixPpxBsNative: (string, string) => string;
33
let parseMerlin:
44
(string, string) => (list(string), list(string), list(string));
55
let isRelativePath: string => bool;
@@ -45,4 +45,4 @@ let getModulesFromMerlin:
4545
list(string),
4646
);
4747
let getFlags: string => RResult.result(list(string), string);
48-
let getBackend: string => RResult.result(string, string);
48+
let getBackend: string => RResult.result(string, string);

0 commit comments

Comments
 (0)