Skip to content

Commit 5995ad5

Browse files
committed
Support multiple version labels
1 parent e2b6532 commit 5995ad5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/block.ml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,11 @@ let rec ends_by_semi_semi = function
309309
| [ h ] -> Astring.String.is_suffix ~affix:";;" h
310310
| _ :: xs -> ends_by_semi_semi xs
311311

312-
let version_enabled version =
312+
let version_enabled versions =
313313
let+ curr_version = Ocaml_version.of_string Sys.ocaml_version in
314-
match version with
315-
| Some (op, v) ->
314+
List.for_all (fun (op, v) ->
316315
Label.Relation.compare op (Ocaml_version.compare curr_version v) 0
317-
| None -> true
316+
) versions
318317

319318
let os_type_enabled os_type =
320319
match os_type with
@@ -349,7 +348,7 @@ type block_config = {
349348
env : string option;
350349
dir : string option;
351350
skip : bool;
352-
version : (Label.Relation.t * Ocaml_version.t) option;
351+
version : (Label.Relation.t * Ocaml_version.t) list;
353352
os_type : (Label.Relation.t * string) option;
354353
set_variables : (string * string) list;
355354
unset_variables : string list;
@@ -369,7 +368,7 @@ let get_block_config l =
369368
env = get_label (function Env x -> Some x | _ -> None) l;
370369
dir = get_label (function Dir x -> Some x | _ -> None) l;
371370
skip = List.exists (function Label.Skip -> true | _ -> false) l;
372-
version = get_label (function Version (x, y) -> Some (x, y) | _ -> None) l;
371+
version = List.filter_map (function Label.Version (x, y) -> Some (x, y) | _ -> None) l;
373372
os_type = get_label (function Os_type (x, y) -> Some (x, y) | _ -> None) l;
374373
set_variables =
375374
List.filter_map (function Label.Set (v, x) -> Some (v, x) | _ -> None) l;

0 commit comments

Comments
 (0)